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 )
{