[vlc-commits] transcode: video: fix insertion of fps filter

Alexandre Janniaux git at videolan.org
Thu Jan 28 11:10:22 UTC 2021


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Tue Jan 26 14:40:30 2021 +0100| [57cd4abb46c64985188d7c3da62c014daa19111b] | committer: Alexandre Janniaux

transcode: video: fix insertion of fps filter

The fps filter must be added when 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=57cd4abb46c64985188d7c3da62c014daa19111b
---

 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 */



More information about the vlc-commits mailing list