<div dir="ltr">Solved it guys. <div><br></div><div>I was calling av_codec_encode_video2 twice for some reason, and the second call was encoding a blank frame instead of the one that had data decoded into it. Silly mistake :p</div>
<div><br></div><div>Thanks for the replies!</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 6, 2013 at 7:51 PM, Alex Cohn <span dir="ltr"><<a href="mailto:alexcohn@netvision.net.il" target="_blank">alexcohn@netvision.net.il</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"><div class="im">On Sun, May 5, 2013 at 2:59 PM, yy-zed <span dir="ltr"><<a href="mailto:samhalligan15@gmail.com" target="_blank">samhalligan15@gmail.com</a>></span> wrote:</div>
<div><br><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I've written a piece of C++ code that can capture webcam video frame, decode<br>
them, convert them to YUV420P, encode them and then write them to a file. If<br>
I use the mpeg2 codec and write to a .mpg file, everything works perfectly.<br>
But, if I use flv, then the output produced is just a green screen. I'm not<br>
sure if there are different encoder settings I need to set for encoding flv<br>
video?Or maybe I'm doing something wrong in sws_scale? Here's my code(the<br>
relevant parts):<br></blockquote><div> </div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">//Read a video frame in<div class="im"><br>
av_read_frame(pFormatCtx,&packet);<br>
<br>
//Decode the contents of packet into pFrame<br>
avcodec_decode_video2(pCodecCtx,pFrame,&frameFinished,&packet);<br></div></blockquote><div><br></div><div>From your snippet, it is not clear what pCodecCtx is, but anyways it's good practice to check the return code from  avcodec_decode_video2() and frameFinished, before you pass pFrame to sws_scale().</div>

<div><br></div><div>BR,</div><div>Alex</div></div></div></div>
<br>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">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>
<br></blockquote></div><br></div>