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.
Related
I tried it with ffmpeg.
ffmpeg input.webm output.webp
input.webm contains transparent background and But the alpha channel becomes white in webp. I think that means alpha channel doesn't come together.
I extracted frames with this command:
ffmpeg -i input.xxx -c:v libwebp output_%03d.webp
And it also gives me webp files with white background.
How can I convert it properly with alpha channel? OR should I convert it from other format(extension)?
Use the -c:v libvpx option before the input to change the decoder like in this example for the first frame (-frames:v 1):
ffmpeg -c:v libvpx -i input.webm -frames:v 1 -c:v libwebp -y output.webp
This comment says that:
FFmpeg's native VPx decoders don't decode alpha. You have to use the libvpx decoder
You can check your decoders using ffmpeg -decoders | grep libvpx and you should see an output like this:
V....D libvpx libvpx VP8 (codec vp8)
V....D libvpx-vp9 libvpx VP9 (codec vp9)
According to that output, libvpx would be the decoder for VP8 and libvpx-vp9 for VP9.
You can check the codec of your video using ffprobe input.webm. You should see an output like this:
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Metadata:
alpha_mode : 1
For converting a whole webm (VP8) to an animated webp use:
ffmpeg -c:v libvpx -i input.webm output.webp
For converting a whole webm (VP9) to an animated webp use:
ffmpeg -c:v libvpx-vp9 -i input.webm output.webp
I have an Ubuntu PC with no video card.
I use avconv for video conversion:
avconv -i video.wmv -c:v libx264 -c:a libmp3lame -b:v 1800K video.mp4
My CPU (Intel Core i7-4770K) processes 1.5-2Gb video in around 7-10 minutes.
In the avconv github sources I saw the options
Hardware accelerators:
--enable-d3d11va enable D3D11VA code
--enable-dxva2 enable DXVA2 code
--enable-vaapi enable VAAPI code
--enable-vda enable VDA code
--enable-vdpau enable VDPAU code
I am thinking of compiling avconv with --enable-vdpau and putting a video card into the PC.
Does this allow avconv to use the video card for video conversion?
How can this increase the speed of video conversion (I mean my command)?
Can you help me to do this test, if you have avconv in your PC with a video card?
Here is an example of WMV.
If you don't want to compile anything from source or use PPAs for extra packages, you can first see what the distribution has to offer:
$ avconv -codecs | grep vdpau
avconv version 9.18-6:9.18-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Mar 16 2015 13:19:10 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
DEV.L. mpeg1video MPEG-1 video (decoders: mpeg1video mpeg1video_vdpau )
DEV.L. mpeg2video MPEG-1 video (decoders: mpeg2video mpegvideo_vdpau )
DEV.L. mpeg4 MPEG-4 part 2 (decoders: mpeg4 mpeg4_vdpau ) (encoders: mpeg4 libxvid )
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_vdpau ) (encoders: libx264 )
D.V.L. vc1 SMPTE VC-1 (decoders: vc1 vc1_vdpau )
D.V.L. wmv3 Windows Media Video 9 (decoders: wmv3 wmv3_vdpau )
Look carefully at the letters "D" - for decoding, "E" for encoding. As you see, VDPAU is only for decoding - it won't help you with encoding the video back. You'd have to measure if this:
avconv -vcodec wmv3_vdpau -i video.wmv -c:v libx264 -c:a libmp3lame -b:v 1800K video.mp4
... gives you any improvement in the tanscoding time.
From my experience the VDPAU is great for watching video - Mplayer2 and VLC support it for display, and I got Mplayer2 to use it also for h264 decoding. The same 1080p clip can play with 80% CPU load on 2 cores with software decoding, and 5-10% CPU load when both the decoding and presentation (video output) is done via VDPAU.
For encoding you could research AMD's VCE, Intel's QuickSync and Nvidia's NVENC (alphabetical order).
Meantime, from ffmpeg:
I had problems with getting avconv to use VDPAU for decoding. Then I stumbled upon this (recommended reading for this kind of question anyway):
https://trac.ffmpeg.org/wiki/HWAccelIntro
-> it seems that the VDPAU decoders support state is:
Actually yes, but is deprecated and should not be used.
So, the final answer is - a card with VDPAU is likely of no advantage in your situation.
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"
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?
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...
I believe that by now the above answers are outdated (or at least unclear) so here's my little go at it.
I tried compiling ffmpeg with the option --enable-encoders=libx264 and it will give no error but it won't enable anything (I can't seem to find where I found that suggestion).
Anyways step-by-step, first you must compile libx264 yourself because repository version is outdated:
wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar --bzip2 -xvf last_x264.tar.bz2
cd x264-snapshot-XXXXXXXX-XXXX/
./configure
make
sudo make install
And then get and compile ffmpeg with libx264 enabled.
I'm using the latest release which is "Happiness":
wget http://ffmpeg.org/releases/ffmpeg-0.11.2.tar.bz2
tar --bzip2 -xvf ffmpeg-0.11.2.tar.bz2
cd ffmpeg-0.11.2/
./configure --enable-libx264 --enable-gpl
make
sudo install
Now finally you have the libx264 codec to encode, to check it you may run
ffmpeg -codecs | grep h264
and you'll see the options you have were the first D means decoding and the first E means encoding
"C:\Program Files (x86)\ffmpegX86shared\bin\ffmpeg.exe" -y -i "C:\testfile.ts" -an -vcodec libx264 -g 75 -keyint_min 12 -vb 4000k -vprofile high -level 40 -s 1920x1080 -y -threads 0 -r 25 "C:\testfile.h264"
The above worked for me on a Windows machine using a FFmpeg Win32 shared build by Kyle Schwarz. The build was compiled on: Feb 22 2013, at: 01:09:53
Note that -an defines that audio should be skipped.
I have a Centos 5 system that I wasn't able to get this working on. So I built a new Fedora 17 system (actually a VM in VMware), and followed the steps at the ffmpeg site to build the latest and greatest ffmpeg.
I took some shortcuts - I skipped all the yum erase commands, added freshrpms according to their instructions:
wget http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/9/freshrpms-release/freshrpms-release-1.1-1.fc.noarch.rpm
rpm -ivh rpmfusion-free-release-stable.noarch.rpm
Then I loaded the stuff that was already readily available:
yum install lame libogg libtheora libvorbis lame-devel libtheora-devel
Afterwards, I only built the following from scratch: libvpx vo-aacenc-0.1.2 x264 yasm-1.2.0 ffmpeg
Then this command encoded with no problems (the audio was already in AAC, so I didn't recode it):
ffmpeg -i input.mov -c:v libx264 -preset slow -crf 22 -c:a copy output.mp4
The result looks just as good as the original to me, and is about 1/4 of the size!