[FFmpeg-cvslog] fftools/ffmpeg_mux_init: do not overwrite OutputStream.frame_rate for streamcopy

Anton Khirnov git at videolan.org
Mon Jun 5 17:31:01 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun May 28 12:23:29 2023 +0200| [c8a85d1b2fcf4a34ef55570d374bda1719bf2569] | committer: Anton Khirnov

fftools/ffmpeg_mux_init: do not overwrite OutputStream.frame_rate for streamcopy

The values currently written into it are not used after
streamcopy_init(), so it is better to confine them to that function.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8a85d1b2fcf4a34ef55570d374bda1719bf2569
---

 fftools/ffmpeg_mux_init.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 33c93e40f2..b5295ad445 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -861,6 +861,9 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost)
 
     AVCodecContext      *codec_ctx  = NULL;
     AVDictionary        *codec_opts = NULL;
+
+    AVRational           fr         = ost->frame_rate;
+
     int ret = 0;
 
     codec_ctx = avcodec_alloc_context3(NULL);
@@ -893,11 +896,11 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost)
 
     par->codec_tag = codec_tag;
 
-    if (!ost->frame_rate.num)
-        ost->frame_rate = ist->framerate;
+    if (!fr.num)
+        fr = ist->framerate;
 
-    if (ost->frame_rate.num)
-        ost->st->avg_frame_rate = ost->frame_rate;
+    if (fr.num)
+        ost->st->avg_frame_rate = fr;
     else
         ost->st->avg_frame_rate = ist->st->avg_frame_rate;
 
@@ -908,8 +911,8 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost)
 
     // copy timebase while removing common factors
     if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) {
-        if (ost->frame_rate.num)
-            ost->st->time_base = av_inv_q(ost->frame_rate);
+        if (fr.num)
+            ost->st->time_base = av_inv_q(fr);
         else
             ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1});
     }



More information about the ffmpeg-cvslog mailing list