<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">Hello all,<br></div><div dir="auto"><div class="gmail_quote" dir="auto"><div lang="EN-US" link="#0563C1" vlink="#954F72"><div class="m_4754091582746901948m_-556863280348909507WordSection1"><p class="MsoNormal"><u></u></p>
<p class="MsoNormal"><u></u>I have been trying to decode videos where I need to offset start position.</p><p class="MsoNormal"><u></u></p>
<p class="MsoNormal">I have tried to use AV_seek_frame but it works on raw video format (.y4m) but fails on mpeg2 compressed formats.
<u></u><u></u></p>
<p class="MsoNormal">Generally videos are in mp4 or wmv and I need to write for those directly instead of converting them into .y4m<u></u><u></u></p>
<p class="MsoNormal">Here how I’m using it <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<table class="m_4754091582746901948m_-556863280348909507MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="margin-left:2.75pt;border-collapse:collapse">
<tbody>
<tr style="height:136.5pt">
<td width="703" valign="top" style="width:613.75pt;border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:136.5pt">
<p class="MsoNormal">//When using with time<u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black">      
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">double</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> t = 5;</span><span style="font-size:9.5pt;font-family:Consolas;color:green">//time in seconds</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black">      
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2b91af">int64_t</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> timestamp = t *
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a">AV_TIME_BASE</span><span style="font-size:9.5pt;font-family:Consolas;color:black">;
</span><span style="font-size:9.5pt;font-family:Consolas;color:green">//destination time</span><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black">      
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2b91af">AVRational</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> r = av_make_q(1,
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a">AV_TIME_BASE</span><span style="font-size:9.5pt;font-family:Consolas;color:black">);     
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black">      
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> (VideoStreamIndex >= 0) {<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black">              timestamp = av_rescale_q(timestamp, r,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black">                     fmt_ctx->streams[VideoStreamIndex]->time_base);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black">       }<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">       av_seek_frame(fmt_ctx, VideoStreamIndex, timestamp,
</span><span style="font-size:9.5pt;font-family:Consolas;color:#6f008a">AVSEEK_FLAG_ANY</span><span style="font-size:9.5pt;font-family:Consolas;color:black">);</span><u></u><u></u></p>
<p class="MsoNormal">or<u></u><u></u></p>
<p class="MsoNormal">if I know the frame no<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:blue">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> frmaeno = 100;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:#2b91af">int64_t</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> point = (</span><span style="font-size:9.5pt;font-family:Consolas;color:#2b91af">int64_t</span><span style="font-size:9.5pt;font-family:Consolas;color:black">(frameno)
 * pavStream->r_frame_rate.den *  pavStream->time_base.den) / (</span><span style="font-size:9.5pt;font-family:Consolas;color:#2b91af">int64_t</span><span style="font-size:9.5pt;font-family:Consolas;color:black">(pavStream->r_frame_rate.num) *pavStream->time_base.num);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">av_seek_frame(fmt_ctx, VideoStreamIndex, point, 0);</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Tried with <span style="font-size:9.5pt;font-family:Consolas;color:black">
avformat_seek_file api too but still failing.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">Need help here.</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="line-height:115%"><span style="font-size:14.0pt;line-height:115%;font-family:Gabriola;color:#595959">Thanks & Warm Regards,</span><b><span style="font-size:14.0pt;line-height:115%;font-family:Gabriola"><u></u><u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:14.0pt;font-family:Gabriola">Ganesh MUNDHE<u></u><u></u></span></b></p>
<br></div>
</div>

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