<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>hi guy's,</div>

<div>i have a problem with the avcodec_encode_video2. i grab a frame from my camera and want to write that into a stream. but avcodec_encode_video2 is generating a segmentation fault.</div>

<div>the main loop is quit simple:</div>

<div> </div>

<div>
<style type="text/css"><!--p, li { white-space: pre-wrap; }
--></style>
<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;"> </p>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#6ffff1;">      for</span><span style=" font-weight:600; color:#007d8b;">(;;)</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;">{</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" color:#6ffff1;">if</span><span style=" font-weight:600; color:#007d8b;">(</span><span style=" color:#3eacff;">av_read_frame</span><span style=" font-weight:600; color:#007d8b;">(</span><span style=" color:#84ada8;">formatCtxIn</span><span style=" font-weight:600; color:#007d8b;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#84ada8;">pktIn</span><span style=" font-weight:600; color:#007d8b;">)</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;">>=</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ff55ff;">0</span><span style=" font-weight:600; color:#007d8b;">)</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;">{</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">          </span><span style=" color:#3eacff;">av_dup_packet</span><span style=" font-weight:600; color:#007d8b;">(</span><span style=" color:#84ada8;">pktIn</span><span style=" font-weight:600; color:#007d8b;">);</span></pre>

<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">          </span><span style=" color:#6ffff1;">int</span><span style=" color:#c0c0c0;"> </span><span style=" color:#84ada8;">fff</span><span style=" font-weight:600; color:#007d8b;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">          </span><span style=" color:#6ffff1;">if</span><span style=" font-weight:600; color:#007d8b;">(</span><span style=" color:#3eacff;">avcodec_decode_video2</span><span style=" font-weight:600; color:#007d8b;">(</span><span style=" color:#84ada8;">codecCtxIn</span><span style=" font-weight:600; color:#007d8b;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#84ada8;">frame</span><span style=" font-weight:600; color:#007d8b;">,</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;">&</span><span style=" color:#84ada8;">fff</span><span style=" font-weight:600; color:#007d8b;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#84ada8;">pktIn</span><span style=" font-weight:600; color:#007d8b;">)</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;"><</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ff55ff;">0</span><span style=" font-weight:600; color:#007d8b;">)</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span><span style=" color:#0059ff;">std</span><span style=" font-weight:600; color:#007d8b;">::</span>cout<span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;"><<</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ffff00;">"shit</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ffff00;">frame"</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;"><<</span><span style=" color:#c0c0c0;"> </span><span style=" color:#0059ff;">std</span><span style=" font-weight:600; color:#007d8b;">::</span>endl<span style=" font-weight:600; color:#007d8b;">;</span></pre>

<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">          </span><span style=" color:#6ffff1;">if</span><span style=" font-weight:600; color:#007d8b;">(!</span><span style=" color:#84ada8;">fff</span><span style=" font-weight:600; color:#007d8b;">)</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span><span style=" color:#6ffff1;">return</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ff55ff;">0</span><span style=" font-weight:600; color:#007d8b;">;</span><span style=" color:#c0c0c0;">  </span><span style=" color:#ff787a;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ff787a;">ok</span></pre>

<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </pre>
<span style=" color:#c0c0c0;">                  </span><span style=" color:#ff787a;">//</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ff787a;">segmentation</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ff787a;">fault</span>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">          </span><span style=" color:#6ffff1;">if</span><span style=" font-weight:600; color:#007d8b;">(</span><span style=" color:#3eacff;">avcodec_encode_video2</span><span style=" font-weight:600; color:#007d8b;">(</span><span style=" color:#84ada8;">streamOut</span><span style=" font-weight:600; color:#007d8b;">-></span>codec<span style=" font-weight:600; color:#007d8b;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#84ada8;">pktOut</span><span style=" font-weight:600; color:#007d8b;">,</span><span style=" color:#c0c0c0;"> </span><span style=" color:#84ada8;">frame</span><span style=" font-weight:600; color:#007d8b;">,</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;">&</span><span style=" color:#84ada8;">fff</span><span style=" font-weight:600; color:#007d8b;">)</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;"><</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ff55ff;">0</span><span style=" font-weight:600; color:#007d8b;">)</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">            </span><span style=" color:#0059ff;">std</span><span style=" font-weight:600; color:#007d8b;">::</span>cout<span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;"><<</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ffff00;">"shit</span><span style=" color:#c0c0c0;"> </span><span style=" color:#ffff00;">frame"</span><span style=" color:#c0c0c0;"> </span><span style=" font-weight:600; color:#007d8b;"><<</span><span style=" color:#c0c0c0;"> </span><span style=" color:#0059ff;">std</span><span style=" font-weight:600; color:#007d8b;">::</span>endl<span style=" font-weight:600; color:#007d8b;">;</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">        </span><span style=" font-weight:600; color:#007d8b;">}</span></pre>

<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">      </span><span style=" font-weight:600; color:#007d8b;">}</span></pre>

<div> </div>

<div>do anybody has any advice for me, why this is happening.</div>

<div> </div>

<div>more code and information you can read here: http://stackoverflow.com/questions/16987749/segmetation-fault-while-avcodec-encode-video2</div>

<div> </div>

<div>cheers</div>

<div>pete</div>
</div>

<div> </div>

<div class="signature"> </div></div></body></html>