[FFmpeg-devel] [PATCH 6/7] fftools/ffmpeg_enc: set audio frame duration when encoding

Anton Khirnov anton at khirnov.net
Fri Apr 14 19:42:43 EEST 2023


---
 fftools/ffmpeg_enc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index a0779c45ae..00cccef65b 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -795,6 +795,8 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
             av_rescale_q(start_time, AV_TIME_BASE_Q,   enc->time_base);
     }
     frame->time_base = enc->time_base;
+    frame->duration  = av_rescale_q(frame->nb_samples, (AVRational){1, frame->sample_rate},
+                                    enc->time_base);
 
     if (!check_recording_time(ost, frame->pts, frame->time_base))
         return;
-- 
2.39.1



More information about the ffmpeg-devel mailing list