]> git.sesse.net Git - ffmpeg/blobdiff - ffmpeg.c
Init sub_mb_type cleanly.
[ffmpeg] / ffmpeg.c
index 2253fc5777194505397ad07b2076ab276e48cfa5..cb53bfc71559df11ce6687c7769a6507bd871a95 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -301,6 +301,7 @@ typedef struct AVInputStream {
     int64_t       pts;       /* current pts */
     int is_start;            /* is 1 at the start and after a discontinuity */
     int showed_multi_packet_warning;
+    int is_past_recording_time;
 } AVInputStream;
 
 typedef struct AVInputFile {
@@ -1314,7 +1315,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
         ist->pts= ist->next_pts;
 
         if(avpkt.size && avpkt.size != pkt->size &&
-           (!ist->showed_multi_packet_warning && verbose>0 || verbose>1)){
+           ((!ist->showed_multi_packet_warning && verbose>0) || verbose>1)){
             fprintf(stderr, "Multiple frames in a packet from stream %d\n", pkt->stream_index);
             ist->showed_multi_packet_warning=1;
         }
@@ -2107,19 +2108,6 @@ static int av_encode(AVFormatContext **output_files,
         ist->is_start = 1;
     }
 
-    /* set the duration of the output to the duration of the input
-     * if the output ends up being different, it'll be corrected later */
-    for (i=0;i<nb_output_files;i++) {
-        AVFormatContext *out_file = output_files[i];
-        AVFormatContext *in_file = input_files[i];
-
-        if (recording_time != INT64_MAX) {
-            out_file->duration = recording_time / 1000000 * AV_TIME_BASE;
-        } else {
-            out_file->duration = in_file->duration;
-        }
-    }
-
     /* set meta data information from input file if required */
     for (i=0;i<nb_meta_data_maps;i++) {
         AVFormatContext *out_file;
@@ -2234,7 +2222,7 @@ static int av_encode(AVFormatContext **output_files,
             ost = ost_table[i];
             os = output_files[ost->file_index];
             ist = ist_table[ost->source_index];
-            if(no_packet[ist->file_index])
+            if(ist->is_past_recording_time || no_packet[ist->file_index])
                 continue;
                 opts = ost->st->pts.val * av_q2d(ost->st->time_base);
             ipts = (double)ist->pts;
@@ -2264,10 +2252,6 @@ static int av_encode(AVFormatContext **output_files,
             break;
         }
 
-        /* finish if recording time exhausted */
-        if (opts_min >= (recording_time / 1000000.0))
-            break;
-
         /* finish if limit size exhausted */
         if (limit_filesize != 0 && limit_filesize < url_ftell(output_files[0]->pb))
             break;
@@ -2331,8 +2315,10 @@ static int av_encode(AVFormatContext **output_files,
         }
 
         /* finish if recording time exhausted */
-        if (pkt.pts * av_q2d(ist->st->time_base) >= (recording_time / 1000000.0))
+        if (av_compare_ts(pkt.pts, ist->st->time_base, recording_time, (AVRational){1, 1000000}) >= 0) {
+            ist->is_past_recording_time = 1;
             goto discard_packet;
+        }
 
         //fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size);
         if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) {
@@ -2605,7 +2591,7 @@ static void opt_frame_pix_fmt(const char *arg)
             av_exit(1);
         }
     } else {
-        list_fmts(avcodec_pix_fmt_string, PIX_FMT_NB);
+        show_pix_fmts();
         av_exit(0);
     }
 }