I am developing a general purpose video encoding application. Encoder used with CBR (constant bit rate) option. It’
But artifacts appear on dynamic video scenes after encoding.
I provide screenshots of the video after encoding that I receive after running the example and the original video.
I followed these steps
# take h264 bitstream from mp4 container
ffmpeg -i design.mp4 -vcodec copy -an -bsf:v h264_mp4toannexb design.h264
# take decoded raw file
tegra_multimedia_api/samples/00_video_decode/video_decode H264 --disable-rendering -o design.raw design.h264
# encode raw file
tegra_multimedia_api/samples/01_video_encode/video_encode design.raw 3840 2160 H264 design_new.h264 -rc cbr --max-perf
What other options can you customize? What can you advise for setting up the encoder to encode such dynamic scenes.
My release version
# R32 (release), REVISION: 2.3, GCID: 17644089, BOARD: t186ref, EABI: aarch64, DATE: Tue Nov 5 21:48:17 UTC 2019
I am also attaching the original video file.
Be default the bitrate is 4Mbps which looks too small for 4K
-br <bitrate> Bitrate [Default = 4000000]
Suggest you try 16Mbps.
I am attaching result with original bitrate 23000K
# encode raw file with original bitrate
tegra_multimedia_api/samples/01_video_encode/video_encode design.raw 3840 2160 H264 design_new.h264 -rc cbr --max-perf -br 23000000
Please try to configure virtual buffer size:
-vbs <size> Virtual buffer size [Default = 0]
Here is a reference link:
And hardware preset type:
-hpt <type> HW preset type (1 = ultrafast, 2 = fast, 3 = medium, 4 = slow)
Please note hardware preset type improves image quality but affects encoding speed. Slow type may not be able to achieve 4Kp30.
unfortunately i got same result (artifacts) with following options
tegra_multimedia_api/samples/01_video_encode/video_encode design.raw 3840 2160 H264 design_new.h264 -rc cbr --max-perf -br 23000000 -vbs 56000000 -hpt 3
The setting looks strange. Bitrate is 23Mbps and virtual buffer size is 56Mbps. You may try virtual buffer size = bitrate/framerate. And 23Mbps may be small for 4K. Please try 40Mbps.
Please show a set of parameters acceptable from your point of view for encoding this example video.
The scene looks complex and I think 40Mbps may not be enough. However, there is trade-off between video quality and bitrate. In general, 40Mbps should be good for most ordinary scenes.