codekingpro/portable-devtools
114k
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">2<html>3<!-- Created by , GNU Texinfo 7.1.1 -->4 <head>5 <meta charset="utf-8">6 <title>7 FFmpeg FAQ8 </title>9 <meta name="viewport" content="width=device-width,initial-scale=1.0">10 <link rel="stylesheet" type="text/css" href="bootstrap.min.css">11 <link rel="stylesheet" type="text/css" href="style.min.css">12 </head>13 <body>14 <div class="container">15 <h1>16 FFmpeg FAQ17 </h1>18 19 20<a name="SEC_Top"></a>21 22<div class="element-contents" id="SEC_Contents">23<h2 class="contents-heading">Table of Contents</h2>24 25<div class="contents">26 27<ul class="toc-numbered-mark">28 <li><a id="toc-General-Questions" href="#General-Questions">1 General Questions</a>29 <ul class="toc-numbered-mark">30 <li><a id="toc-Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f" href="#Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f">1.1 Why doesn’t FFmpeg support feature [xyz]?</a></li>31 <li><a id="toc-FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f" href="#FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f">1.2 FFmpeg does not support codec XXX. Can you include a Windows DLL loader to support it?</a></li>32 <li><a id="toc-I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e" href="#I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e">1.3 I cannot read this file although this format seems to be supported by ffmpeg.</a></li>33 <li><a id="toc-Which-codecs-are-supported-by-Windows_003f" href="#Which-codecs-are-supported-by-Windows_003f">1.4 Which codecs are supported by Windows?</a></li>34 </ul></li>35 <li><a id="toc-Compilation" href="#Compilation">2 Compilation</a>36 <ul class="toc-numbered-mark">37 <li><a id="toc-error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027" href="#error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027">2.1 <code class="code">error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'</code></a></li>38 <li><a id="toc-I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f" href="#I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f">2.2 I have installed this library with my distro’s package manager. Why does <code class="command">configure</code> not see it?</a></li>39 <li><a id="toc-How-do-I-make-pkg_002dconfig-find-my-libraries_003f" href="#How-do-I-make-pkg_002dconfig-find-my-libraries_003f">2.3 How do I make <code class="command">pkg-config</code> find my libraries?</a></li>40 <li><a id="toc-How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f" href="#How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f">2.4 How do I use <code class="command">pkg-config</code> when cross-compiling?</a></li>41 </ul></li>42 <li><a id="toc-Usage" href="#Usage">3 Usage</a>43 <ul class="toc-numbered-mark">44 <li><a id="toc-ffmpeg-does-not-work_003b-what-is-wrong_003f" href="#ffmpeg-does-not-work_003b-what-is-wrong_003f">3.1 ffmpeg does not work; what is wrong?</a></li>45 <li><a id="toc-How-do-I-encode-single-pictures-into-movies_003f" href="#How-do-I-encode-single-pictures-into-movies_003f">3.2 How do I encode single pictures into movies?</a></li>46 <li><a id="toc-How-do-I-encode-movie-to-single-pictures_003f" href="#How-do-I-encode-movie-to-single-pictures_003f">3.3 How do I encode movie to single pictures?</a></li>47 <li><a id="toc-Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f" href="#Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f">3.4 Why do I see a slight quality degradation with multithreaded MPEG* encoding?</a></li>48 <li><a id="toc-How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f" href="#How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f">3.5 How can I read from the standard input or write to the standard output?</a></li>49 <li><a id="toc-_002df-jpeg-doesn_0027t-work_002e" href="#g_t_002df-jpeg-doesn_0027t-work_002e">3.6 -f jpeg doesn’t work.</a></li>50 <li><a id="toc-Why-can-I-not-change-the-frame-rate_003f" href="#Why-can-I-not-change-the-frame-rate_003f">3.7 Why can I not change the frame rate?</a></li>51 <li><a id="toc-How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f" href="#How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f">3.8 How do I encode Xvid or DivX video with ffmpeg?</a></li>52 <li><a id="toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f">3.9 Which are good parameters for encoding high quality MPEG-4?</a></li>53 <li><a id="toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f">3.10 Which are good parameters for encoding high quality MPEG-1/MPEG-2?</a></li>54 <li><a id="toc-Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f" href="#Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f">3.11 Interlaced video looks very bad when encoded with ffmpeg, what is wrong?</a></li>55 <li><a id="toc-How-can-I-read-DirectShow-files_003f" href="#How-can-I-read-DirectShow-files_003f">3.12 How can I read DirectShow files?</a></li>56 <li><a id="toc-How-can-I-join-video-files_003f" href="#How-can-I-join-video-files_003f">3.13 How can I join video files?</a></li>57 <li><a id="toc-How-can-I-concatenate-video-files_003f" href="#How-can-I-concatenate-video-files_003f">3.14 How can I concatenate video files?</a>58 <ul class="toc-numbered-mark">59 <li><a id="toc-Concatenating-using-the-concat-filter" href="#Concatenating-using-the-concat-filter">3.14.1 Concatenating using the concat <em class="emph">filter</em></a></li>60 <li><a id="toc-Concatenating-using-the-concat-demuxer" href="#Concatenating-using-the-concat-demuxer">3.14.2 Concatenating using the concat <em class="emph">demuxer</em></a></li>61 <li><a id="toc-Concatenating-using-the-concat-protocol-_0028file-level_0029" href="#Concatenating-using-the-concat-protocol-_0028file-level_0029">3.14.3 Concatenating using the concat <em class="emph">protocol</em> (file level)</a></li>62 <li><a id="toc-Concatenating-using-raw-audio-and-video" href="#Concatenating-using-raw-audio-and-video">3.14.4 Concatenating using raw audio and video</a></li>63 </ul></li>64 <li><a id="toc-Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e" href="#Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e">3.15 Using <samp class="option">-f lavfi</samp>, audio becomes mono for no apparent reason.</a></li>65 <li><a id="toc-Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f" href="#Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f">3.16 Why does FFmpeg not see the subtitles in my VOB file?</a></li>66 <li><a id="toc-Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f" href="#Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f">3.17 Why was the <code class="command">ffmpeg</code> <samp class="option">-sameq</samp> option removed? What to use instead?</a></li>67 <li><a id="toc-I-have-a-stretched-video_002c-why-does-scaling-not-fix-it_003f" href="#I-have-a-stretched-video_002c-why-does-scaling-not-fix-it_003f">3.18 I have a stretched video, why does scaling not fix it?</a></li>68 <li><a id="toc-How-do-I-run-ffmpeg-as-a-background-task_003f" href="#How-do-I-run-ffmpeg-as-a-background-task_003f">3.19 How do I run ffmpeg as a background task?</a></li>69 <li><a id="toc-How-do-I-prevent-ffmpeg-from-suspending-with-a-message-like-suspended-_0028tty-output_0029_003f" href="#How-do-I-prevent-ffmpeg-from-suspending-with-a-message-like-suspended-_0028tty-output_0029_003f">3.20 How do I prevent ffmpeg from suspending with a message like <em class="emph">suspended (tty output)</em>?</a></li>70 </ul></li>71 <li><a id="toc-Development" href="#Development">4 Development</a>72 <ul class="toc-numbered-mark">73 <li><a id="toc-Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f" href="#Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f">4.1 Are there examples illustrating how to use the FFmpeg libraries, particularly libavcodec and libavformat?</a></li>74 <li><a id="toc-Can-you-support-my-C-compiler-XXX_003f" href="#Can-you-support-my-C-compiler-XXX_003f">4.2 Can you support my C compiler XXX?</a></li>75 <li><a id="toc-Is-Microsoft-Visual-C_002b_002b-supported_003f" href="#Is-Microsoft-Visual-C_002b_002b-supported_003f">4.3 Is Microsoft Visual C++ supported?</a></li>76 <li><a id="toc-Can-you-add-automake_002c-libtool-or-autoconf-support_003f" href="#Can-you-add-automake_002c-libtool-or-autoconf-support_003f">4.4 Can you add automake, libtool or autoconf support?</a></li>77 <li><a id="toc-Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f" href="#Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f">4.5 Why not rewrite FFmpeg in object-oriented C++?</a></li>78 <li><a id="toc-Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f" href="#Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f">4.6 Why are the ffmpeg programs devoid of debugging symbols?</a></li>79 <li><a id="toc-I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f" href="#I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f">4.7 I do not like the LGPL, can I contribute code under the GPL instead?</a></li>80 <li><a id="toc-I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e" href="#I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e">4.8 I’m using FFmpeg from within my C application but the linker complains about missing symbols from the libraries themselves.</a></li>81 <li><a id="toc-I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e" href="#I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e">4.9 I’m using FFmpeg from within my C++ application but the linker complains about missing symbols which seem to be available.</a></li>82 <li><a id="toc-I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope" href="#I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope">4.10 I’m using libavutil from within my C++ application but the compiler complains about ’UINT64_C’ was not declared in this scope</a></li>83 <li><a id="toc-I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f" href="#I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f">4.11 I have a file in memory / a API different from *open/*read/ libc how do I use it with libavformat?</a></li>84 <li><a id="toc-Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f" href="#Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f">4.12 Where is the documentation about ffv1, msmpeg4, asv1, 4xm?</a></li>85 <li><a id="toc-How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f" href="#How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f">4.13 How do I feed H.263-RTP (and other codecs in RTP) to libavcodec?</a></li>86 <li><a id="toc-AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e" href="#AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e">4.14 AVStream.r_frame_rate is wrong, it is much larger than the frame rate.</a></li>87 <li><a id="toc-Why-is-make-fate-not-running-all-tests_003f" href="#Why-is-make-fate-not-running-all-tests_003f">4.15 Why is <code class="code">make fate</code> not running all tests?</a></li>88 <li><a id="toc-Why-is-make-fate-not-finding-the-samples_003f" href="#Why-is-make-fate-not-finding-the-samples_003f">4.16 Why is <code class="code">make fate</code> not finding the samples?</a></li>89 </ul></li>90</ul>91</div>92</div>93 94<a name="General-Questions"></a>95<h2 class="chapter">1 General Questions<span class="pull-right"><a class="anchor hidden-xs" href="#General-Questions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-General-Questions" aria-hidden="true">TOC</a></span></h2>96 97<a name="Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f"></a>98<h3 class="section">1.1 Why doesn’t FFmpeg support feature [xyz]?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-doesn_0027t-FFmpeg-support-feature-_005bxyz_005d_003f" aria-hidden="true">TOC</a></span></h3>99 100<p>Because no one has taken on that task yet. FFmpeg development is101driven by the tasks that are important to the individual developers.102If there is a feature that is important to you, the best way to get103it implemented is to undertake the task yourself or sponsor a developer.104</p>105<a name="FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f"></a>106<h3 class="section">1.2 FFmpeg does not support codec XXX. Can you include a Windows DLL loader to support it?<span class="pull-right"><a class="anchor hidden-xs" href="#FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-FFmpeg-does-not-support-codec-XXX_002e-Can-you-include-a-Windows-DLL-loader-to-support-it_003f" aria-hidden="true">TOC</a></span></h3>107 108<p>No. Windows DLLs are not portable, bloated and often slow.109Moreover FFmpeg strives to support all codecs natively.110A DLL loader is not conducive to that goal.111</p>112<a name="I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e"></a>113<h3 class="section">1.3 I cannot read this file although this format seems to be supported by ffmpeg.<span class="pull-right"><a class="anchor hidden-xs" href="#I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-cannot-read-this-file-although-this-format-seems-to-be-supported-by-ffmpeg_002e" aria-hidden="true">TOC</a></span></h3>114 115<p>Even if ffmpeg can read the container format, it may not support all its116codecs. Please consult the supported codec list in the ffmpeg117documentation.118</p>119<a name="Which-codecs-are-supported-by-Windows_003f"></a>120<h3 class="section">1.4 Which codecs are supported by Windows?<span class="pull-right"><a class="anchor hidden-xs" href="#Which-codecs-are-supported-by-Windows_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Which-codecs-are-supported-by-Windows_003f" aria-hidden="true">TOC</a></span></h3>121 122<p>Windows does not support standard formats like MPEG very well, unless you123install some additional codecs.124</p>125<p>The following list of video codecs should work on most Windows systems:126</p><dl class="table">127<dt><samp class="option">msmpeg4v2</samp></dt>128<dd><p>.avi/.asf129</p></dd>130<dt><samp class="option">msmpeg4</samp></dt>131<dd><p>.asf only132</p></dd>133<dt><samp class="option">wmv1</samp></dt>134<dd><p>.asf only135</p></dd>136<dt><samp class="option">wmv2</samp></dt>137<dd><p>.asf only138</p></dd>139<dt><samp class="option">mpeg4</samp></dt>140<dd><p>Only if you have some MPEG-4 codec like ffdshow or Xvid installed.141</p></dd>142<dt><samp class="option">mpeg1video</samp></dt>143<dd><p>.mpg only144</p></dd>145</dl>146<p>Note, ASF files often have .wmv or .wma extensions in Windows. It should also147be mentioned that Microsoft claims a patent on the ASF format, and may sue148or threaten users who create ASF files with non-Microsoft software. It is149strongly advised to avoid ASF where possible.150</p>151<p>The following list of audio codecs should work on most Windows systems:152</p><dl class="table">153<dt><samp class="option">adpcm_ima_wav</samp></dt>154<dt><samp class="option">adpcm_ms</samp></dt>155<dt><samp class="option">pcm_s16le</samp></dt>156<dd><p>always157</p></dd>158<dt><samp class="option">libmp3lame</samp></dt>159<dd><p>If some MP3 codec like LAME is installed.160</p></dd>161</dl>162 163 164<a name="Compilation"></a>165<h2 class="chapter">2 Compilation<span class="pull-right"><a class="anchor hidden-xs" href="#Compilation" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Compilation" aria-hidden="true">TOC</a></span></h2>166 167<a name="error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027"></a>168<h3 class="section">2.1 <code class="code">error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'</code><span class="pull-right"><a class="anchor hidden-xs" href="#error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027" aria-hidden="true">TOC</a></span></h3>169 170<p>This is a bug in gcc. Do not report it to us. Instead, please report it to171the gcc developers. Note that we will not add workarounds for gcc bugs.172</p>173<p>Also note that (some of) the gcc developers believe this is not a bug or174not a bug they should fix:175<a class="url" href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203</a>.176Then again, some of them do not know the difference between an undecidable177problem and an NP-hard problem...178</p>179<a name="I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f"></a>180<h3 class="section">2.2 I have installed this library with my distro’s package manager. Why does <code class="command">configure</code> not see it?<span class="pull-right"><a class="anchor hidden-xs" href="#I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-have-installed-this-library-with-my-distro_0027s-package-manager_002e-Why-does-configure-not-see-it_003f" aria-hidden="true">TOC</a></span></h3>181 182<p>Distributions usually split libraries in several packages. The main package183contains the files necessary to run programs using the library. The184development package contains the files necessary to build programs using the185library. Sometimes, docs and/or data are in a separate package too.186</p>187<p>To build FFmpeg, you need to install the development package. It is usually188called <samp class="file">libfoo-dev</samp> or <samp class="file">libfoo-devel</samp>. You can remove it after the189build is finished, but be sure to keep the main package.190</p>191<a name="How-do-I-make-pkg_002dconfig-find-my-libraries_003f"></a>192<h3 class="section">2.3 How do I make <code class="command">pkg-config</code> find my libraries?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-make-pkg_002dconfig-find-my-libraries_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-make-pkg_002dconfig-find-my-libraries_003f" aria-hidden="true">TOC</a></span></h3>193 194<p>Somewhere along with your libraries, there is a <samp class="file">.pc</samp> file (or several)195in a <samp class="file">pkgconfig</samp> directory. You need to set environment variables to196point <code class="command">pkg-config</code> to these files.197</p>198<p>If you need to <em class="emph">add</em> directories to <code class="command">pkg-config</code>’s search list199(typical use case: library installed separately), add it to200<code class="code">$PKG_CONFIG_PATH</code>:201</p>202<div class="example">203<pre class="example-preformatted">export PKG_CONFIG_PATH=/opt/x264/lib/pkgconfig:/opt/opus/lib/pkgconfig204</pre></div>205 206<p>If you need to <em class="emph">replace</em> <code class="command">pkg-config</code>’s search list207(typical use case: cross-compiling), set it in208<code class="code">$PKG_CONFIG_LIBDIR</code>:209</p>210<div class="example">211<pre class="example-preformatted">export PKG_CONFIG_LIBDIR=/home/me/cross/usr/lib/pkgconfig:/home/me/cross/usr/local/lib/pkgconfig212</pre></div>213 214<p>If you need to know the library’s internal dependencies (typical use: static215linking), add the <code class="code">--static</code> option to <code class="command">pkg-config</code>:216</p>217<div class="example">218<pre class="example-preformatted">./configure --pkg-config-flags=--static219</pre></div>220 221<a name="How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f"></a>222<h3 class="section">2.4 How do I use <code class="command">pkg-config</code> when cross-compiling?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-use-pkg_002dconfig-when-cross_002dcompiling_003f" aria-hidden="true">TOC</a></span></h3>223 224<p>The best way is to install <code class="command">pkg-config</code> in your cross-compilation225environment. It will automatically use the cross-compilation libraries.226</p>227<p>You can also use <code class="command">pkg-config</code> from the host environment by228specifying explicitly <code class="code">--pkg-config=pkg-config</code> to <code class="command">configure</code>.229In that case, you must point <code class="command">pkg-config</code> to the correct directories230using the <code class="code">PKG_CONFIG_LIBDIR</code>, as explained in the previous entry.231</p>232<p>As an intermediate solution, you can place in your cross-compilation233environment a script that calls the host <code class="command">pkg-config</code> with234<code class="code">PKG_CONFIG_LIBDIR</code> set. That script can look like that:235</p>236<div class="example">237<pre class="example-preformatted">#!/bin/sh238PKG_CONFIG_LIBDIR=/path/to/cross/lib/pkgconfig239export PKG_CONFIG_LIBDIR240exec /usr/bin/pkg-config "$@"241</pre></div>242 243<a name="Usage"></a>244<h2 class="chapter">3 Usage<span class="pull-right"><a class="anchor hidden-xs" href="#Usage" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Usage" aria-hidden="true">TOC</a></span></h2>245 246<a name="ffmpeg-does-not-work_003b-what-is-wrong_003f"></a>247<h3 class="section">3.1 ffmpeg does not work; what is wrong?<span class="pull-right"><a class="anchor hidden-xs" href="#ffmpeg-does-not-work_003b-what-is-wrong_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-ffmpeg-does-not-work_003b-what-is-wrong_003f" aria-hidden="true">TOC</a></span></h3>248 249<p>Try a <code class="code">make distclean</code> in the ffmpeg source directory before the build.250If this does not help see251(<a class="url" href="https://ffmpeg.org/bugreports.html">https://ffmpeg.org/bugreports.html</a>).252</p>253<a name="How-do-I-encode-single-pictures-into-movies_003f"></a>254<h3 class="section">3.2 How do I encode single pictures into movies?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-encode-single-pictures-into-movies_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-encode-single-pictures-into-movies_003f" aria-hidden="true">TOC</a></span></h3>255 256<p>First, rename your pictures to follow a numerical sequence.257For example, img1.jpg, img2.jpg, img3.jpg,...258Then you may run:259</p>260<div class="example">261<pre class="example-preformatted">ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg262</pre></div>263 264<p>Notice that ‘<samp class="samp">%d</samp>’ is replaced by the image number.265</p>266<p><samp class="file">img%03d.jpg</samp> means the sequence <samp class="file">img001.jpg</samp>, <samp class="file">img002.jpg</samp>, etc.267</p>268<p>Use the <samp class="option">-start_number</samp> option to declare a starting number for269the sequence. This is useful if your sequence does not start with270<samp class="file">img001.jpg</samp> but is still in a numerical order. The following271example will start with <samp class="file">img100.jpg</samp>:272</p>273<div class="example">274<pre class="example-preformatted">ffmpeg -f image2 -start_number 100 -i img%d.jpg /tmp/a.mpg275</pre></div>276 277<p>If you have large number of pictures to rename, you can use the278following command to ease the burden. The command, using the bourne279shell syntax, symbolically links all files in the current directory280that match <code class="code">*jpg</code> to the <samp class="file">/tmp</samp> directory in the sequence of281<samp class="file">img001.jpg</samp>, <samp class="file">img002.jpg</samp> and so on.282</p>283<div class="example">284<pre class="example-preformatted">x=1; for i in *jpg; do counter=$(printf %03d $x); ln -s "$i" /tmp/img"$counter".jpg; x=$(($x+1)); done285</pre></div>286 287<p>If you want to sequence them by oldest modified first, substitute288<code class="code">$(ls -r -t *jpg)</code> in place of <code class="code">*jpg</code>.289</p>290<p>Then run:291</p>292<div class="example">293<pre class="example-preformatted">ffmpeg -f image2 -i /tmp/img%03d.jpg /tmp/a.mpg294</pre></div>295 296<p>The same logic is used for any image format that ffmpeg reads.297</p>298<p>You can also use <code class="command">cat</code> to pipe images to ffmpeg:299</p>300<div class="example">301<pre class="example-preformatted">cat *.jpg | ffmpeg -f image2pipe -c:v mjpeg -i - output.mpg302</pre></div>303 304<a name="How-do-I-encode-movie-to-single-pictures_003f"></a>305<h3 class="section">3.3 How do I encode movie to single pictures?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-encode-movie-to-single-pictures_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-encode-movie-to-single-pictures_003f" aria-hidden="true">TOC</a></span></h3>306 307<p>Use:308</p>309<div class="example">310<pre class="example-preformatted">ffmpeg -i movie.mpg movie%d.jpg311</pre></div>312 313<p>The <samp class="file">movie.mpg</samp> used as input will be converted to314<samp class="file">movie1.jpg</samp>, <samp class="file">movie2.jpg</samp>, etc...315</p>316<p>Instead of relying on file format self-recognition, you may also use317</p><dl class="table">318<dt><samp class="option">-c:v ppm</samp></dt>319<dt><samp class="option">-c:v png</samp></dt>320<dt><samp class="option">-c:v mjpeg</samp></dt>321</dl>322<p>to force the encoding.323</p>324<p>Applying that to the previous example:325</p><div class="example">326<pre class="example-preformatted">ffmpeg -i movie.mpg -f image2 -c:v mjpeg menu%d.jpg327</pre></div>328 329<p>Beware that there is no "jpeg" codec. Use "mjpeg" instead.330</p>331<a name="Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f"></a>332<h3 class="section">3.4 Why do I see a slight quality degradation with multithreaded MPEG* encoding?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-do-I-see-a-slight-quality-degradation-with-multithreaded-MPEG_002a-encoding_003f" aria-hidden="true">TOC</a></span></h3>333 334<p>For multithreaded MPEG* encoding, the encoded slices must be independent,335otherwise thread n would practically have to wait for n-1 to finish, so it’s336quite logical that there is a small reduction of quality. This is not a bug.337</p>338<a name="How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f"></a>339<h3 class="section">3.5 How can I read from the standard input or write to the standard output?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-read-from-the-standard-input-or-write-to-the-standard-output_003f" aria-hidden="true">TOC</a></span></h3>340 341<p>Use <samp class="file">-</samp> as file name.342</p>343<a name="g_t_002df-jpeg-doesn_0027t-work_002e"></a>344<h3 class="section">3.6 -f jpeg doesn’t work.<span class="pull-right"><a class="anchor hidden-xs" href="#_002df-jpeg-doesn_0027t-work_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-_002df-jpeg-doesn_0027t-work_002e" aria-hidden="true">TOC</a></span></h3>345 346<p>Try ’-f image2 test%d.jpg’.347</p>348<a name="Why-can-I-not-change-the-frame-rate_003f"></a>349<h3 class="section">3.7 Why can I not change the frame rate?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-can-I-not-change-the-frame-rate_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-can-I-not-change-the-frame-rate_003f" aria-hidden="true">TOC</a></span></h3>350 351<p>Some codecs, like MPEG-1/2, only allow a small number of fixed frame rates.352Choose a different codec with the -c:v command line option.353</p>354<a name="How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f"></a>355<h3 class="section">3.8 How do I encode Xvid or DivX video with ffmpeg?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-encode-Xvid-or-DivX-video-with-ffmpeg_003f" aria-hidden="true">TOC</a></span></h3>356 357<p>Both Xvid and DivX (version 4+) are implementations of the ISO MPEG-4358standard (note that there are many other coding formats that use this359same standard). Thus, use ’-c:v mpeg4’ to encode in these formats. The360default fourcc stored in an MPEG-4-coded file will be ’FMP4’. If you want361a different fourcc, use the ’-vtag’ option. E.g., ’-vtag xvid’ will362force the fourcc ’xvid’ to be stored as the video fourcc rather than the363default.364</p>365<a name="Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f"></a>366<h3 class="section">3.9 Which are good parameters for encoding high quality MPEG-4?<span class="pull-right"><a class="anchor hidden-xs" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d4_003f" aria-hidden="true">TOC</a></span></h3>367 368<p>’-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2’,369things to try: ’-bf 2’, ’-mpv_flags qp_rd’, ’-mpv_flags mv0’, ’-mpv_flags skip_rd’.370</p>371<a name="Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f"></a>372<h3 class="section">3.10 Which are good parameters for encoding high quality MPEG-1/MPEG-2?<span class="pull-right"><a class="anchor hidden-xs" href="#Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Which-are-good-parameters-for-encoding-high-quality-MPEG_002d1_002fMPEG_002d2_003f" aria-hidden="true">TOC</a></span></h3>373 374<p>’-mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2’375but beware the ’-g 100’ might cause problems with some decoders.376Things to try: ’-bf 2’, ’-mpv_flags qp_rd’, ’-mpv_flags mv0’, ’-mpv_flags skip_rd’.377</p>378<a name="Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f"></a>379<h3 class="section">3.11 Interlaced video looks very bad when encoded with ffmpeg, what is wrong?<span class="pull-right"><a class="anchor hidden-xs" href="#Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Interlaced-video-looks-very-bad-when-encoded-with-ffmpeg_002c-what-is-wrong_003f" aria-hidden="true">TOC</a></span></h3>380 381<p>You should use ’-flags +ilme+ildct’ and maybe ’-flags +alt’ for interlaced382material, and try ’-top 0/1’ if the result looks really messed-up.383</p>384<a name="How-can-I-read-DirectShow-files_003f"></a>385<h3 class="section">3.12 How can I read DirectShow files?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-read-DirectShow-files_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-read-DirectShow-files_003f" aria-hidden="true">TOC</a></span></h3>386 387<p>If you have built FFmpeg with <code class="code">./configure --enable-avisynth</code>388(only possible on MinGW/Cygwin platforms),389then you may use any file that DirectShow can read as input.390</p>391<p>Just create an "input.avs" text file with this single line ...392</p><div class="example">393<pre class="example-preformatted">DirectShowSource("C:\path to your file\yourfile.asf")394</pre></div>395<p>... and then feed that text file to ffmpeg:396</p><div class="example">397<pre class="example-preformatted">ffmpeg -i input.avs398</pre></div>399 400<p>For ANY other help on AviSynth, please visit the401<a class="uref" href="http://www.avisynth.org/">AviSynth homepage</a>.402</p>403<a name="How-can-I-join-video-files_003f"></a>404<h3 class="section">3.13 How can I join video files?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-join-video-files_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-join-video-files_003f" aria-hidden="true">TOC</a></span></h3>405 406<p>To "join" video files is quite ambiguous. The following list explains the407different kinds of "joining" and points out how those are addressed in408FFmpeg. To join video files may mean:409</p>410<ul class="itemize mark-bullet">411<li>To put them one after the other: this is called to <em class="emph">concatenate</em> them412(in short: concat) and is addressed413<a class="ref" href="#How-can-I-concatenate-video-files">in this very faq</a>.414 415</li><li>To put them together in the same file, to let the user choose between the416different versions (example: different audio languages): this is called to417<em class="emph">multiplex</em> them together (in short: mux), and is done by simply418invoking ffmpeg with several <samp class="option">-i</samp> options.419 420</li><li>For audio, to put all channels together in a single stream (example: two421mono streams into one stereo stream): this is sometimes called to422<em class="emph">merge</em> them, and can be done using the423<a class="url" href="ffmpeg-filters.html#amerge"><code class="code">amerge</code></a> filter.424 425</li><li>For audio, to play one on top of the other: this is called to <em class="emph">mix</em>426them, and can be done by first merging them into a single stream and then427using the <a class="url" href="ffmpeg-filters.html#pan"><code class="code">pan</code></a> filter to mix428the channels at will.429 430</li><li>For video, to display both together, side by side or one on top of a part of431the other; it can be done using the432<a class="url" href="ffmpeg-filters.html#overlay"><code class="code">overlay</code></a> video filter.433 434</li></ul>435 436<a class="anchor" id="How-can-I-concatenate-video-files"></a><a name="How-can-I-concatenate-video-files_003f"></a>437<h3 class="section">3.14 How can I concatenate video files?<span class="pull-right"><a class="anchor hidden-xs" href="#How-can-I-concatenate-video-files_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-can-I-concatenate-video-files_003f" aria-hidden="true">TOC</a></span></h3>438 439<p>There are several solutions, depending on the exact circumstances.440</p>441<a name="Concatenating-using-the-concat-filter"></a>442<h4 class="subsection">3.14.1 Concatenating using the concat <em class="emph">filter</em><span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-the-concat-filter" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-the-concat-filter" aria-hidden="true">TOC</a></span></h4>443 444<p>FFmpeg has a <a class="url" href="ffmpeg-filters.html#concat"><code class="code">concat</code></a> filter designed specifically for that, with examples in the445documentation. This operation is recommended if you need to re-encode.446</p>447<a name="Concatenating-using-the-concat-demuxer"></a>448<h4 class="subsection">3.14.2 Concatenating using the concat <em class="emph">demuxer</em><span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-the-concat-demuxer" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-the-concat-demuxer" aria-hidden="true">TOC</a></span></h4>449 450<p>FFmpeg has a <a class="url" href="ffmpeg-formats.html#concat"><code class="code">concat</code></a> demuxer which you can use when you want to avoid a re-encode and451your format doesn’t support file level concatenation.452</p>453<a name="Concatenating-using-the-concat-protocol-_0028file-level_0029"></a>454<h4 class="subsection">3.14.3 Concatenating using the concat <em class="emph">protocol</em> (file level)<span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-the-concat-protocol-_0028file-level_0029" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-the-concat-protocol-_0028file-level_0029" aria-hidden="true">TOC</a></span></h4>455 456<p>FFmpeg has a <a class="url" href="ffmpeg-protocols.html#concat"><code class="code">concat</code></a> protocol designed specifically for that, with examples in the457documentation.458</p>459<p>A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow one to concatenate460video by merely concatenating the files containing them.461</p>462<p>Hence you may concatenate your multimedia files by first transcoding them to463these privileged formats, then using the humble <code class="code">cat</code> command (or the464equally humble <code class="code">copy</code> under Windows), and finally transcoding back to your465format of choice.466</p>467<div class="example">468<pre class="example-preformatted">ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg469ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg470cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg471ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi472</pre></div>473 474<p>Additionally, you can use the <code class="code">concat</code> protocol instead of <code class="code">cat</code> or475<code class="code">copy</code> which will avoid creation of a potentially huge intermediate file.476</p>477<div class="example">478<pre class="example-preformatted">ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg479ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg480ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg481ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi482</pre></div>483 484<p>Note that you may need to escape the character "|" which is special for many485shells.486</p>487<p>Another option is usage of named pipes, should your platform support it:488</p>489<div class="example">490<pre class="example-preformatted">mkfifo intermediate1.mpg491mkfifo intermediate2.mpg492ffmpeg -i input1.avi -qscale:v 1 -y intermediate1.mpg < /dev/null &493ffmpeg -i input2.avi -qscale:v 1 -y intermediate2.mpg < /dev/null &494cat intermediate1.mpg intermediate2.mpg |\495ffmpeg -f mpeg -i - -c:v mpeg4 -c:a libmp3lame output.avi496</pre></div>497 498<a name="Concatenating-using-raw-audio-and-video"></a>499<h4 class="subsection">3.14.4 Concatenating using raw audio and video<span class="pull-right"><a class="anchor hidden-xs" href="#Concatenating-using-raw-audio-and-video" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Concatenating-using-raw-audio-and-video" aria-hidden="true">TOC</a></span></h4>500 501<p>Similarly, the yuv4mpegpipe format, and the raw video, raw audio codecs also502allow concatenation, and the transcoding step is almost lossless.503When using multiple yuv4mpegpipe(s), the first line needs to be discarded504from all but the first stream. This can be accomplished by piping through505<code class="code">tail</code> as seen below. Note that when piping through <code class="code">tail</code> you506must use command grouping, <code class="code">{ ;}</code>, to background properly.507</p>508<p>For example, let’s say we want to concatenate two FLV files into an509output.flv file:510</p>511<div class="example">512<pre class="example-preformatted">mkfifo temp1.a513mkfifo temp1.v514mkfifo temp2.a515mkfifo temp2.v516mkfifo all.a517mkfifo all.v518ffmpeg -i input1.flv -vn -f u16le -c:a pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &519ffmpeg -i input2.flv -vn -f u16le -c:a pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &520ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &521{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } &522cat temp1.a temp2.a > all.a &523cat temp1.v temp2.v > all.v &524ffmpeg -f u16le -c:a pcm_s16le -ac 2 -ar 44100 -i all.a \525 -f yuv4mpegpipe -i all.v \526 -y output.flv527rm temp[12].[av] all.[av]528</pre></div>529 530<a name="Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e"></a>531<h3 class="section">3.15 Using <samp class="option">-f lavfi</samp>, audio becomes mono for no apparent reason.<span class="pull-right"><a class="anchor hidden-xs" href="#Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Using-_002df-lavfi_002c-audio-becomes-mono-for-no-apparent-reason_002e" aria-hidden="true">TOC</a></span></h3>532 533<p>Use <samp class="option">-dumpgraph -</samp> to find out exactly where the channel layout is534lost.535</p>536<p>Most likely, it is through <code class="code">auto-inserted aresample</code>. Try to understand537why the converting filter was needed at that place.538</p>539<p>Just before the output is a likely place, as <samp class="option">-f lavfi</samp> currently540only support packed S16.541</p>542<p>Then insert the correct <code class="code">aformat</code> explicitly in the filtergraph,543specifying the exact format.544</p>545<div class="example">546<pre class="example-preformatted">aformat=sample_fmts=s16:channel_layouts=stereo547</pre></div>548 549<a name="Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f"></a>550<h3 class="section">3.16 Why does FFmpeg not see the subtitles in my VOB file?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-does-FFmpeg-not-see-the-subtitles-in-my-VOB-file_003f" aria-hidden="true">TOC</a></span></h3>551 552<p>VOB and a few other formats do not have a global header that describes553everything present in the file. Instead, applications are supposed to scan554the file to see what it contains. Since VOB files are frequently large, only555the beginning is scanned. If the subtitles happen only later in the file,556they will not be initially detected.557</p>558<p>Some applications, including the <code class="code">ffmpeg</code> command-line tool, can only559work with streams that were detected during the initial scan; streams that560are detected later are ignored.561</p>562<p>The size of the initial scan is controlled by two options: <code class="code">probesize</code>563(default ~5 Mo) and <code class="code">analyzeduration</code> (default 5,000,000 µs = 5 s). For564the subtitle stream to be detected, both values must be large enough.565</p>566<a name="Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f"></a>567<h3 class="section">3.17 Why was the <code class="command">ffmpeg</code> <samp class="option">-sameq</samp> option removed? What to use instead?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-was-the-ffmpeg-_002dsameq-option-removed_003f-What-to-use-instead_003f" aria-hidden="true">TOC</a></span></h3>568 569<p>The <samp class="option">-sameq</samp> option meant "same quantizer", and made sense only in a570very limited set of cases. Unfortunately, a lot of people mistook it for571"same quality" and used it in places where it did not make sense: it had572roughly the expected visible effect, but achieved it in a very inefficient573way.574</p>575<p>Each encoder has its own set of options to set the quality-vs-size balance,576use the options for the encoder you are using to set the quality level to a577point acceptable for your tastes. The most common options to do that are578<samp class="option">-qscale</samp> and <samp class="option">-qmax</samp>, but you should peruse the documentation579of the encoder you chose.580</p>581<a name="I-have-a-stretched-video_002c-why-does-scaling-not-fix-it_003f"></a>582<h3 class="section">3.18 I have a stretched video, why does scaling not fix it?<span class="pull-right"><a class="anchor hidden-xs" href="#I-have-a-stretched-video_002c-why-does-scaling-not-fix-it_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-have-a-stretched-video_002c-why-does-scaling-not-fix-it_003f" aria-hidden="true">TOC</a></span></h3>583 584<p>A lot of video codecs and formats can store the <em class="emph">aspect ratio</em> of the585video: this is the ratio between the width and the height of either the full586image (DAR, display aspect ratio) or individual pixels (SAR, sample aspect587ratio). For example, EGA screens at resolution 640×350 had 4:3 DAR and 35:48588SAR.589</p>590<p>Most still image processing work with square pixels, i.e. 1:1 SAR, but a lot591of video standards, especially from the analogic-numeric transition era, use592non-square pixels.593</p>594<p>Most processing filters in FFmpeg handle the aspect ratio to avoid595stretching the image: cropping adjusts the DAR to keep the SAR constant,596scaling adjusts the SAR to keep the DAR constant.597</p>598<p>If you want to stretch, or “unstretch”, the image, you need to override the599information with the600<a class="url" href="ffmpeg-filters.html#setdar_002c-setsar"><code class="code">setdar or setsar filters</code></a>.601</p>602<p>Do not forget to examine carefully the original video to check whether the603stretching comes from the image or from the aspect ratio information.604</p>605<p>For example, to fix a badly encoded EGA capture, use the following commands,606either the first one to upscale to square pixels or the second one to set607the correct aspect ratio or the third one to avoid transcoding (may not work608depending on the format / codec / player / phase of the moon):609</p>610<div class="example">611<pre class="example-preformatted">ffmpeg -i ega_screen.nut -vf scale=640:480,setsar=1 ega_screen_scaled.nut612ffmpeg -i ega_screen.nut -vf setdar=4/3 ega_screen_anamorphic.nut613ffmpeg -i ega_screen.nut -aspect 4/3 -c copy ega_screen_overridden.nut614</pre></div>615 616<a class="anchor" id="background-task"></a><a name="How-do-I-run-ffmpeg-as-a-background-task_003f"></a>617<h3 class="section">3.19 How do I run ffmpeg as a background task?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-run-ffmpeg-as-a-background-task_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-run-ffmpeg-as-a-background-task_003f" aria-hidden="true">TOC</a></span></h3>618 619<p>ffmpeg normally checks the console input, for entries like "q" to stop620and "?" to give help, while performing operations. ffmpeg does not have a way of621detecting when it is running as a background task.622When it checks the console input, that can cause the process running ffmpeg623in the background to suspend.624</p>625<p>To prevent those input checks, allowing ffmpeg to run as a background task,626use the <a class="url" href="ffmpeg.html#stdin-option"><code class="code">-nostdin</code> option</a>627in the ffmpeg invocation. This is effective whether you run ffmpeg in a shell628or invoke ffmpeg in its own process via an operating system API.629</p>630<p>As an alternative, when you are running ffmpeg in a shell, you can redirect631standard input to <code class="code">/dev/null</code> (on Linux and macOS)632or <code class="code">NUL</code> (on Windows). You can do this redirect either633on the ffmpeg invocation, or from a shell script which calls ffmpeg.634</p>635<p>For example:636</p>637<div class="example">638<pre class="example-preformatted">ffmpeg -nostdin -i INPUT OUTPUT639</pre></div>640 641<p>or (on Linux, macOS, and other UNIX-like shells):642</p>643<div class="example">644<pre class="example-preformatted">ffmpeg -i INPUT OUTPUT </dev/null645</pre></div>646 647<p>or (on Windows):648</p>649<div class="example">650<pre class="example-preformatted">ffmpeg -i INPUT OUTPUT <NUL651</pre></div>652 653<a name="How-do-I-prevent-ffmpeg-from-suspending-with-a-message-like-suspended-_0028tty-output_0029_003f"></a>654<h3 class="section">3.20 How do I prevent ffmpeg from suspending with a message like <em class="emph">suspended (tty output)</em>?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-prevent-ffmpeg-from-suspending-with-a-message-like-suspended-_0028tty-output_0029_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-prevent-ffmpeg-from-suspending-with-a-message-like-suspended-_0028tty-output_0029_003f" aria-hidden="true">TOC</a></span></h3>655 656<p>If you run ffmpeg in the background, you may find that its process suspends.657There may be a message like <em class="emph">suspended (tty output)</em>. The question is how658to prevent the process from being suspended.659</p>660<p>For example:661</p>662<div class="example">663<pre class="example-preformatted">% ffmpeg -i INPUT OUTPUT &> ~/tmp/log.txt &664[1] 93352665%666[1] + suspended (tty output) ffmpeg -i INPUT OUTPUT &>667</pre></div>668 669<p>The message "tty output" notwithstanding, the problem here is that670ffmpeg normally checks the console input when it runs. The operating system671detects this, and suspends the process until you can bring it to the672foreground and attend to it.673</p>674<p>The solution is to use the right techniques to tell ffmpeg not to consult675console input. You can use the676<a class="url" href="ffmpeg.html#stdin-option"><code class="code">-nostdin</code> option</a>,677or redirect standard input with <code class="code">< /dev/null</code>.678See FAQ679<a class="ref" href="#background-task"><em class="emph">How do I run ffmpeg as a background task?</em></a>680for details.681</p>682<a name="Development"></a>683<h2 class="chapter">4 Development<span class="pull-right"><a class="anchor hidden-xs" href="#Development" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Development" aria-hidden="true">TOC</a></span></h2>684 685<a name="Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f"></a>686<h3 class="section">4.1 Are there examples illustrating how to use the FFmpeg libraries, particularly libavcodec and libavformat?<span class="pull-right"><a class="anchor hidden-xs" href="#Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Are-there-examples-illustrating-how-to-use-the-FFmpeg-libraries_002c-particularly-libavcodec-and-libavformat_003f" aria-hidden="true">TOC</a></span></h3>687 688<p>Yes. Check the <samp class="file">doc/examples</samp> directory in the source689repository, also available online at:690<a class="url" href="https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples">https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples</a>.691</p>692<p>Examples are also installed by default, usually in693<code class="code">$PREFIX/share/ffmpeg/examples</code>.694</p>695<p>Also you may read the Developers Guide of the FFmpeg documentation. Alternatively,696examine the source code for one of the many open source projects that697already incorporate FFmpeg at (<a class="url" href="projects.html">projects.html</a>).698</p>699<a name="Can-you-support-my-C-compiler-XXX_003f"></a>700<h3 class="section">4.2 Can you support my C compiler XXX?<span class="pull-right"><a class="anchor hidden-xs" href="#Can-you-support-my-C-compiler-XXX_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Can-you-support-my-C-compiler-XXX_003f" aria-hidden="true">TOC</a></span></h3>701 702<p>It depends. If your compiler is C99-compliant, then patches to support703it are likely to be welcome if they do not pollute the source code704with <code class="code">#ifdef</code>s related to the compiler.705</p>706<a name="Is-Microsoft-Visual-C_002b_002b-supported_003f"></a>707<h3 class="section">4.3 Is Microsoft Visual C++ supported?<span class="pull-right"><a class="anchor hidden-xs" href="#Is-Microsoft-Visual-C_002b_002b-supported_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Is-Microsoft-Visual-C_002b_002b-supported_003f" aria-hidden="true">TOC</a></span></h3>708 709<p>Yes. Please see the <a class="uref" href="platform.html">Microsoft Visual C++</a>710section in the FFmpeg documentation.711</p>712<a name="Can-you-add-automake_002c-libtool-or-autoconf-support_003f"></a>713<h3 class="section">4.4 Can you add automake, libtool or autoconf support?<span class="pull-right"><a class="anchor hidden-xs" href="#Can-you-add-automake_002c-libtool-or-autoconf-support_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Can-you-add-automake_002c-libtool-or-autoconf-support_003f" aria-hidden="true">TOC</a></span></h3>714 715<p>No. These tools are too bloated and they complicate the build.716</p>717<a name="Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f"></a>718<h3 class="section">4.5 Why not rewrite FFmpeg in object-oriented C++?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-not-rewrite-FFmpeg-in-object_002doriented-C_002b_002b_003f" aria-hidden="true">TOC</a></span></h3>719 720<p>FFmpeg is already organized in a highly modular manner and does not need to721be rewritten in a formal object language. Further, many of the developers722favor straight C; it works for them. For more arguments on this matter,723read <a class="uref" href="https://web.archive.org/web/20111004021423/http://kernel.org/pub/linux/docs/lkml/#s15">"Programming Religion"</a>.724</p>725<a name="Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f"></a>726<h3 class="section">4.6 Why are the ffmpeg programs devoid of debugging symbols?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-are-the-ffmpeg-programs-devoid-of-debugging-symbols_003f" aria-hidden="true">TOC</a></span></h3>727 728<p>The build process creates <code class="command">ffmpeg_g</code>, <code class="command">ffplay_g</code>, etc. which729contain full debug information. Those binaries are stripped to create730<code class="command">ffmpeg</code>, <code class="command">ffplay</code>, etc. If you need the debug information, use731the *_g versions.732</p>733<a name="I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f"></a>734<h3 class="section">4.7 I do not like the LGPL, can I contribute code under the GPL instead?<span class="pull-right"><a class="anchor hidden-xs" href="#I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-do-not-like-the-LGPL_002c-can-I-contribute-code-under-the-GPL-instead_003f" aria-hidden="true">TOC</a></span></h3>735 736<p>Yes, as long as the code is optional and can easily and cleanly be placed737under #if CONFIG_GPL without breaking anything. So, for example, a new codec738or filter would be OK under GPL while a bug fix to LGPL code would not.739</p>740<a name="I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e"></a>741<h3 class="section">4.8 I’m using FFmpeg from within my C application but the linker complains about missing symbols from the libraries themselves.<span class="pull-right"><a class="anchor hidden-xs" href="#I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e" aria-hidden="true">TOC</a></span></h3>742 743<p>FFmpeg builds static libraries by default. In static libraries, dependencies744are not handled. That has two consequences. First, you must specify the745libraries in dependency order: <code class="code">-lavdevice</code> must come before746<code class="code">-lavformat</code>, <code class="code">-lavutil</code> must come after everything else, etc.747Second, external libraries that are used in FFmpeg have to be specified too.748</p>749<p>An easy way to get the full list of required libraries in dependency order750is to use <code class="code">pkg-config</code>.751</p>752<div class="example">753<pre class="example-preformatted">c99 -o program program.c $(pkg-config --cflags --libs libavformat libavcodec)754</pre></div>755 756<p>See <samp class="file">doc/example/Makefile</samp> and <samp class="file">doc/example/pc-uninstalled</samp> for757more details.758</p>759<a name="I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e"></a>760<h3 class="section">4.9 I’m using FFmpeg from within my C++ application but the linker complains about missing symbols which seem to be available.<span class="pull-right"><a class="anchor hidden-xs" href="#I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I_0027m-using-FFmpeg-from-within-my-C_002b_002b-application-but-the-linker-complains-about-missing-symbols-which-seem-to-be-available_002e" aria-hidden="true">TOC</a></span></h3>761 762<p>FFmpeg is a pure C project, so to use the libraries within your C++ application763you need to explicitly state that you are using a C library. You can do this by764encompassing your FFmpeg includes using <code class="code">extern "C"</code>.765</p>766<p>See <a class="url" href="http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.3">http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.3</a>767</p>768<a name="I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope"></a>769<h3 class="section">4.10 I’m using libavutil from within my C++ application but the compiler complains about ’UINT64_C’ was not declared in this scope<span class="pull-right"><a class="anchor hidden-xs" href="#I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I_0027m-using-libavutil-from-within-my-C_002b_002b-application-but-the-compiler-complains-about-_0027UINT64_005fC_0027-was-not-declared-in-this-scope" aria-hidden="true">TOC</a></span></h3>770 771<p>FFmpeg is a pure C project using C99 math features, in order to enable C++772to use them you have to append -D__STDC_CONSTANT_MACROS to your CXXFLAGS773</p>774<a name="I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f"></a>775<h3 class="section">4.11 I have a file in memory / a API different from *open/*read/ libc how do I use it with libavformat?<span class="pull-right"><a class="anchor hidden-xs" href="#I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-I-have-a-file-in-memory-_002f-a-API-different-from-_002aopen_002f_002aread_002f-libc-how-do-I-use-it-with-libavformat_003f" aria-hidden="true">TOC</a></span></h3>776 777<p>You have to create a custom AVIOContext using <code class="code">avio_alloc_context</code>,778see <samp class="file">libavformat/aviobuf.c</samp> in FFmpeg and <samp class="file">libmpdemux/demux_lavf.c</samp> in MPlayer or MPlayer2 sources.779</p>780<a name="Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f"></a>781<h3 class="section">4.12 Where is the documentation about ffv1, msmpeg4, asv1, 4xm?<span class="pull-right"><a class="anchor hidden-xs" href="#Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Where-is-the-documentation-about-ffv1_002c-msmpeg4_002c-asv1_002c-4xm_003f" aria-hidden="true">TOC</a></span></h3>782 783<p>see <a class="url" href="https://www.ffmpeg.org/~michael/">https://www.ffmpeg.org/~michael/</a>784</p>785<a name="How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f"></a>786<h3 class="section">4.13 How do I feed H.263-RTP (and other codecs in RTP) to libavcodec?<span class="pull-right"><a class="anchor hidden-xs" href="#How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-How-do-I-feed-H_002e263_002dRTP-_0028and-other-codecs-in-RTP_0029-to-libavcodec_003f" aria-hidden="true">TOC</a></span></h3>787 788<p>Even if peculiar since it is network oriented, RTP is a container like any789other. You have to <em class="emph">demux</em> RTP before feeding the payload to libavcodec.790In this specific case please look at RFC 4629 to see how it should be done.791</p>792<a name="AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e"></a>793<h3 class="section">4.14 AVStream.r_frame_rate is wrong, it is much larger than the frame rate.<span class="pull-right"><a class="anchor hidden-xs" href="#AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e" aria-hidden="true">TOC</a></span></h3>794 795<p><code class="code">r_frame_rate</code> is NOT the average frame rate, it is the smallest frame rate796that can accurately represent all timestamps. So no, it is not797wrong if it is larger than the average!798For example, if you have mixed 25 and 30 fps content, then <code class="code">r_frame_rate</code>799will be 150 (it is the least common multiple).800If you are looking for the average frame rate, see <code class="code">AVStream.avg_frame_rate</code>.801</p>802<a name="Why-is-make-fate-not-running-all-tests_003f"></a>803<h3 class="section">4.15 Why is <code class="code">make fate</code> not running all tests?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-is-make-fate-not-running-all-tests_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-is-make-fate-not-running-all-tests_003f" aria-hidden="true">TOC</a></span></h3>804 805<p>Make sure you have the fate-suite samples and the <code class="code">SAMPLES</code> Make variable806or <code class="code">FATE_SAMPLES</code> environment variable or the <code class="code">--samples</code>807<code class="command">configure</code> option is set to the right path.808</p>809<a name="Why-is-make-fate-not-finding-the-samples_003f"></a>810<h3 class="section">4.16 Why is <code class="code">make fate</code> not finding the samples?<span class="pull-right"><a class="anchor hidden-xs" href="#Why-is-make-fate-not-finding-the-samples_003f" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Why-is-make-fate-not-finding-the-samples_003f" aria-hidden="true">TOC</a></span></h3>811 812<p>Do you happen to have a <code class="code">~</code> character in the samples path to indicate a813home directory? The value is used in ways where the shell cannot expand it,814causing FATE to not find files. Just replace <code class="code">~</code> by the full path.815</p>816 <p style="font-size: small;">817 This document was generated using <a class="uref" href="https://www.gnu.org/software/texinfo/"><em class="emph">makeinfo</em></a>.818 </p>819 </div>820 </body>821</html>822 