wg <[EMAIL PROTECTED]> added the comment:

Patch to fix subtitle streams in ffmpeg.c

----------
type:  -> patch

______________________________________________________
FFmpeg issue tracker <[EMAIL PROTECTED]>
<https://roundup.mplayerhq.hu/roundup/ffmpeg/issue356>
______________________________________________________
--- trunk/ffmpeg.c	2008-02-05 11:06:19.000000000 +0100
+++ ffmpeg-wg/ffmpeg.c	2008-02-09 18:11:21.000000000 +0100
@@ -1909,9 +1956,15 @@
         for(i=0;i<nb_ostreams;i++) {
             double ipts, opts;
             ost = ost_table[i];
+            if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
+                file_index= -1;
+                break;
+            }
             os = output_files[ost->file_index];
             ist = ist_table[ost->source_index];
-            if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO)
+            if(ost->st->codec->codec_type == CODEC_TYPE_SUBTITLE)
+                continue;
+            else if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO)
                 opts = ost->sync_opts * av_q2d(ost->st->codec->time_base);
             else
                 opts = ost->st->pts.val * av_q2d(ost->st->time_base);
@@ -1926,10 +1979,6 @@
                     if(!input_sync) file_index = ist->file_index;
                 }
             }
-            if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
-                file_index= -1;
-                break;
-            }
         }
         /* if none, if is finished */
         if (file_index < 0) {
@@ -1971,14 +2020,15 @@
         if (pkt.pts != AV_NOPTS_VALUE)
             pkt.pts += av_rescale_q(input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ist->st->time_base);
 
-//        fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
-        if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE) {
+//        fprintf(stderr, "st:%d next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist_index, ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
+        if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE &&
+            ist->st->codec->codec_type != CODEC_TYPE_SUBTITLE) {
             int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
             int64_t delta= pkt_dts - ist->next_pts;
             if((FFABS(delta) > 1LL*dts_delta_threshold*AV_TIME_BASE || pkt_dts+1<ist->pts)&& !copy_ts){
                 input_files_ts_offset[ist->file_index]-= delta;
                 if (verbose > 2)
-                    fprintf(stderr, "timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", delta, input_files_ts_offset[ist->file_index]);
+                    fprintf(stderr, "st:%d timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", ist_index, delta, input_files_ts_offset[ist->file_index]);
                 pkt.dts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
                 if(pkt.pts != AV_NOPTS_VALUE)
                     pkt.pts-= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);

Reply via email to