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

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

Related

ffmpeg conditional copy or encode audio stream

My objective is to DirectPlay all my content in Plex.
To do this, I have to conditionally re-encode some audio and video streams, to a format that can be played without the server having to transcode on the fly.
I am currently using HanbrakeCLI to encode video to x264 and audio to a compatible format.
I use the "--aencoder copy --audio-fallback ac3" options, to copy the audio stream as is if in a supported format, i.e. aac/ac3/eac3/truehd/dts/dtshd/mp3/flac, or to encode to ac3 if not a supported format.
I want to switch away from HandbrakeCLI because it does not support copying video streams, sometimes my media has a good video stream, but the audio needs to be encoded only, e.g. WMV with a VC1 video and WMAPro audio stream.
A commandline for HandbrakeCLI looks like:
// Create the HandbrakeCLI commandline and execute
// https://handbrake.fr/docs/en/latest/cli/cli-guide.html
string commandline = $"--input \"{inputname}\" --output \"{outputname}\" --format av_mkv --encoder x264 " +
$"--encoder-preset medium --quality {Settings.Default.VideoEncodeQuality} --subtitle 1,2,3,4 --audio 1,2,3,4 " +
$"--aencoder copy --audio-fallback ac3";
In ffmpeg I would use:
// Create the FFmpeg commandline and execute
// https://trac.ffmpeg.org/wiki/Encode/H.264
string commandline = $"-i \"{inputname}\" -c:v libx264 -crf {Settings.Default.VideoEncodeQuality} -preset medium -c:a copy -f matroska \"{outputname}\"";
Is there an equivalent to HandbrakeCLI's "--audio-fallback ac3" in ffmpeg?
I.e. I want the video to be encoded to x264, all audio tracks copied if the track is aac or ac3 or eac3 or truehd or dts or dtshd or mp3 or flac, and if not, encoded as ac3, while also copying all the subtitles and chapters as is.

How to use ffmpeg to encode video in H.264?

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.

AVCONV / FFMPEG hardware acceleration for video conversion

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.

FFMPEG: how to save input camera stream into the file with the SAME codec format?

I have the camera-like device that produces video stream and passes it into my Windows-based machine via USB port.
Using the command:
ffmpeg -y -f vfwcap -i list
I see that (as expected) FFmpeg finds the input stream as stream #0.
Using the command:
ffmpeg -y -f vfwcap -r 25 -i 0 c:\out.mp4
I can successfully save the input stream into the file.
From the log I see:
Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 240x320, 25 tbr, 1k tbn, 25 tbc
No pixel format specified, yuv422p for H.264 encoding chosen.
So, my input format is transcoded to yuv422p.
My question:
How can I cause FFmpeg to save my input video stream into out.mp4 WITHOUT transcoding - actually, to copy input stream to output file as close as possible, with the same format?
How can I cause ffmpeg to save my input videostream into out.mp4 WITHOUT transcoding
You can not. You can stream copy the rawvideo from vfwcap, but the MP4 container format does not support rawvideo. You have several options:
Use a different output container format.
Stream copy to rawvideo then encode.
Use a lossless encoder (and optionally re-encode it after capturing).
Use a different output container format
This meets your requirement of saving your input without re-encoding.
ffmpeg -f vfwcap -i 0 -codec:v copy rawvideo.nut
rawvideo creates huge file sizes.
Stream copy to rawvideo then encode
This is the same as above, but the rawvideo is then encoded to a more common format.
ffmpeg -f vfwcap -i 0 -codec:v copy rawvideo.nut
ffmpeg -i rawvideo.nut -codec:v libx264 -crf 23 -preset medium -pix_fmt yuv420p -movflags +faststart output.mp4
See the FFmpeg and x264 Encoding Guide for more information about -crf, -preset, and additional detailed information on creating H.264 video.
-pix_fmt yuv420p will use a pixel format that is compatible with dumb players like QuickTime. Refer to colorspace and chroma subsampling for more info.
-movflags +faststart relocates the moov atom which allows the video to begin playback before it is completely downloaded by the client. Useful if you are hosting the video and users will view it in their browser.
Use a lossless encoder
Using huffyuv:
ffmpeg -f vfwcap -i 0 -codec:v huffyuv lossless.mkv
Using lossless H.264:
ffmpeg -f vfwcap -i 0 -codec:v libx264 -qp 0 lossless.mp4
Lossless files can be huge, but not as big as rawvideo.
Re-encoding the lossless output is the same as re-encoding the rawvideo.

ffmpeg usage to encode a video to H264 codec format

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!

Resources