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
Related
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").
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
I have installed ffmpeg 3.0 from https://github.com/FFmpeg/FFmpeg, I am trying to convert a video coded with mepeg4 part 2 to H264, but I got Unknown encoder 'libx264'
error
Here is my comannd: (I tried h264, x264, libx264, none of them worked)
ffmpeg -i Fashion.divx -acodec aac -vcodec libx264 out.mp4
I checked the list of supported codec
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.. 012v Uncompressed 4:2:2 10-bit
Here is h264:
D.V.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_vdpau)
I am using ffmpeg 3.0, from that list, it seems that encoding with h264 is not supported, only decoding h264 is supported, right?
I tried to enable h.264 with this guide
How to quickly compile FFmpeg with libx264 (x264, H.264)
./configure --enable-gpl --enable-libx264
bu I get
./configure --enable-gpl --enable-libx264
ERROR: libx264 not found
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user#ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.
what should I do to make encode video in h.264 work?
Ok, I just found out I need to install libx264 separately, here is the command
sudo apt-get install yasm libvpx. libx264.
Indeed after install libx264, I get
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_vdpau ) (encoders: libx264 libx264rgb )
Hehe, you've already answered your own question:
Here is h264:
D.V.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_vdpau)
As the listing suggests, the encoder's name is h264, the codec's name can be found between the braces.
So your command should look like this:
ffmpeg -i Fashion.divx -acodec libfaac -vcodec h264 out.mp4
My FFmpeg version has libx264, so the -codecs option prints me this:
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_vdpau ) (encoders: libx264 libx264rgb )
As you can see, I could use -vcodec libx264 or -vcodec libx264rgb.
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
I am trying to use Jave to convert a wmv file into h264(mp4).
The final version created by Jave plays fine with VLC player but when I try to use it inside the HTML5 video tag, it is not able to play the file.
I am guessing that the issue is with the attributes I am setting for the video attributes.
Java Code:
videoAttributes.setCodec("mpeg4");
videoAttributes.setTag("mpeg4");
videoAttributes.setBitRate(new Integer(5000));
videoAttributes.setFrameRate(new Integer(30));
videoAttributes.setSize(new VideoSize(512, 384));
encodingAttributes.setVideoAttributes(videoAttributes);
encodingAttributes.setFormat("mp4");
HTML code:
<video controls="true" width=400 height=200>
<source src="path_to_converted_mp4_file" type="video/mp4" />
Not Supported
</video>
Don't know how Jave identifies codecs but if it uses the same naming as FFmpeg then the codec for HTML5 should be libx264. The mpeg4 codec is "MPEG-4 part 2" according to ffmpeg -codecs.
./ffmpeg -codecs | grep -e mpeg4 -e 264
D V D h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
EV libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
EV libx264rgb libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB
DEVSDT mpeg4 MPEG-4 part 2
DEVSD msmpeg4 MPEG-4 part 2 Microsoft variant version 3
D VSD msmpeg4v1 MPEG-4 part 2 Microsoft variant version 1
DEVSD msmpeg4v2 MPEG-4 part 2 Microsoft variant version 2
According to the JAVE documentation the name of the format is "mp4" not "mpeg4"