What's the difference between ffprobe level and H.264 level? - ffmpeg

ffprobe -show_streams input.mp4
[STREAM]
index=0
codec_name=hevc
codec_long_name=H.265 / HEVC (High Efficiency Video Coding)
profile=Main
codec_type=video
...
level=120
...
https://en.wikipedia.org/wiki/Advanced_Video_Coding

ffprobe indicates the stream codec is H.265 a.k.a. HEVC. The correct Wiki link is https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding_tiers_and_levels
The codec standard requires the level be multiplied by 30 before it is stored in the bitstream. So, a readout of 120 corresponds to 120/30 = level 4

Related

A ffplay Error :"Failed to set value 'yuv420p' for option 'pix_fmt': Option not found"

I was trying to play a video by ffplay. Here’s my command:
ffplay -f rawvideo -pix_fmt yuv420p -video_size 640x360 Resources/video.h264
but I got this error:
Failed to set value 'yuv420p’ for option 'pix_fmt: Option not found
So l used another command to make the video playing correctly, and this is the command:
ffplay -f rawvideo -video_size 640x360 Resources/video.h264
I wonder why the first command reported the error, because I used ffplav -pix_fmts and found that yuv420p is supported.
By the way the pixel format of the video file is yuv420p exactly.
Disclaimer: This is a bit of a speculation (someone with deeper knowledge, please chime in)
The bottom (obvious) line that you cannot set -pix_fmt simply because the h264 decoder isn't allowing you to do so.
You can identify which decoder allows modification of the codec parameter via ffmpeg -h decoder=xxx call. (presumably the same with ffplay)
First try h264, which prints:
Decoder h264 [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:
General capabilities: dr1 delay threads
Threading capabilities: frame and slice
Supported hardware devices: dxva2 (null) d3d11va cuda
H264 Decoder AVOptions:
-is_avc <boolean> .D.V..X.... is avc (default false)
-nal_length_size <int> .D.V..X.... nal_length_size (from 0 to 4) (default 0)
-enable_er <boolean> .D.V....... Enable error resilience on damaged frames (unsafe) (default auto)
-x264_build <int> .D.V....... Assume this x264 version if no x264 version found in any SEI (from -1 to INT_MAX) (default -1)
The key line to look for is General capabilities: dr1 delay threads.
Now, try rawvideo (which I use extensively and know that you can set pix_fmt):
Decoder rawvideo [raw video]:
General capabilities: paramchange
Threading capabilities: none
rawdec AVOptions:
-top <boolean> .D.V....... top field first (default auto)
Here General capabilities lists "paramchange", which wasn't in h264. This capability appears to be the differentiator.
To investigate further, you find "paramchange" is displayed by the source code on fftools/opt_common.c#L301:
if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE)
printf("paramchange ");
and AV_CODEC_CAP_PARAM_CHANGE is defined on libavcodec/codec.h#L118:
/**
* Codec supports changed parameters at any point.
*/
#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14)
The comment appears to fit our circumstance here (if you interpret it with its opposite condition as "Codec supports changed parameters at no point").

FFmpeg GPU 10-bit HEVC encoding using NVENC

I'm encoding some 4K 10-bit YUV test sequences using NVENC HEVC encoder. For an example sequence and configuration, I use the following command.
ffmpeg -hide_banner -benchmark -loglevel debug -y -f rawvideo -s:v 3840x2160 -r 50 -pix_fmt yuv420p10le -i ParkRunning3_3840x2160_50fps_10bit_420.yuv -c:v hevc_nvenc -preset hp -rc cbr -profile:v main10 -b:v 10M output.mp4
My goal is to achieve as low latency as possible; therefore I set the preset to low-latency high-performance. However, I only get around 15 fps encoding speed with this command. A logfile from the ffmpeg output from the above command is here.
I also tried with different presets and different sequences. The results are similar for all the 10-bit sequences I encoded. For 1920x1080 10-bit sequences, I get around 50-60 fps with HEVC encoder. But for 8-bit sequences I'm getting a much higher throughput of around 450-500 fps with similar preset and rate control modes. In the example, I'm using CBR as rate-control mode but I also tested and obtained similar results (in terms of encoding throughput) with VBR and constant QP modes.
Is there anything I'm missing in my command for 10-bit HEVC encoding? I understand that with 10-bit, because of the increased bit-depth, the encoding will take longer. But a reduction in throughput on this scale makes me think that I'm doing something wrong. It seems that FFmpeg is inserting an auto_scaler before the encoder which converts from yuv420p10le (my input format) to p010le (the 10-bit format accepted by NVENC). Could this scaling module reduce the encoder speed so drastically?

What does "level" mean in FFprobe output?

I do not understand some attributes in the output by FFprobe
For a sample file
$ ffprobe -v error -show_format -show_streams input.mp4
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
width=320
height=240
has_b_frames=2
pix_fmt=yuv420p
level=13 <= This one!
color_range=N/A
What does "level" mean here? Is there any document explain those attributes?
The [level][1] means a set of constraints (mostly resolution but bit depth as well) that indicate a degree of required decoder performance for a profile. The 13 probably refers to 1.3

How can I generate encoded HEVC bitstream using ffmpeg?

I am able to encoded YUV file to mp4 using HEVC:
ffmpeg.exe -f rawvideo -s 1920x1080 -pix_fmt yuv420p -i input.yuv -c:v hevc -r 30 -x265-params crf=27 -vframes 300 -an -y test.mp4
Here is the mp4box -info test.mp4 shows:
* Movie Info *
Timescale 1000 - Duration 00:00:10.000
1 track(s)
Fragmented File: no
File suitable for progressive download (moov before mdat)
File Brand isom - version 512
Created: UNKNOWN DATE Modified: UNKNOWN DATE File has no MPEG4 IOD/OD
iTunes Info:
Encoder Software: Lavf56.11.100
Track # 1 Info - TrackID 1 - TimeScale 15360 - Media Duration 00:00:10.000 Track has 1 edit lists: track duration is 00:00:10.000 Media Info: Language "Undetermined" - Type "vide:hev1" - 300 samples Visual Track layout: x=0 y=0 width=1920 height=1080 MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x23 HEVC Video - Visual Size 1920 x 1080
HEVC Info: Profile Main # Level 5 - Chroma Format 1
NAL Unit length bits: 32 - general profile compatibility 0x60000000
Parameter Sets: 1 VPS 1 SPS 1 PPS
SPS resolution 1920x1080
Bit Depth luma 8 - Chroma 8 - 1 temporal layers
But how can I get the decodeble bit stream? I tried
mp4box -raw 1 test.mp4 -out out.bin
It gives:
Extracting MPEG-H HEVC stream to hevc
But the out.bin couldn't be decoded by HM or elecard.
Thanks
Use
ffmpeg -i input.mp4 -c:v hevc -f hevc out.bin
to generate an Annex B bytestream. This can be fed to another decoder.

ffmpeg -acodec and -vcodec parameter inputs list [duplicate]

This question already has answers here:
What are all codecs and formats supported by FFmpeg?
(4 answers)
Closed 1 year ago.
Is there a list somewhere for ffmpeg which lists what the libraries we enter into the -acodec/ -vcodec parameters support?
eg: ffmpeg -vcodec x264 -acodec libmp3lame
I would like a list showing which formats x264/libmp3lame support.
Also is there a list that shows all possible inputs to the -vcodec & -acodec parameters.
You can use ffmpeg -codecs to get a list.
$ ffmpeg -codecs
Codecs:
D..... = Decoding supported
.E.... = Encoding supported
..V... = Video codec
..A... = Audio codec
..S... = Subtitle codec
...I.. = Intra frame-only codec
....L. = Lossy compression
.....S = Lossless compression
-------
D.VI.S 012v Uncompressed 4:2:2 10-bit
D.V.L. 4xm 4X Movie
D.VI.S 8bps QuickTime 8BPS video
.EVIL. a64_multi Multicolor charset for Commodore 64 (encoders: a64multi )
.EVIL. a64_multi5 Multicolor charset for Commodore 64, extended with 5th color (colram) (encoders: a64multi5 )
D.V..S aasc Autodesk RLE
D.VIL. aic Apple Intermediate Codec
DEVI.S alias_pix Alias/Wavefront PIX image
DEVIL. amv AMV Video
D.V.L. anm Deluxe Paint Animation
<snip>
In your case, it looks like you would be interested in this line:
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_crystalhd h264_v4l2m2m h264_vdpau h264_cuvid ) (encoders: libx264 libx264rgb h264_nvenc h264_omx h264_v4l2m2m h264_vaapi nvenc nvenc_h264 )
and this line:
DEA.L. mp3 MP3 (MPEG audio layer 3) (decoders: mp3 mp3float ) (encoders: libmp3lame libshine )
If you want just the video codecs, you can filter them with 'V':
ffmpeg -codecs | grep '^ ..V'
and audio with 'A':
ffmpeg -codecs | grep '^ ..A'
The advantage of this method is that it shows you what codecs your copy of ffmpeg supports. There is also a list of codecs that the most recent version of ffmpeg supports here:
https://ffmpeg.org/ffmpeg-codecs.html
Related:
Determine FFmpeg codecs available for container
How can I determine if a codec / container combination is compatible with FFmpeg?
https://superuser.com/questions/655951/which-codecs-are-supported-by-ffmpeg-libraries-in-system
i have been searching for a while but no luck. you should search one by one.
becuase many containers support variety of codecs, but unfortunately, ffmpeg dose not support that perfectly. even if you can transcode, you can't playback it.
following link is which containers support what codecs. remind that this lists are not matched with ffmpeg perfectly.
http://en.wikipedia.org/wiki/Comparison_of_container_formats
following lists are my tested results in ffmpeg 2.2, which containers support h264/mp3 codecs. perhaps this is what you want :)
H264(libx264) available containers : mp4, flv, ts, mkv, mts, mov, 3gp, 3g2
mp3(libmp3lame) available containers : mp4, wmv, flv, avi, mkv, mpg, mts, mov

Resources