[Libav-user] Framerate of video is not exact
Exclusive Goods Warehouse
testchannel256 at gmail.com
Thu Apr 29 11:35:41 EEST 2021
Hello,
thanks for reply. I just want to mention that the avg_frame_rate is unset
by default. So I had to set it manually in the part of code where the
stream is initialized, like this:
ost->st->timebase = (AVRational) {1, framerate};
ost->st->avg_frame_rate = (AVRational) {framerate,1};
I did this and now it works fine.
Best regards,
Rick
st 28. 4. 2021 v 18:22 odesílatel Vassilis Pantazis <bpantazhs at gmail.com>
napsal:
> Hello,
>
> 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 James).
> I am not sure that this will resolve your issue but it may, so here goes:
>
> 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:
>
> // for example, if 25 FPS, and time_base is 12800, then packet.duration =
> 12800 / 25 = 512
> 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;
>
> /* mux encoded frame */
> ret = av_interleaved_write_frame(format_context, output_packet);
>
> Hope this helps!
> Vas
>
> On Wed, Apr 28, 2021 at 7:09 PM Exclusive Goods Warehouse <
> testchannel256 at gmail.com> wrote:
>
>> Hello,
>>
>> 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.
>> I have no idea how to fix this. Would somebody be so kind and help me?
>>
>> Here is the output:
>>
>> [libx264 @ 0x56419e134b00]
>> using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX
>> [libx264 @ 0x56419e134b00]
>> profile High, level 1.3
>> [libx264 @ 0x56419e134b00] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4
>> AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html -
>> 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
>> Output #0, mp4, to '/home/****/Videos/test.mp4':
>> Stream #0:0: Video: h264, yuv420p, 352x288, q=2-31, 400 kb/s, 25 tbn
>> Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 64 kb/s
>> [libx264 @ 0x56419e134b00]
>> frame I:13 Avg QP: 9,53 size: 3837
>> [libx264 @ 0x56419e134b00] frame P:38 Avg QP: 9,60 size: 974
>> [libx264 @ 0x56419e134b00] frame B:100 Avg QP:13,21 size: 970
>> [libx264 @ 0x56419e134b00] consecutive B-frames: 8,6% 1,3% 23,8% 66,2%
>> [libx264 @ 0x56419e134b00] mb I I16..4: 77,9% 12,5% 9,7%
>> [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%
>> [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%
>> [libx264 @ 0x56419e134b00] final ratefactor: 6,01
>> [libx264 @ 0x56419e134b00] 8x8 transform intra:7,9% inter:39,2%
>> [libx264 @ 0x56419e134b00] coded y,uvDC,uvAC intra: 7,0% 15,9% 10,0%
>> inter: 0,2% 74,0% 7,7%
>> [libx264 @ 0x56419e134b00] i16 v,h,dc,p: 0% 0% 0% 100%
>> [libx264 @ 0x56419e134b00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 17% 6% 57%
>> 0% 0% 0% 0% 0%
>> [libx264 @ 0x56419e134b00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 4% 5% 74%
>> 4% 0% 0% 2% 1%
>> [libx264 @ 0x56419e134b00] i8c dc,h,v,p: 0% 5% 7% 89%
>> [libx264 @ 0x56419e134b00] Weighted P-Frames: Y:0,0% UV:0,0%
>> [libx264 @ 0x56419e134b00] ref P L0: 98,4% 0,2% 0,6% 0,8%
>> [libx264 @ 0x56419e134b00] ref B L0: 90,0% 8,9% 1,1%
>> [libx264 @ 0x56419e134b00] ref B L1: 95,9% 4,1%
>> [libx264 @ 0x56419e134b00] kb/s:243,60
>> [aac @ 0x56419e11d6a0] Qavg: 321,284
>>
>>
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/libav-user
>>
>> To unsubscribe, visit link above, or email
>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210429/74f8b6cd/attachment.htm>
More information about the Libav-user
mailing list