Browse code

start time hack by (devik <devik at cdi dot cz>)

Originally committed as revision 2408 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2003/10/21 19:55:24
Showing 1 changed files
... ...
@@ -133,6 +133,7 @@ static int audio_channels = 1;
133 133
 static int audio_codec_id = CODEC_ID_NONE;
134 134
 
135 135
 static int64_t recording_time = 0;
136
+static int64_t start_time = 0;
136 137
 static int file_overwrite = 0;
137 138
 static char *str_title = NULL;
138 139
 static char *str_author = NULL;
... ...
@@ -1255,11 +1256,12 @@ static int av_encode(AVFormatContext **output_files,
1255 1255
         if (ist->discard)
1256 1256
             goto discard_packet;
1257 1257
 
1258
-        // printf("read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size);
1258
+        //fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size);
1259 1259
 
1260 1260
         len = pkt.size;
1261 1261
         ptr = pkt.data;
1262 1262
         while (len > 0) {
1263
+	    int ipts;
1263 1264
 	    /* decode the packet if needed */
1264 1265
             data_buf = NULL; /* fail safe */
1265 1266
             data_size = 0;
... ...
@@ -1368,8 +1370,12 @@ static int av_encode(AVFormatContext **output_files,
1368 1368
                 }
1369 1369
             }
1370 1370
 #endif
1371
-            /* transcode raw format, encode packets and output them */
1371
+	    ipts = (double)ist->pts * is->pts_num / is->pts_den;
1372
+        //fprintf(stderr,"decoded ipts=%ld %d\n",ipts,ist->pts);
1372 1373
 
1374
+	    /* if output time reached then transcode raw format, 
1375
+	       encode packets and output them */
1376
+	    if (start_time == 0 || ipts > (start_time / 1000000.0))
1373 1377
             for(i=0;i<nb_ostreams;i++) {
1374 1378
                 int frame_size;
1375 1379
 
... ...
@@ -2028,6 +2034,11 @@ static void opt_recording_time(const char *arg)
2028 2028
     recording_time = parse_date(arg, 1);
2029 2029
 }
2030 2030
 
2031
+static void opt_start_time(const char *arg)
2032
+{
2033
+    start_time = parse_date(arg, 1);
2034
+}
2035
+
2031 2036
 static void opt_input_file(const char *filename)
2032 2037
 {
2033 2038
     AVFormatContext *ic;
... ...
@@ -2663,6 +2674,7 @@ const OptionDef options[] = {
2663 2663
     { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" },
2664 2664
     { "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file:stream" },
2665 2665
     { "t", HAS_ARG, {(void*)opt_recording_time}, "set the recording time", "duration" },
2666
+    { "start", HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" },
2666 2667
     { "title", HAS_ARG | OPT_STRING, {(void*)&str_title}, "set the title", "string" },
2667 2668
     { "author", HAS_ARG | OPT_STRING, {(void*)&str_author}, "set the author", "string" },
2668 2669
     { "copyright", HAS_ARG | OPT_STRING, {(void*)&str_copyright}, "set the copyright", "string" },