Browse code

* making it possible to specify recording date and time in a stream

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

Roman Shaposhnik authored on 2004/04/06 15:31:12
Showing 4 changed files
... ...
@@ -166,6 +166,7 @@ static int audio_codec_id = CODEC_ID_NONE;
166 166
 
167 167
 static int64_t recording_time = 0;
168 168
 static int64_t start_time = 0;
169
+static int64_t rec_timestamp = 0;
169 170
 static int file_overwrite = 0;
170 171
 static char *str_title = NULL;
171 172
 static char *str_author = NULL;
... ...
@@ -2213,6 +2214,11 @@ static void opt_start_time(const char *arg)
2213 2213
     start_time = parse_date(arg, 1);
2214 2214
 }
2215 2215
 
2216
+static void opt_rec_timestamp(const char *arg)
2217
+{
2218
+    rec_timestamp = parse_date(arg, 0) / 1000000;
2219
+}
2220
+
2216 2221
 static void opt_input_file(const char *filename)
2217 2222
 {
2218 2223
     AVFormatContext *ic;
... ...
@@ -2658,7 +2664,9 @@ static void opt_output_file(const char *filename)
2658 2658
             exit(1);
2659 2659
         }
2660 2660
 
2661
-        if (str_title)
2661
+        oc->timestamp = rec_timestamp;
2662
+	    
2663
+	if (str_title)
2662 2664
             pstrcpy(oc->title, sizeof(oc->title), str_title);
2663 2665
         if (str_author)
2664 2666
             pstrcpy(oc->author, sizeof(oc->author), str_author);
... ...
@@ -3127,6 +3135,7 @@ const OptionDef options[] = {
3127 3127
     { "t", HAS_ARG, {(void*)opt_recording_time}, "set the recording time", "duration" },
3128 3128
     { "ss", HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" },
3129 3129
     { "title", HAS_ARG | OPT_STRING, {(void*)&str_title}, "set the title", "string" },
3130
+    { "timestamp", HAS_ARG, {(void*)&opt_rec_timestamp}, "set the timestamp", "time" },
3130 3131
     { "author", HAS_ARG | OPT_STRING, {(void*)&str_author}, "set the author", "string" },
3131 3132
     { "copyright", HAS_ARG | OPT_STRING, {(void*)&str_copyright}, "set the copyright", "string" },
3132 3133
     { "comment", HAS_ARG | OPT_STRING, {(void*)&str_comment}, "set the comment", "string" },
... ...
@@ -26,6 +26,7 @@
26 26
 #include <sys/poll.h>
27 27
 #include <errno.h>
28 28
 #include <sys/time.h>
29
+#undef time //needed because HAVE_AV_CONFIG_H is defined on top
29 30
 #include <time.h>
30 31
 #include <sys/types.h>
31 32
 #include <sys/socket.h>
... ...
@@ -251,6 +251,7 @@ typedef struct AVFormatContext {
251 251
     AVStream *streams[MAX_STREAMS];
252 252
     char filename[1024]; /* input or output filename */
253 253
     /* stream info */
254
+    int64_t timestamp;
254 255
     char title[512];
255 256
     char author[512];
256 257
     char copyright[512];
... ...
@@ -685,7 +685,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s)
685 685
     /* Ok, everything seems to be in working order */
686 686
     c->frames = 0;
687 687
     c->has_audio = c->has_video = 0;
688
-    c->start_time = 0;
688
+    c->start_time = (time_t)s->timestamp;
689 689
     c->aspect = 0; /* 4:3 is the default */
690 690
     if ((int)(av_q2d(vst->codec.sample_aspect_ratio) * vst->codec.width / vst->codec.height * 10) == 17) /* 16:9 */ 
691 691
         c->aspect = 0x07;