[vlc-devel] [PATCH 3/3] transcode: video: fix insertion of fps filter

Alexandre Janniaux ajanni at videolabs.io
Tue Jan 26 14:01:47 UTC 2021


The fps filter must be added iif. the target framerate is different from
the source framerate, not when we define the fps parameter.

We also check that fps.den > 0 to avoid divide-by-zero errors.

Probably regression from 030183d79045a1747d891572b2fe77d8cd0fd946 in
which the target framerate was defined in the destination format.
.
---
 modules/stream_out/transcode/video.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index b36ed90bbf..ce657088ad 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -297,11 +297,19 @@ static int transcode_video_filters_init( sout_stream_t *p_stream,
         src_ctx = filter_chain_GetVideoCtxOut( id->p_f_chain );
     }
 
-    if( id->p_enccfg->video.fps.num > 0 )
+    if( id->p_enccfg->video.fps.num > 0 &&
+        id->p_enccfg->video.fps.den > 0 &&
+      ( id->p_enccfg->video.fps.num != p_src->video.i_frame_rate ||
+        id->p_enccfg->video.fps.den != p_src->video.i_frame_rate_base ) )
     {
-        filter_chain_AppendFilter( id->p_f_chain, "fps", NULL, p_src );
+        es_format_t dst;
+        es_format_Copy(&dst, p_src);
+        dst.video.i_frame_rate = id->p_enccfg->video.fps.num;
+        dst.video.i_frame_rate_base = id->p_enccfg->video.fps.den;
+        filter_chain_AppendFilter( id->p_f_chain, "fps", NULL, &dst );
         p_src = filter_chain_GetFmtOut( id->p_f_chain );
         src_ctx = filter_chain_GetVideoCtxOut( id->p_f_chain );
+        es_format_Clean(&dst);
     }
 
     /* User filters */
-- 
2.30.0



More information about the vlc-devel mailing list