[FFmpeg-devel] [PATCH] ffmpeg.c can not process invalid PTS

朱世奇 hiccupzhu at 163.com
Fri Oct 30 03:08:43 CET 2015


diff --git a/ffmpeg.c b/ffmpeg.c
index f91fb7b..22766b3 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3864,6 +3864,9 @@ static int process_input(int file_index)
     if (pkt.dts != AV_NOPTS_VALUE)
         pkt.dts *= ist->ts_scale;
 
+    if(pkt.pts == AV_NOPTS_VALUE)
+        pkt.pts = ist->next_pts;
+
     if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
          ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
         pkt.dts != AV_NOPTS_VALUE && ist->next_dts == AV_NOPTS_VALUE && !copy_ts

====================================================================================
Explanation:
In function "process_input" ffmpeg just handle "pts != AV_NOPTS_VALUE", but not handle "pts == AV_NOPTS_VALUE".Now I fixed it. 
if ( current_pts == AV_NOPTS_VALUE) {
current_pts  = predicted_pts;
}


Reproduce:
1. Download test file http://pan.baidu.com/s/1eQsb9hK;
2. Run command below:
ffmpeg -i ./manga.01.ts -vcodec copy -bsf:v h264_mp4toannexb -hls_list_size 0 -hls_segment_filename "test_%04d.ts" playlist.m3u8
3. If the bug not fixed, the HLS slice just one; Then fix the bug, HLS' slice is normally.






 


More information about the ffmpeg-devel mailing list