<div dir="ltr">Hello,<div><br></div><div><div>This seems like an issue I faced with my own attempt at transcoding video and a fix was suggested by a member of this mailing list (thanks <span class="gmail-il">James</span>). </div><div>I am not sure that this will resolve your issue but it may, so here goes:</div><div><br></div><div>You need to set the AVPacket duration field. This would mean adding something in the lines of the following line of code before your av_interleaved_write_frame is called:</div><div><div><br></div><div>// for example, if 25 FPS, and time_base is 12800, then packet.duration = 12800 / 25 = 512<br></div><div>output_packet.duration = format_context->streams[stream_index]->time_base.den / format_context->streams[stream_index]->time_base.num / format_context->streams[stream_index]->avg_frame_rate.num * format_context->streams[stream_index]->avg_frame_rate.den;<br></div><div><br></div><div> /* mux encoded frame */<br>    ret = av_interleaved_write_frame(format_context, output_packet);<br></div><div><br></div><div>Hope this helps!</div></div></div><div>Vas</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 28, 2021 at 7:09 PM Exclusive Goods Warehouse <<a href="mailto:testchannel256@gmail.com">testchannel256@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
<div>Hello,</div><div><br></div><div>I'm trying to use "muxing.c" file from the examples. I need to export videos in multiple formats with exact fps, let's say 25. I'm using VLC player to check the real fps. 
When i pick .avi format as output, it is exactly 25. Hovewer, when i 
pick .mp4 file, the output video has always slightly different 
framerate, for example 25.166666. This somehow depends on duration of 
the video. Short videos can have even more than 26 fps. This does not happen in console tool ffmpeg, just in the file muxing.c. I don't want to use the console version though.<br></div><div>I have no idea how to fix this. Would somebody be so kind and help me?</div><div><br></div><div>Here is the output:</div><div><br></div><div>[libx264 @ 0x56419e134b00] <br>using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX<br>[libx264 @ 0x56419e134b00] <br>profile High, level 1.3<br>[libx264 @ 0x56419e134b00] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - <a href="http://www.videolan.org/x264.html" target="_blank">http://www.videolan.org/x264.html</a> - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1,00:0,00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=12 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=400 ratetol=1,0 qcomp=0,60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1,40 aq=1:1,00<br>Output #0, mp4, to '/home/****/Videos/test.mp4':<br>    Stream #0:0: Video: h264, yuv420p, 352x288, q=2-31, 400 kb/s, 25 tbn<br>    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 64 kb/s<br>[libx264 @ 0x56419e134b00] <br>frame I:13    Avg QP: 9,53  size:  3837<br>[libx264 @ 0x56419e134b00] frame P:38    Avg QP: 9,60  size:   974<br>[libx264 @ 0x56419e134b00] frame B:100   Avg QP:13,21  size:   970<br>[libx264 @ 0x56419e134b00] consecutive B-frames:  8,6%  1,3% 23,8% 66,2%<br>[libx264 @ 0x56419e134b00] mb I  I16..4: 77,9% 12,5%  9,7%<br>[libx264 @ 0x56419e134b00] mb P  I16..4: 76,4%  4,9%  0,2%  P16..4: 18,1%  0,2%  0,3%  0,0%  0,0%    skip: 0,0%<br>[libx264 @ 0x56419e134b00] mb B  I16..4:  0,0%  0,0%  0,0%  B16..8: 11,9%  0,5%  0,0%  direct:60,1%  skip:27,5%  L0:39,3% L1:56,6% BI: 4,1%<br>[libx264 @ 0x56419e134b00] final ratefactor: 6,01<br>[libx264 @ 0x56419e134b00] 8x8 transform intra:7,9% inter:39,2%<br>[libx264 @ 0x56419e134b00] coded y,uvDC,uvAC intra: 7,0% 15,9% 10,0% inter: 0,2% 74,0% 7,7%<br>[libx264 @ 0x56419e134b00] i16 v,h,dc,p:  0%  0%  0% 100%<br>[libx264 @ 0x56419e134b00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 17%  6% 57%  0%  0%  0%  0%  0%<br>[libx264 @ 0x56419e134b00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11%  4%  5% 74%  4%  0%  0%  2%  1%<br>[libx264 @ 0x56419e134b00] i8c dc,h,v,p:  0%  5%  7% 89%<br>[libx264 @ 0x56419e134b00] Weighted P-Frames: Y:0,0% UV:0,0%<br>[libx264 @ 0x56419e134b00] ref P L0: 98,4%  0,2%  0,6%  0,8%<br>[libx264 @ 0x56419e134b00] ref B L0: 90,0%  8,9%  1,1%<br>[libx264 @ 0x56419e134b00] ref B L1: 95,9%  4,1%<br>[libx264 @ 0x56419e134b00] kb/s:243,60<br>[aac @ 0x56419e11d6a0] Qavg: 321,284<br></div><div><br></div><div><br></div><div><br></div>

</div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div>