From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move derivation of frame duration from filter framerate Date: Sun, 1 Oct 2023 14:55:52 +0200 Message-ID: <20231001125552.23976-9-anton@khirnov.net> (raw) In-Reply-To: <20231001125552.23976-1-anton@khirnov.net> From ffmpeg_enc to ffmpeg_filter, which is a more appropriate place for it. --- fftools/ffmpeg_enc.c | 9 +-------- fftools/ffmpeg_filter.c | 6 +++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 6c00156121..ec9cebbd96 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -1109,16 +1109,9 @@ static int do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) int64_t nb_frames, nb_frames_prev, i; double duration = 0; - if (frame) { - FrameData *fd = frame_data(frame); - + if (frame) duration = frame->duration * av_q2d(frame->time_base) / av_q2d(enc->time_base); - if (duration <= 0 && - fd->frame_rate_filter.num > 0 && fd->frame_rate_filter.den > 0) - duration = 1 / (av_q2d(fd->frame_rate_filter) * av_q2d(enc->time_base)); - } - video_sync_process(of, ost, frame, duration, &nb_frames, &nb_frames_prev); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 9bf870b615..b6348d7f87 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1817,8 +1817,12 @@ static int fg_output_step(OutputFilterPriv *ofp, int flush) if (ost->type == AVMEDIA_TYPE_VIDEO) { AVRational fr = av_buffersink_get_frame_rate(filter); - if (fr.num > 0 && fr.den > 0) + if (fr.num > 0 && fr.den > 0) { fd->frame_rate_filter = fr; + + if (!frame->duration) + frame->duration = av_rescale_q(1, av_inv_q(fr), frame->time_base); + } } ret = enc_frame(ost, frame); -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2023-10-01 12:56 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-10-01 12:55 [FFmpeg-devel] [PATCH 1/9] lavfi/yadif: update output frame durations Anton Khirnov 2023-10-01 12:55 ` [FFmpeg-devel] [PATCH 2/9] lavf/demux: restrict video parser duration handling to just GIF Anton Khirnov 2023-10-01 12:55 ` [FFmpeg-devel] [PATCH 3/9] lavf/gifdec: do not mark as notimestamps Anton Khirnov 2023-10-01 12:55 ` [FFmpeg-devel] [PATCH 4/9] lavc/mpegvideo_parser: reduce variable scopes Anton Khirnov 2023-10-01 20:28 ` Michael Niedermayer 2023-10-01 12:55 ` [FFmpeg-devel] [PATCH 5/9] lavc/mpegvideo_parser: improve exporting field-coding information Anton Khirnov 2023-10-01 12:55 ` [FFmpeg-devel] [PATCH 6/9] lavc/mpeg4videodec: do not invent a framerate from guessed numbers Anton Khirnov 2023-10-01 13:14 ` Andreas Rheinhardt 2023-10-02 8:56 ` Anton Khirnov 2023-10-01 12:55 ` [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg_dec: disregard demuxer timestamps for NOTIMESTAMPS formats Anton Khirnov 2023-10-01 13:18 ` Andreas Rheinhardt 2023-10-02 8:59 ` Anton Khirnov 2023-10-01 12:55 ` [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg_enc: do not round frame durations prematurely Anton Khirnov 2023-10-01 12:55 ` Anton Khirnov [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231001125552.23976-9-anton@khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git