<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Using this code</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" color:#c0c0c0;">        </span><span style=" color:#800080;">AVCodec</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">*pAVCodec=</span><span style=" color:#c0c0c0;"> </span>avcodec_find_encoder<span style=" color:#000000;">(</span><span style=" color:#800080;">CODEC_ID_MPEG4</span><span style=" color:#000000;">);</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">        </span><span style=" font-family:'Courier New,courier'; color:#808000;">if</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000000;">(!pAVCodec)</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier';">qDebug</span><span style=" font-family:'Courier New,courier'; color:#000000;">()</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000000;"><<</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#008000;">"avcodec_find_encoder</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#008000;">Error!!!"</span><span style=" font-family:'Courier New,courier'; color:#000000;">;</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">        </span><span style=" font-family:'Courier New,courier'; color:#808000;">else</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000000;">{</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">            </span><span style=" font-family:'Courier New,courier'; color:#800080;">AVCodecContext</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000000;">*pAVCodecContext=</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier';">avcodec_alloc_context</span><span style=" font-family:'Courier New,courier'; color:#000000;">();</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000000;">{</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">                </span><span style=" font-family:'Courier New,courier'; color:#000000;">pAVCodecContext-></span><span style=" font-family:'Courier New,courier'; color:#800000;">pix_fmt</span><span style=" font-family:'Courier New,courier'; color:#000000;">=</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#800080;">PIX_FMT_YUV420P</span><span style=" font-family:'Courier New,courier'; color:#000000;">;</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">                </span><span style=" font-family:'Courier New,courier'; color:#000000;">pAVCodecContext-></span><span style=" font-family:'Courier New,courier'; color:#800000;">width</span><span style=" font-family:'Courier New,courier'; color:#000000;">=</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#800000;">Width</span><span style=" font-family:'Courier New,courier'; color:#000000;">;</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">                </span><span style=" font-family:'Courier New,courier'; color:#000000;">pAVCodecContext-></span><span style=" font-family:'Courier New,courier'; color:#800000;">height</span><span style=" font-family:'Courier New,courier'; color:#000000;">=</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#800000;">Height</span><span style=" font-family:'Courier New,courier'; color:#000000;">;</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">                </span><span style=" font-family:'Courier New,courier'; color:#000000;">pAVCodecContext-></span><span style=" font-family:'Courier New,courier'; color:#800000;">time_base</span><span style=" font-family:'Courier New,courier'; color:#000000;">.</span><span style=" font-family:'Courier New,courier'; color:#800000;">den</span><span style=" font-family:'Courier New,courier'; color:#000000;">=</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000080;">25</span><span style=" font-family:'Courier New,courier'; color:#000000;">;</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">                </span><span style=" font-family:'Courier New,courier'; color:#000000;">pAVCodecContext-></span><span style=" font-family:'Courier New,courier'; color:#800000;">time_base</span><span style=" font-family:'Courier New,courier'; color:#000000;">.</span><span style=" font-family:'Courier New,courier'; color:#800000;">num</span><span style=" font-family:'Courier New,courier'; color:#000000;">=</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000080;">1</span><span style=" font-family:'Courier New,courier'; color:#000000;">;</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" color:#c0c0c0;">                                    </span><span style=" color:#808000;">int</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">OutSize=</span><span style=" color:#c0c0c0;"> </span>avcodec_encode_video<span style=" color:#000000;">(pAVCodecContext,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">pOutBuffer,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">BYTEPIC,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#000000;">pAVFrame);</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier'; color:#c0c0c0;">                                    </span><span style=" font-family:'Courier New,courier';">fwrite</span><span style=" font-family:'Courier New,courier'; color:#000000;">(pOutBuffe</span><span style=" font-family:'Courier New,courier';">r</span><span style=" font-family:'Courier New,courier'; color:#000000;">,</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000080;">1</span><span style=" font-family:'Courier New,courier'; color:#000000;">,</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000000;">OutSiz</span><span style=" font-family:'Courier New,courier';">e</span><span style=" font-family:'Courier New,courier'; color:#000000;">,</span><span style=" font-family:'Courier New,courier'; color:#c0c0c0;"> </span><span style=" font-family:'Courier New,courier'; color:#000000;">FileOu</span><span style=" font-family:'Courier New,courier';">t</span><span style=" font-family:'Courier New,courier'; color:#000000;">);</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">With this code I can produce a mpg file that I can see it with mplayer but not with vlc. Vlc does not show a good error report, only this rows:</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">denis@tomcat:~/C++/QtCamera/QtCamera-build-desktop$ cvlc a.mpeg </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">VLC media player 1.1.3 The Luggage (revision exported)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Blocked: call to unsetenv("DBUS_ACTIVATION_ADDRESS")</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Blocked: call to unsetenv("DBUS_ACTIVATION_BUS_TYPE")</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">Warning: call to signal(13, 0x1)</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">[0xb7004484] dummy interface: using the dummy interface module...</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">^C[0x91aae34] signals interface error: Caught Interrupt signal, exiting...</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">denis@tomcat:~/C++/QtCamera/QtCamera-build-desktop$ </span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><span style=" font-family:'Courier New,courier';">What can I do to adjust my code in order to produce a mpg file for vlc?</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0; font-family:'Courier New,courier';"></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">-- </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">www.denisgottardello.it</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Skype: mrdebug</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Videosurveillance and home automation! </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">http://www.denisgottardello.it/DomusBoss/DomusBossIndice.php</p></body></html>