Originally committed as revision 3218 to svn://svn.ffmpeg.org/ffmpeg/trunk
Michael Niedermayer authored on 2004/06/12 12:41:36... | ... |
@@ -202,6 +202,7 @@ static char *pass_logfilename = NULL; |
202 | 202 |
static int audio_stream_copy = 0; |
203 | 203 |
static int video_stream_copy = 0; |
204 | 204 |
static int sync_method= 1; |
205 |
+static int copy_ts= 0; |
|
205 | 206 |
|
206 | 207 |
static int rate_emu = 0; |
207 | 208 |
|
... | ... |
@@ -616,13 +617,16 @@ static void do_video_out(AVFormatContext *s, |
616 | 616 |
nb_frames = 0; |
617 | 617 |
else if (vdelta > 1.1) |
618 | 618 |
nb_frames = 2; |
619 |
-//printf("vdelta:%f, ost->sync_opts:%lld, ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, ost->sync_ipts, nb_frames); |
|
619 |
+//fprintf(stderr, "vdelta:%f, ost->sync_opts:%lld, ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, ost->sync_ipts, nb_frames); |
|
620 | 620 |
} |
621 |
- if (nb_frames == 0) |
|
621 |
+ if (nb_frames == 0){ |
|
622 | 622 |
++nb_frames_drop; |
623 |
- else if (nb_frames == 2) { |
|
623 |
+ if (verbose>2) |
|
624 |
+ fprintf(stderr, "*** drop!\n"); |
|
625 |
+ }else if (nb_frames == 2) { |
|
624 | 626 |
++nb_frames_dup; |
625 |
- //printf("*** dup!\n"); |
|
627 |
+ if (verbose>2) |
|
628 |
+ fprintf(stderr, "*** dup!\n"); |
|
626 | 629 |
} |
627 | 630 |
ost->sync_opts+= nb_frames; |
628 | 631 |
|
... | ... |
@@ -1693,6 +1697,20 @@ static int av_encode(AVFormatContext **output_files, |
1693 | 1693 |
if (ist->discard) |
1694 | 1694 |
goto discard_packet; |
1695 | 1695 |
|
1696 |
+// fprintf(stderr, "next:%lld dts:%lld off:%lld %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec.codec_type); |
|
1697 |
+ if (pkt.dts != AV_NOPTS_VALUE) { |
|
1698 |
+ int64_t delta= pkt.dts - ist->next_pts; |
|
1699 |
+ if(ABS(delta) > 10LL*AV_TIME_BASE && !copy_ts){ |
|
1700 |
+ input_files_ts_offset[ist->file_index]-= delta; |
|
1701 |
+ if (verbose > 2) |
|
1702 |
+ fprintf(stderr, "timestamp discontinuity %lld, new offset= %lld\n", delta, input_files_ts_offset[ist->file_index]); |
|
1703 |
+ for(i=0; i<file_table[file_index].nb_streams; i++){ |
|
1704 |
+ int index= file_table[file_index].ist_index + i; |
|
1705 |
+ ist_table[index]->next_pts += delta; |
|
1706 |
+ } |
|
1707 |
+ } |
|
1708 |
+ } |
|
1709 |
+ |
|
1696 | 1710 |
//fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size); |
1697 | 1711 |
if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) { |
1698 | 1712 |
|
... | ... |
@@ -2652,8 +2670,6 @@ static void opt_input_file(const char *filename) |
2652 | 2652 |
|
2653 | 2653 |
input_files[nb_input_files] = ic; |
2654 | 2654 |
input_files_ts_offset[nb_input_files] = input_ts_offset; |
2655 |
- if (ic->start_time != AV_NOPTS_VALUE && 0) |
|
2656 |
- input_files_ts_offset[nb_input_files] -= ic->start_time; |
|
2657 | 2655 |
/* dump the file content */ |
2658 | 2656 |
if (verbose >= 0) |
2659 | 2657 |
dump_format(ic, nb_input_files, filename, 0); |
... | ... |
@@ -3544,6 +3560,7 @@ const OptionDef options[] = { |
3544 | 3544 |
{ "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\" or \"dvd\")", "type" }, |
3545 | 3545 |
{ "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" }, |
3546 | 3546 |
{ "sync", HAS_ARG | OPT_EXPERT, {(void*)opt_sync_method}, "sync method", "" }, |
3547 |
+ { "copyts", OPT_BOOL | OPT_EXPERT, {(void*)©_ts}, "copy timestamps" }, |
|
3547 | 3548 |
|
3548 | 3549 |
/* video options */ |
3549 | 3550 |
{ "b", HAS_ARG | OPT_VIDEO, {(void*)opt_video_bitrate}, "set video bitrate (in kbit/s)", "bitrate" }, |