<div dir="ltr">After some more investigation and a good debugging session, it seems the problem comes from the initialisation of the AVFrame rather than the AVCodecContext (as one may misunderstand from the thread).<div><br>
</div><div>To fix the example code, one has to insert 3 lines of code <b>just after</b> the "frame = avcodec_alloc_frame()" call inside "open_video()":</div><div><br></div><div><div class="" style="font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;color:rgb(0,0,0)">
<span style="color:rgb(128,0,0);line-height:1">/* new code to make FFV1 codec work well - does not</span></div><div class="" style="font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;color:rgb(0,0,0)">
<span style="color:rgb(128,0,0);line-height:1">   disturb other codecs, so you can leave it there */</span></div></div><div class="" style="font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;color:rgb(0,0,0)">
<div><span style="font-size:small">frame->format = c->pix_fmt;</span><br></div></div><div class="" style="min-height:13px;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><font color="#000000" face="monospace, fixed"><span style="line-height:13px;white-space:pre-wrap">frame->width = c->width;</span></font></div>
<div class="" style="min-height:13px;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px"><font color="#000000" face="monospace, fixed"><span style="line-height:13px;white-space:pre-wrap">frame->height = c->height;</span></font><br>
</div><div><br></div><div>If you do this, then the example muxing application will work again.</div><div><br></div><div>Could anyone fix the example code in ffmpeg so it reflects these modifications?</div><div><br></div><div>
Best, André</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 22, 2013 at 3:42 PM, André Anjos <span dir="ltr"><<a href="mailto:andre.dos.anjos@gmail.com" target="_blank">andre.dos.anjos@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Another question:<br><div><br></div><div>From my investigations, the program aborts at a failed attempt to encode a new frame (using avcodec_encode_video2()). If the problem is on the initialisation, how can I check the codec is ready before attempting an encode?</div>

<div><br></div><div>Thanks, André</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 22, 2013 at 2:49 PM, André Anjos <span dir="ltr"><<a href="mailto:andre.dos.anjos@gmail.com" target="_blank">andre.dos.anjos@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for this reply. Could you please share a fix for the program that makes it work?<span><font color="#888888"><div>

<br></div><div>André</div></font></span></div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Tue, Oct 22, 2013 at 10:29 AM, Paul B Mahol <span dir="ltr"><<a href="mailto:onemda@gmail.com" target="_blank">onemda@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On 10/22/13, Andre Anjos <<a href="mailto:andre.dos.anjos@gmail.com" target="_blank">andre.dos.anjos@gmail.com</a>> wrote:<br>



> Hello,<br>
><br>
> I'm using a MacPorts build of ffmpeg 2.0.2. It passes most of our tests,<br>
> except the one using the FFV1 codec. This seems independent of the file<br>
> format chosen.<br>
><br>
> How to reproduce the problem:<br>
><br>
> 1) Download the muxing example from the ffmpeg doxygen documentation (<br>
> <a href="http://ffmpeg.org/doxygen/2.0/doc_2examples_2muxing_8c-example.html" target="_blank">http://ffmpeg.org/doxygen/2.0/doc_2examples_2muxing_8c-example.html</a>)<br>
><br>
> 2) By the end of the application, replace the code:<br>
><br>
> if (fmt->video_codec != AV_CODEC_ID_NONE) {<br>
> video_st = add_stream(oc, &video_codec, fmt->video_codec);<br>
> }<br>
><br>
> With:<br>
><br>
> video_st = add_stream(oc, &video_codec, AV_CODEC_ID_FFV1)<br>
><br>
> So, that the FFV1 codec is forced.<br>
><br>
> 3) Compile the program (on OSX, that would be):<br>
><br>
> clang -I/opt/local/include test.c -L/opt/local/lib -lavutil<br>
> -lavcodec -lavformat -lswscale -lswresample -o ffmpeg_test<br>
><br>
> 4) Run the program:<br>
><br>
> ./ffmpeg_test foo.avi<br>
><br>
> to get:<br>
><br>
> [libmp3lame @ 0x7fa7d201f200] Channel layout not specified<br>
>  Output #0, avi, to 'test.avi':<br>
>      Stream #0:0: Video: ffv1, yuv420p, 352x288, q=2-31, 400 kb/s, 90k tbn,<br>
>  25 tbc<br>
>      Stream #0:1: Audio: mp3 (libmp3lame), 44100 Hz, 2 channels, fltp, 64<br>
>  kb/s<br>
>  Error encoding video frame: Invalid argument<br>
><br>
> Result: Bogus file, with error<br>
><br>
> Expected result: clean file with no errors.<br>
><br>
> Can anyone confirm this or provide some light on what I could possibly be<br>
> doing wrong? A developer from MacPorts has confirmed the problem - it does<br>
> not happen on 1.2.x. It does happen with 2.0.1 and 2.0.2 (<br>
> <a href="https://trac.macports.org/ticket/40829" target="_blank">https://trac.macports.org/ticket/40829</a>).<br>
><br>
> Thanks in advance, A<br>
<br>
</div></div>FFmpeg 2.0.X does not have bogus FFV1 codec.<br>
<br>
The examples code is of very low quality.<br>
<br>
FFV1 encoder have been changed in its initialization to abort when<br>
width/height is not set.<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div><br><br clear="all"><div><br></div></div></div><div>-- <br>André Anjos<br><a href="http://andreanjos.org" target="_blank">http://andreanjos.org</a>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>André Anjos<br><a href="http://andreanjos.org" target="_blank">http://andreanjos.org</a>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>André Anjos<br><a href="http://andreanjos.org" target="_blank">http://andreanjos.org</a>
</div>