]> granicus.if.org Git - libx264/commitdiff
flv: Fix one frame video total duration
authorAnton Mitrofanov <BugMaster@narod.ru>
Thu, 17 Aug 2017 20:51:14 +0000 (23:51 +0300)
committerAnton Mitrofanov <BugMaster@narod.ru>
Sun, 24 Dec 2017 20:47:25 +0000 (23:47 +0300)
output/flv.c

index 0057de4bdba602e0424fedeb8fd9b02b9b43463b..74e7f8a9208f235a9707c67345431ae79c9a244f 100644 (file)
@@ -322,7 +322,12 @@ static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest
 
     CHECK( flv_flush_data( c ) );
 
-    double total_duration = (2 * largest_pts - second_largest_pts) * p_flv->d_timebase;
+    double total_duration;
+    /* duration algorithm fails with one frame */
+    if( p_flv->i_framenum == 1 )
+        total_duration = p_flv->i_fps_num ? (double)p_flv->i_fps_den / p_flv->i_fps_num : 0;
+    else
+        total_duration = (2 * largest_pts - second_largest_pts) * p_flv->d_timebase;
 
     if( x264_is_regular_file( c->fp ) && total_duration > 0 )
     {