<div dir="ltr"><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">hello, i am new to libav. after reading documentation and examples for serveral weeks, i tried to write simple remuxing (e.g mp4->avi) w/o decoding/encoding, just like <b>ffmpeg -i inputfile.mp4 -f avi -c:v copy -an output.avi.</b></div>

<div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)"><br></div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

however both VLC and windows media player refuse to play output avi file - no video playback.</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">moreoever ffprobe on output file shows me incorrect duration and bitrate.</div>

<div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)"><br></div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

moreover, though the output file contains only video streams and lacks audio streams it's much bigger than the input file:</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

<br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><div class="gmail_default"><font color="#330000" face="courier new, monospace">-rw-r--r-- 1 me me 28689538 </font><span style="color:rgb(51,0,0);font-family:'courier new',monospace">Feb  1 13:00</span><font color="#330000" face="courier new, monospace"> inputk.mp4</font></div>

</div><div class="gmail_default"><div class="gmail_default"><font color="#330000" face="courier new, monospace">-rw-r--r-- 1 </font><span style="color:rgb(51,0,0);font-family:'courier new',monospace">me </span><span style="color:rgb(51,0,0);font-family:'courier new',monospace">me </span><font color="#330000" face="courier new, monospace">77916554 Feb  1 13:40 output.avi</font></div>

</div></blockquote><div class="gmail_default"><div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small"><br></div></div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

<br></div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">i am definitely missing somesthing.</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

again, my appologies, i'm a new to libav*. :(</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">thanks for help.</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

<br></div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">PS: sorry for long mail.</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

<br></div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">my shortened code:</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51,51,51);line-height:18px"><div class="" id="LC49" style="padding-left:10px"><span class="" style>avformat_open_input</span><span class="" style>(</span><span class="" style="font-weight:bold">&</span><span class="" style>ic</span><span class="" style>,</span> <span class="" style>infname</span><span class="" style>,</span> <span class="" style="color:rgb(0,134,179)">NULL</span><span class="" style>,</span> <span class="" style="color:rgb(0,134,179)">NULL</span><span class="" style>);</span><div>

<span class="" style>avformat_find_stream_info</span><span class="" style>(</span><span class="" style>ic</span><span class="" style>,</span> <span class="" style="color:rgb(0,134,179)">NULL</span><span class="" style>);</span></div>

<div><span class="" style><br></span></div><div><span class="" style><span class="" style>oc</span> <span class="" style="font-weight:bold">=</span> <span class="" style>avformat_alloc_context</span><span class="" style>();</span></span></div>

<div><span class="" style><span class="" style><span class="" style>oc</span><span class="" style="font-weight:bold">-></span><span class="" style>oformat</span> <span class="" style="font-weight:bold">=</span> <span class="" style>av_guess_format</span><span class="" style>(</span><span class="" style>"avi"</span><span class="" style>,</span> <span class="" style="color:rgb(0,134,179)">NULL</span><span class="" style>,</span> <span class="" style="color:rgb(0,134,179)">NULL</span><span class="" style>);</span></span></span></div>

<div><span class="" style><span class="" style><span class="" style>/**no need to open encoders/decoders since i do no want to recode the frames) **/</span></span></span></div><div><span class="" style><span class="" style><span class="" style><span class="" style>memmove</span><span class="" style>(</span><span class="" style>oc</span><span class="" style="font-weight:bold">-></span><span class="" style>filename</span><span class="" style>,</span> <span class="" style>outfname</span><span class="" style>,</span> <span class="" style>strlen</span><span class="" style>(</span><span class="" style>outfname</span><span class="" style>));</span></span></span></span></div>

<div><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style>avio_open</span><span class="" style>(</span><span class="" style="font-weight:bold">&</span><span class="" style>oc</span><span class="" style="font-weight:bold">-></span><span class="" style>pb</span><span class="" style>,</span> <span class="" style>outfname</span><span class="" style>,</span> <span class="" style>AVIO_FLAG_WRITE</span><span class="" style>);</span></span></span></span></span></div>

<div><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><br></span></span></span></span></span></div><div><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style>// stripped map input video streams to output video streams block</span></span></span></span></span></div>

<div><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><br></span></span></span></span></span></div><div><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style>avformat_write_header</span><span class="" style>(</span><span class="" style>oc</span><span class="" style>,</span> <span class="" style="color:rgb(0,134,179)">NULL</span><span class="" style>);</span></span></span></span></span></span></div>

<div><span class="" style="font-weight:bold">for</span><span class="">(</span><span class="">i</span><span class="" style="font-weight:bold">=</span><span class="" style="color:rgb(0,153,153)">0</span><span class="">;</span> <span class="">av_read_frame</span><span class="">(</span><span class="">ic</span><span class="">,</span> <span class="" style="font-weight:bold">&</span><span class="">inpacket</span><span class="">)</span><span class="" style="font-weight:bold">>=</span><span class="" style="color:rgb(0,153,153)">0</span><span class="">;</span> <span class="">i</span><span class="" style="font-weight:bold">++</span><span class="">,</span> <span class="">av_free_packet</span><span class="">(</span><span class="" style="font-weight:bold">&</span><span class="">inpacket</span><span class="">))</span> <span class="">{</span></div>

<div><pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;margin-top:0px;margin-bottom:0px"><div class="" id="LC150" style="padding-left:10px">        <span class="" style>idx</span> <span class="" style="font-weight:bold">=</span> <span class="" style>inpacket</span><span class="" style>.</span><span class="" style>stream_index</span><span class="" style>;</span></div>

<div class="" id="LC151" style="padding-left:10px">        <span class="">stream</span> <span class="" style="font-weight:bold">=</span> <span class="">ic</span><span class="" style="font-weight:bold">-></span><span class="">streams</span><span class="">[</span><span class="">idx</span><span class="">];</span><br>

</div><div class="" id="LC157" style="padding-left:10px">        <span class="" style="font-weight:bold">if</span><span class="" style>(</span><span class="" style>stream_map</span><span class="" style>[</span><span class="" style>idx</span><span class="" style>]</span><span class="" style="font-weight:bold">==-</span><span class="" style="color:rgb(0,153,153)">1</span><span class="" style>){</span></div>

<div class="" id="LC158" style="padding-left:10px">           <span class="" style="font-weight:bold">continue</span><span class="">;</span></div><div class="" id="LC160" style="padding-left:10px">        <span class="" style>}</span></div>

<div class="" id="LC161" style="padding-left:10px">        <span class="" style="font-weight:bold">if</span><span class="" style>(</span><span class="" style>ic</span><span class="" style="font-weight:bold">-></span><span class="" style>streams</span><span class="" style>[</span><span class="" style>stream_map</span><span class="" style>[</span><span class="" style>idx</span><span class="" style>]]</span><span class="" style="font-weight:bold">-></span><span class="" style>codec</span><span class="" style="font-weight:bold">-></span><span class="" style>codec_type</span><span class="" style>!=</span><span class="">AVMEDIA_TYPE_VIDEO)</span></div>

<div class="" id="LC163" style="padding-left:10px">           <span class="" style="font-weight:bold">continue</span><span class="">;</span><br></div><div class="" id="LC166" style="padding-left:10px">        <span class="">av_copy_packet</span><span class="">(</span><span class="" style="font-weight:bold">&</span><span class="">outpacket</span><span class="">,</span> <span class="" style="font-weight:bold">&</span><span class="">inpacket</span><span class="">);</span><br>

</div><div class="" id="LC169" style="padding-left:10px">        <span class="" style>outpacket</span><span class="" style>.</span><span class="" style>stream_index</span> <span class="" style="font-weight:bold">=</span> <span class="" style>stream_map</span><span class="" style>[</span><span class="" style>idx</span><span class="" style>];</span></div>

<div class="" id="LC170" style="padding-left:10px">        <span class="" style>av_interleaved_write_frame</span><span class="" style>(</span><span class="" style>oc</span><span class="" style>,</span> <span class="" style="font-weight:bold">&</span><span class="" style>outpacket</span><span class="" style>);</span></div>

<div class="" id="LC171" style="padding-left:10px">        <span class="" style>av_free_packet</span><span class="" style>(</span><span class="" style="font-weight:bold">&</span><span class="" style>outpacket</span><span class="" style>);</span></div>

<div class="" id="LC171" style="padding-left:10px">}</div></pre></div><div><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style>av_write_trailer</span><span class="" style>(</span><span class="" style>oc</span><span class="" style>);</span></span></span></span></span></span></span></div>

<div><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><span class="" style><br></span></span></span></span></span></span></span></div></div></pre>

</div><div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">my</span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">full code: <a href="https://github.com/yurkao/libavformat-test/blob/master/remux.c">https://github.com/yurkao/libavformat-test/blob/master/remux.c</a></font><br>

</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)"><br></div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)">

ffprobe original.mp4</div><div class="gmail_default" style="font-family:'courier new',monospace;font-size:small;color:rgb(51,0,0)"><br></div><div class="gmail_default"><div class="gmail_default"><font color="#330000" face="courier new, monospace">> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '</font><span style="color:rgb(51,0,0);font-family:'courier new',monospace">original</span><font color="#330000" face="courier new, monospace">.mp4':</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">  Metadata:</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    major_brand     : mp42</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    minor_version   : 1</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    compatible_brands: isommp41avc1</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    creation_time   : 2011-05-05 18:09:35</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">  Duration: 00:01:10.04, start: 0.000000, bitrate: 3277 kb/s</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 3150 kb/s, 29.96 fps, 29.96 tbr, 29956 tbn, 59.92 tbc (default)</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Metadata:</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      creation_time   : 2011-05-05 18:09:35</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      handler_name    : ?Apple Video Media Handler</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 123 kb/s (default)</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Metadata:</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      creation_time   : 2011-05-05 18:09:35</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      handler_name    : ?Apple Sound Media Handler</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Stream #0:2(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Metadata:</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      creation_time   : 2011-05-05 18:09:35</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      handler_name    : ?</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Stream #0:3(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Metadata:</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      creation_time   : 2011-05-05 18:09:35</font></div>

<div class="gmail_default"><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">      handler_name    : ?</font></div>

<div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small"><br></div><div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small"><br></div><div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small">

ffprobe output.avi</div><div><div><font color="#330000" face="courier new, monospace">> Input #0, avi, from 'output.avi':</font></div><div><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">  Metadata:</font></div>

<div><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    encoder         : Lavf55.19.104</font></div>

<div><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">  Duration: 09:43:16.62, start: 0.000000, bitrate: 17 kb/s</font></div>

<div><span style="color:rgb(51,0,0);font-family:'courier new',monospace">></span><span style="color:rgb(51,0,0);font-family:'courier new',monospace"> </span><font color="#330000" face="courier new, monospace">    Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 59.92 fps, 0.06 tbr, 59.92 tbn, 59.92 tbc</font></div>

<div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small"><br></div></div><div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small">Linux ffmpeg libs:</div>

<div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small">Version:  2.1.3</div><div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small">OS: Ubuntu 12.04.3 LTS amd64</div>

<div style="color:rgb(51,0,0);font-family:'courier new',monospace;font-size:small">compiler: gcc 4.6.3</div><div><font color="#330000" face="courier new, monospace">> --disable-doc --enable-shared --disable-network --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libvpx --enable-libfaac --enable-libopenjpeg --disable-ffserver --enable-postproc --disable-w32threads --disable-os2threads --disable-indevs --disable-outdevs --disable-avdevice --disable-x11grab --enable-pic --enable-zlib --enable-bzlib --enable-shared --enable-avresample --enable-swscale --enable-swresample --enable-postproc --enable-avfilter --enable-avformat --enable-avcodec --enable-avutil</font><br>

</div><div><font color="#330000" face="courier new, monospace"><br></font></div><div><font color="#330000" face="courier new, monospace">Windows ffmpeg libs:</font></div><div><font color="#330000" face="courier new, monospace">Version: ffmpeg-20140121-git-13e0109-win32-shared</font></div>

<div><font color="#330000" face="courier new, monospace">OS: Windows 7 64 bit</font></div><div><font color="#330000" face="courier new, monospace">compiler: VS 2010 target 32bit</font></div><div><font color="#330000" face="courier new, monospace"><br>

</font></div></div></div>