Discussion:
flv: Fix one frame video total duration
(too old to reply)
Anton Mitrofanov
2017-12-25 19:39:50 UTC
Permalink
x264 | branch: master | Anton Mitrofanov <***@narod.ru> | Thu Aug 17 23:51:14 2017 +0300| [5d4031618e9feedcb527fd4e5a91bc06e30b70b4] | committer: Anton Mitrofanov

flv: Fix one frame video total duration
http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=5d4031618e9feedcb527fd4e5a91bc06e30b70b4
---

output/flv.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/output/flv.c b/output/flv.c
index 0057de4b..74e7f8a9 100644
--- a/output/flv.c
+++ b/output/flv.c
@@ -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 )
{

Loading...