I have a *.mp4 video file(MPEG4 video codec) and I am trying to convert this to a H264 video codec format(raw h.264 format) using ffmpeg on Linux(Version - FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1, Copyright (c) 2000-2009 Fabrice Bellard,) using command line as shown below,
ffmpeg -i input .mp4 output.h264
but I get an error saying -
Unsupported codec for output stream #0.0
Then when i try this option:
ffmpeg -i input .mp4 -formats h264 output.h264
it still does not work, and gives -
Seems stream 0 codec frame rate differs from container frame rate: 59.94 (5994/100) -> 29.97 (30000/1001) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Rapture.mp4': Duration: 00:02:06.44, start: 0.000000, bitrate: 26574 kb/s Stream #0.0(eng): Video: h264, yuv420p, 1920x1080, 29.97 tbr, 29.97 tbn, 59.94 tbc Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16
And then it prints out help on the formats which we get when we do ffmpeg -formats
When I checked the help, ffmpeg -formats
, I see below information related to H264 file format and codec:
File format : DE h264 raw H.264 video format Codecs: D V D h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
My questions :
How can I convert the video to a H264 encoded video (raw H264 video format)
When I do ffmpeg -formats
, I see many acronyms for the codecs supported, I see many acronyms before the codec name/type such as - D V D S E A, what do they stand for?
How to use the ffmpeg options -vcodec
and -formats
?
For the MP4 extension, if you input a 1080p file, FFmpeg will encode using the H. 264 video codec at about 9 to 10 Mbps, the AAC audio codec at around 130 Kbps, a keyframe interval of 250 frames, the High profile, and the medium x264 preset.
Variable Bit Rate with -qscale You can select an audio quality level with -qscale:a (or the alias -q:a ). The value changes depending on the audio encoder. Since this guide uses libmp3lame see the MP3 Encoding Guide for examples and more information.
A codec based on the H. 264 standard compresses a digital video file (or stream) so that it only requires half of the storage space (or network bandwidth) of MPEG-2. Through this compression, the codec is able to maintain the same video quality despite using only half of the storage space.
I used these options to convert to the H.264/AAC .mp4 format for HTML5 playback (I think it may help other guys with this problem in some way):
ffmpeg -i input.flv -vcodec mpeg4 -acodec aac output.mp4
UPDATE
As @LordNeckbeard mentioned, the previous line will produce MPEG-4 Part 2
(back in 2012 that worked somehow, I don't remember/understand why). Use the libx264
encoder to produce the proper video with H.264/AAC. To test the output file you can just drag it to a browser window and it should playback just fine.
ffmpeg -i input.flv -vcodec libx264 -acodec aac output.mp4
I believe you have libx264
installed and configured with ffmpeg
to convert video to h264
... Then you can try with -vcodec libx264
... The -format
option is for showing available formats, this is not a conversion option I think...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With