yading10: \input texinfo yading10: yading10: FFmpeg FAQ yading10: yading10: FFmpeg FAQ yading10: titlepage yading10: yading10: yading10: yading10: yading10: yading10: General Questions yading10: yading10: Why doesn't FFmpeg support feature [xyz]? yading10: yading10: Because no one has taken on that task yet. FFmpeg development is yading10: driven by the tasks that are important to the individual developers. yading10: If there is a feature that is important to you, the best way to get yading10: it implemented is to undertake the task yourself or sponsor a developer. yading10: yading10: FFmpeg does not support codec XXX. Can you include a Windows DLL loader to support it? yading10: yading10: No. Windows DLLs are not portable, bloated and often slow. yading10: Moreover FFmpeg strives to support all codecs natively. yading10: A DLL loader is not conducive to that goal. yading10: yading10: I cannot read this file although this format seems to be supported by ffmpeg. yading10: yading10: Even if ffmpeg can read the container format, it may not support all its yading10: codecs. Please consult the supported codec list in the ffmpeg yading10: documentation. yading10: yading10: Which codecs are supported by Windows? yading10: yading10: Windows does not support standard formats like MPEG very well, unless you yading10: install some additional codecs. yading10: yading10: The following list of video codecs should work on most Windows systems: yading10: yading10: msmpeg4v2 yading10: .avi/.asf yading10: msmpeg4 yading10: .asf only yading10: wmv1 yading10: .asf only yading10: wmv2 yading10: .asf only yading10: mpeg4 yading10: Only if you have some MPEG-4 codec like ffdshow or Xvid installed. yading10: mpeg1video yading10: .mpg only yading10: table yading10: Note, ASF files often have .wmv or .wma extensions in Windows. It should also yading10: be mentioned that Microsoft claims a patent on the ASF format, and may sue yading10: or threaten users who create ASF files with non-Microsoft software. It is yading10: strongly advised to avoid ASF where possible. yading10: yading10: The following list of audio codecs should work on most Windows systems: yading10: yading10: adpcm_ima_wav yading10: adpcm_ms yading10: pcm_s16le yading10: always yading10: libmp3lame yading10: If some MP3 codec like LAME is installed. yading10: table yading10: yading10: yading10: Compilation yading10: yading10: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm' yading10: yading10: This is a bug in gcc. Do not report it to us. Instead, please report it to yading10: the gcc developers. Note that we will not add workarounds for gcc bugs. yading10: yading10: Also note that (some of) the gcc developers believe this is not a bug or yading10: not a bug they should fix: yading10: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203. yading10: Then again, some of them do not know the difference between an undecidable yading10: problem and an NP-hard problem... yading10: yading10: I have installed this library with my distro's package manager. Why does configure not see it? yading10: yading10: Distributions usually split libraries in several packages. The main package yading10: contains the files necessary to run programs using the library. The yading10: development package contains the files necessary to build programs using the yading10: library. Sometimes, docs and/or data are in a separate package too. yading10: yading10: To build FFmpeg, you need to install the development package. It is usually yading10: called libfoo-dev or libfoo-devel. You can remove it after the yading10: build is finished, but be sure to keep the main package. yading10: yading10: Usage yading10: yading10: ffmpeg does not work; what is wrong? yading10: yading10: Try a make distclean in the ffmpeg source directory before the build. yading10: If this does not help see yading10: (http://ffmpeg.org/bugreports.html). yading10: yading10: How do I encode single pictures into movies? yading10: yading10: First, rename your pictures to follow a numerical sequence. yading10: For example, img1.jpg, img2.jpg, img3.jpg,... yading10: Then you may run: yading10: yading10: yading10:   ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg yading10: example yading10: yading10: Notice that %d is replaced by the image number. yading10: yading10: img%03d.jpg means the sequence img001.jpg, img002.jpg, etc. yading10: yading10: Use the -start_number option to declare a starting number for yading10: the sequence. This is useful if your sequence does not start with yading10: img001.jpg but is still in a numerical order. The following yading10: example will start with img100.jpg: yading10: yading10: yading10:   ffmpeg -f image2 -start_number 100 -i img%d.jpg /tmp/a.mpg yading10: example yading10: yading10: If you have large number of pictures to rename, you can use the yading10: following command to ease the burden. The command, using the bourne yading10: shell syntax, symbolically links all files in the current directory yading10: that match *jpg to the /tmp directory in the sequence of yading10: img001.jpg, img002.jpg and so on. yading10: yading10: yading10:   x=1; for i in *jpg; do counter=$(printf %03d $x); ln -s "$i" /tmp/img"$counter".jpg; x=$(($x+1)); done yading10: example yading10: yading10: If you want to sequence them by oldest modified first, substitute yading10: $(ls -r -t *jpg) in place of *jpg. yading10: yading10: Then run: yading10: yading10: yading10:   ffmpeg -f image2 -i /tmp/img%03d.jpg /tmp/a.mpg yading10: example yading10: yading10: The same logic is used for any image format that ffmpeg reads. yading10: yading10: You can also use cat to pipe images to ffmpeg: yading10: yading10: yading10:   cat *.jpg | ffmpeg -f image2pipe -c:v mjpeg -i - output.mpg yading10: example yading10: yading10: How do I encode movie to single pictures? yading10: yading10: Use: yading10: yading10: yading10:   ffmpeg -i movie.mpg movie%d.jpg yading10: example yading10: yading10: The movie.mpg used as input will be converted to yading10: movie1.jpg, movie2.jpg, etc... yading10: yading10: Instead of relying on file format self-recognition, you may also use yading10: yading10: -c:v ppm yading10: -c:v png yading10: -c:v mjpeg yading10: table yading10: to force the encoding. yading10: yading10: Applying that to the previous example: yading10: yading10:   ffmpeg -i movie.mpg -f image2 -c:v mjpeg menu%d.jpg yading10: example yading10: yading10: Beware that there is no "jpeg" codec. Use "mjpeg" instead. yading10: yading10: Why do I see a slight quality degradation with multithreaded MPEG* encoding? yading10: yading10: For multithreaded MPEG* encoding, the encoded slices must be independent, yading10: otherwise thread n would practically have to wait for n-1 to finish, so it's yading10: quite logical that there is a small reduction of quality. This is not a bug. yading10: yading10: How can I read from the standard input or write to the standard output? yading10: yading10: Use - as file name. yading10: yading10: -f jpeg doesn't work. yading10: yading10: Try '-f image2 test%d.jpg'. yading10: yading10: Why can I not change the frame rate? yading10: yading10: Some codecs, like MPEG-1/2, only allow a small number of fixed frame rates. yading10: Choose a different codec with the -c:v command line option. yading10: yading10: How do I encode Xvid or DivX video with ffmpeg? yading10: yading10: Both Xvid and DivX (version 4+) are implementations of the ISO MPEG-4 yading10: standard (note that there are many other coding formats that use this yading10: same standard). Thus, use '-c:v mpeg4' to encode in these formats. The yading10: default fourcc stored in an MPEG-4-coded file will be 'FMP4'. If you want yading10: a different fourcc, use the '-vtag' option. E.g., '-vtag xvid' will yading10: force the fourcc 'xvid' to be stored as the video fourcc rather than the yading10: default. yading10: yading10: Which are good parameters for encoding high quality MPEG-4? yading10: yading10: '-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2', yading10: things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd'. yading10: yading10: Which are good parameters for encoding high quality MPEG-1/MPEG-2? yading10: yading10: '-mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2' yading10: but beware the '-g 100' might cause problems with some decoders. yading10: Things to try: '-bf 2', '-flags qprd', '-flags mv0', '-flags skiprd. yading10: yading10: Interlaced video looks very bad when encoded with ffmpeg, what is wrong? yading10: yading10: You should use '-flags +ilme+ildct' and maybe '-flags +alt' for interlaced yading10: material, and try '-top 0/1' if the result looks really messed-up. yading10: yading10: How can I read DirectShow files? yading10: yading10: If you have built FFmpeg with ./configure --enable-avisynth yading10: (only possible on MinGW/Cygwin platforms), yading10: then you may use any file that DirectShow can read as input. yading10: yading10: Just create an "input.avs" text file with this single line ... yading10: yading10:   DirectShowSource("C:\path to your file\yourfile.asf") yading10: example yading10: ... and then feed that text file to ffmpeg: yading10: yading10:   ffmpeg -i input.avs yading10: example yading10: yading10: For ANY other help on Avisynth, please visit the yading10: Avisynth homepage (http://www.avisynth.org/). yading10: yading10: How can I join video files? yading10: yading10: To "join" video files is quite ambiguous. The following list explains the yading10: different kinds of "joining" and points out how those are addressed in yading10: FFmpeg. To join video files may mean: yading10: yading10: yading10: yading10: yading10: To put them one after the other: this is called to concatenate them yading10: (in short: concat) and is addressed yading10: in this very faq. yading10: yading10: yading10: To put them together in the same file, to let the user choose between the yading10: different versions (example: different audio languages): this is called to yading10: multiplex them together (in short: mux), and is done by simply yading10: invoking ffmpeg with several -i options. yading10: yading10: yading10: For audio, to put all channels together in a single stream (example: two yading10: mono streams into one stereo stream): this is sometimes called to yading10: merge them, and can be done using the yading10: amerge (http://ffmpeg.org/ffmpeg-filters.html#amerge) filter. yading10: yading10: yading10: For audio, to play one on top of the other: this is called to mix yading10: them, and can be done by first merging them into a single stream and then yading10: using the pan (http://ffmpeg.org/ffmpeg-filters.html#pan) filter to mix yading10: the channels at will. yading10: yading10: yading10: For video, to display both together, side by side or one on top of a part of yading10: the other; it can be done using the yading10: overlay (http://ffmpeg.org/ffmpeg-filters.html#overlay) video filter. yading10: yading10: itemize yading10: yading10: yading10: How can I concatenate video files? yading10: yading10: There are several solutions, depending on the exact circumstances. yading10: yading10: Concatenating using the concat filter yading10: yading10: FFmpeg has a yading10: concat (http://ffmpeg.org/ffmpeg-filters.html#concat) filter designed specifically for that, with examples in the yading10: documentation. This operation is recommended if you need to re-encode. yading10: yading10: Concatenating using the concat demuxer yading10: yading10: FFmpeg has a yading10: concat (http://www.ffmpeg.org/ffmpeg-formats.html#concat) demuxer which you can use when you want to avoid a re-encode and yading10: your format doesn't support file level concatenation. yading10: yading10: Concatenating using the concat protocol (file level) yading10: yading10: FFmpeg has a yading10: concat (http://ffmpeg.org/ffmpeg-protocols.html#concat) protocol designed specifically for that, with examples in the yading10: documentation. yading10: yading10: A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow to concatenate yading10: video by merely concatenating the files containing them. yading10: yading10: Hence you may concatenate your multimedia files by first transcoding them to yading10: these privileged formats, then using the humble cat command (or the yading10: equally humble copy under Windows), and finally transcoding back to your yading10: format of choice. yading10: yading10: yading10: ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg yading10: ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg yading10: cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg yading10: ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi yading10: example yading10: yading10: Additionally, you can use the concat protocol instead of cat or yading10: copy which will avoid creation of a potentially huge intermediate file. yading10: yading10: yading10: ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg yading10: ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg yading10: ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg yading10: ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi yading10: example yading10: yading10: Note that you may need to escape the character "|" which is special for many yading10: shells. yading10: yading10: Another option is usage of named pipes, should your platform support it: yading10: yading10: yading10: mkfifo intermediate1.mpg yading10: mkfifo intermediate2.mpg yading10: ffmpeg -i input1.avi -qscale:v 1 -y intermediate1.mpg < /dev/null & yading10: ffmpeg -i input2.avi -qscale:v 1 -y intermediate2.mpg < /dev/null & yading10: cat intermediate1.mpg intermediate2.mpg |\ yading10: ffmpeg -f mpeg -i - -c:v mpeg4 -acodec libmp3lame output.avi yading10: example yading10: yading10: Concatenating using raw audio and video yading10: yading10: Similarly, the yuv4mpegpipe format, and the raw video, raw audio codecs also yading10: allow concatenation, and the transcoding step is almost lossless. yading10: When using multiple yuv4mpegpipe(s), the first line needs to be discarded yading10: from all but the first stream. This can be accomplished by piping through yading10: tail as seen below. Note that when piping through tail you yading10: must use command grouping, {  ;}, to background properly. yading10: yading10: For example, let's say we want to concatenate two FLV files into an yading10: output.flv file: yading10: yading10: yading10: mkfifo temp1.a yading10: mkfifo temp1.v yading10: mkfifo temp2.a yading10: mkfifo temp2.v yading10: mkfifo all.a yading10: mkfifo all.v yading10: ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null & yading10: ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null & yading10: ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null & yading10: { ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } & yading10: cat temp1.a temp2.a > all.a & yading10: cat temp1.v temp2.v > all.v & yading10: ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \ yading10:        -f yuv4mpegpipe -i all.v \ yading10:        -y output.flv yading10: rm temp[12].[av] all.[av] yading10: example yading10: yading10: -profile option fails when encoding H.264 video with AAC audio yading10: yading10: ffmpeg prints an error like yading10: yading10: yading10: Undefined constant or missing '(' in 'baseline' yading10: Unable to parse option value "baseline" yading10: Error setting option profile to value baseline. yading10: example yading10: yading10: Short answer: write -profile:v instead of -profile. yading10: yading10: Long answer: this happens because the -profile option can apply to both yading10: video and audio.  Specifically the AAC encoder also defines some profiles, none yading10: of which are named BASELINE. yading10: yading10: The solution is to apply the -profile option to the video stream only yading10: by using Stream specifiers (http://ffmpeg.org/ffmpeg.html#Stream-specifiers-1). yading10: Appending :v to it will do exactly that. yading10: yading10: Using -f lavfi, audio becomes mono for no apparent reason. yading10: yading10: Use -dumpgraph - to find out exactly where the channel layout is yading10: lost. yading10: yading10: Most likely, it is through auto-inserted aresample. Try to understand yading10: why the converting filter was needed at that place. yading10: yading10: Just before the output is a likely place, as -f lavfi currently yading10: only support packed S16. yading10: yading10: Then insert the correct aformat explicitly in the filtergraph, yading10: specifying the exact format. yading10: yading10: yading10: aformat=sample_fmts=s16:channel_layouts=stereo yading10: example yading10: yading10: Why does FFmpeg not see the subtitles in my VOB file? yading10: yading10: VOB and a few other formats do not have a global header that describes yading10: everything present in the file. Instead, applications are supposed to scan yading10: the file to see what it contains. Since VOB files are frequently large, only yading10: the beginning is scanned. If the subtitles happen only later in the file, yading10: they will not be initally detected. yading10: yading10: Some applications, including the ffmpeg command-line tool, can only yading10: work with streams that were detected during the initial scan; streams that yading10: are detected later are ignored. yading10: yading10: The size of the initial scan is controlled by two options: probesize yading10: (default ~5 Mo) and analyzeduration (default 5,000,000 µs = 5 s). For yading10: the subtitle stream to be detected, both values must be large enough. yading10: yading10: Why was the ffmpeg -sameq option removed? What to use instead? yading10: yading10: The -sameq option meant "same quantizer", and made sense only in a yading10: very limited set of cases. Unfortunately, a lot of people mistook it for yading10: "same quality" and used it in places where it did not make sense: it had yading10: roughly the expected visible effect, but achieved it in a very inefficient yading10: way. yading10: yading10: Each encoder has its own set of options to set the quality-vs-size balance, yading10: use the options for the encoder you are using to set the quality level to a yading10: point acceptable for your tastes. The most common options to do that are yading10: -qscale and -qmax, but you should peruse the documentation yading10: of the encoder you chose. yading10: yading10: Development yading10: yading10: Are there examples illustrating how to use the FFmpeg libraries, particularly libavcodec and libavformat? yading10: yading10: Yes. Check the doc/examples directory in the source yading10: repository, also available online at: yading10: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples. yading10: yading10: Examples are also installed by default, usually in yading10: $PREFIX/share/ffmpeg/examples. yading10: yading10: Also you may read the Developers Guide of the FFmpeg documentation. Alternatively, yading10: examine the source code for one of the many open source projects that yading10: already incorporate FFmpeg at (projects.html). yading10: yading10: Can you support my C compiler XXX? yading10: yading10: It depends. If your compiler is C99-compliant, then patches to support yading10: it are likely to be welcome if they do not pollute the source code yading10: with #ifdefs related to the compiler. yading10: yading10: Is Microsoft Visual C++ supported? yading10: yading10: Yes. Please see the Microsoft Visual C++ (platform.html) yading10: section in the FFmpeg documentation. yading10: yading10: Can you add automake, libtool or autoconf support? yading10: yading10: No. These tools are too bloated and they complicate the build. yading10: yading10: Why not rewrite FFmpeg in object-oriented C++? yading10: yading10: FFmpeg is already organized in a highly modular manner and does not need to yading10: be rewritten in a formal object language. Further, many of the developers yading10: favor straight C; it works for them. For more arguments on this matter, yading10: read "Programming Religion" (http://www.tux.org/lkml/#s15). yading10: yading10: Why are the ffmpeg programs devoid of debugging symbols? yading10: yading10: The build process creates ffmpeg_g, ffplay_g, etc. which contain full debug yading10: information. Those binaries are stripped to create ffmpeg, ffplay, etc. If yading10: you need the debug information, use the *_g versions. yading10: yading10: I do not like the LGPL, can I contribute code under the GPL instead? yading10: yading10: Yes, as long as the code is optional and can easily and cleanly be placed yading10: under #if CONFIG_GPL without breaking anything. So, for example, a new codec yading10: or filter would be OK under GPL while a bug fix to LGPL code would not. yading10: yading10: I'm using FFmpeg from within my C application but the linker complains about missing symbols from the libraries themselves. yading10: yading10: FFmpeg builds static libraries by default. In static libraries, dependencies yading10: are not handled. That has two consequences. First, you must specify the yading10: libraries in dependency order: -lavdevice must come before yading10: -lavformat, -lavutil must come after everything else, etc. yading10: Second, external libraries that are used in FFmpeg have to be specified too. yading10: yading10: An easy way to get the full list of required libraries in dependency order yading10: is to use pkg-config. yading10: yading10: yading10:   c99 -o program program.c $(pkg-config --cflags --libs libavformat libavcodec) yading10: example yading10: yading10: See doc/example/Makefile and doc/example/pc-uninstalled for yading10: more details. yading10: yading10: I'm using FFmpeg from within my C++ application but the linker complains about missing symbols which seem to be available. yading10: yading10: FFmpeg is a pure C project, so to use the libraries within your C++ application yading10: you need to explicitly state that you are using a C library. You can do this by yading10: encompassing your FFmpeg includes using extern "C". yading10: yading10: See http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.3 yading10: yading10: I'm using libavutil from within my C++ application but the compiler complains about 'UINT64_C' was not declared in this scope yading10: yading10: FFmpeg is a pure C project using C99 math features, in order to enable C++ yading10: to use them you have to append -D__STDC_CONSTANT_MACROS to your CXXFLAGS yading10: yading10: I have a file in memory / a API different from *open/*read/ libc how do I use it with libavformat? yading10: yading10: You have to create a custom AVIOContext using avio_alloc_context, yading10: see libavformat/aviobuf.c in FFmpeg and libmpdemux/demux_lavf.c in MPlayer or MPlayer2 sources. yading10: yading10: Where can I find libav* headers for Pascal/Delphi? yading10: yading10: see http://www.iversenit.dk/dev/ffmpeg-headers/ yading10: yading10: Where is the documentation about ffv1, msmpeg4, asv1, 4xm? yading10: yading10: see http://www.ffmpeg.org/~michael/ yading10: yading10: How do I feed H.263-RTP (and other codecs in RTP) to libavcodec? yading10: yading10: Even if peculiar since it is network oriented, RTP is a container like any yading10: other. You have to demux RTP before feeding the payload to libavcodec. yading10: In this specific case please look at RFC 4629 to see how it should be done. yading10: yading10: AVStream.r_frame_rate is wrong, it is much larger than the frame rate. yading10: yading10: r_frame_rate is NOT the average frame rate, it is the smallest frame rate yading10: that can accurately represent all timestamps. So no, it is not yading10: wrong if it is larger than the average! yading10: For example, if you have mixed 25 and 30 fps content, then r_frame_rate yading10: will be 150. yading10: yading10: Why is make fate not running all tests? yading10: yading10: Make sure you have the fate-suite samples and the SAMPLES Make variable yading10: or FATE_SAMPLES environment variable or the --samples yading10: configure option is set to the right path. yading10: yading10: Why is make fate not finding the samples? yading10: yading10: Do you happen to have a ~ character in the samples path to indicate a yading10: home directory? The value is used in ways where the shell cannot expand it, yading10: causing FATE to not find files. Just replace ~ by the full path. yading10: yading10: