]> git.sesse.net Git - ffmpeg/blobdiff - ffmpeg.c
ffprobe: add default_writer priv_size.
[ffmpeg] / ffmpeg.c
index b1697010775249c7971b0cd56aa142cc1e8dd53b..801ce2fdb3724a602fecc8ce729fa3b04585d6f1 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -319,6 +319,7 @@ typedef struct OutputStream {
     int copy_initial_nonkeyframes;
 
     enum PixelFormat pix_fmts[2];
+    int keep_pix_fmt;
 } OutputStream;
 
 
@@ -706,6 +707,15 @@ static enum PixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum Pixe
 
 static char *choose_pixel_fmts(OutputStream *ost)
 {
+    if (ost->keep_pix_fmt) {
+        if (ost->filter)
+            avfilter_graph_set_auto_convert(ost->filter->graph->graph,
+                                            AVFILTER_AUTO_CONVERT_NONE);
+        if (ost->st->codec->pix_fmt == PIX_FMT_NONE)
+            return NULL;
+        ost->pix_fmts[0] = ost->st->codec->pix_fmt;
+        return ost->pix_fmts;
+    }
     if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
         return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));
     } else if (ost->enc->pix_fmts) {
@@ -835,6 +845,10 @@ static int configure_video_filters(FilterGraph *fg)
             return ret;
     }
 
+    if (ost->keep_pix_fmt)
+        avfilter_graph_set_auto_convert(fg->graph,
+                                        AVFILTER_AUTO_CONVERT_NONE);
+
     if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
         return ret;
 
@@ -1980,11 +1994,11 @@ static void do_video_out(AVFormatContext *s, OutputStream *ost,
         if (delta <= -0.6)
             nb_frames = 0;
         else if (delta > 0.6)
-            ost->sync_opts = lrintf(sync_ipts);
+            ost->sync_opts = lrint(sync_ipts);
         break;
     case VSYNC_DROP:
     case VSYNC_PASSTHROUGH:
-        ost->sync_opts = lrintf(sync_ipts);
+        ost->sync_opts = lrint(sync_ipts);
         break;
     default:
         av_assert0(0);
@@ -2100,6 +2114,7 @@ static int poll_filters(void)
     AVFrame *filtered_frame = NULL;
     int i, ret, ret_all;
     unsigned nb_success, nb_eof;
+    int64_t frame_pts;
 
     while (1) {
         /* Reap all buffers present in the buffer sinks */
@@ -2129,7 +2144,7 @@ static int poll_filters(void)
                     }
                     break;
                 }
-                filtered_frame->pts = av_rescale_q(picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
+                filtered_frame->pts = frame_pts = av_rescale_q(picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
                 //if (ost->source_index >= 0)
                 //    *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold
 
@@ -2139,6 +2154,7 @@ static int poll_filters(void)
                 switch (ost->filter->filter->inputs[0]->type) {
                 case AVMEDIA_TYPE_VIDEO:
                     avfilter_fill_frame_from_video_buffer_ref(filtered_frame, picref);
+                    filtered_frame->pts = frame_pts;
                     if (!ost->frame_aspect_ratio)
                         ost->st->codec->sample_aspect_ratio = picref->video->sample_aspect_ratio;
 
@@ -2896,7 +2912,7 @@ static int init_input_stream(int ist_index, char *error, int error_len)
             return AVERROR(EINVAL);
         }
 
-        ist->dr1 = codec->capabilities & CODEC_CAP_DR1;
+        ist->dr1 = (codec->capabilities & CODEC_CAP_DR1) && !do_deinterlace;
         if (codec->type == AVMEDIA_TYPE_VIDEO && ist->dr1) {
             ist->st->codec->get_buffer     = codec_get_buffer;
             ist->st->codec->release_buffer = codec_release_buffer;
@@ -3033,6 +3049,7 @@ static int transcode_init(void)
             }
             memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);
             codec->extradata_size= icodec->extradata_size;
+            codec->bits_per_coded_sample  = icodec->bits_per_coded_sample;
 
             codec->time_base = ist->st->time_base;
             /*
@@ -3075,6 +3092,10 @@ static int transcode_init(void)
                 codec->frame_size         = icodec->frame_size;
                 codec->audio_service_type = icodec->audio_service_type;
                 codec->block_align        = icodec->block_align;
+                if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)
+                    codec->block_align= 0;
+                if(codec->codec_id == CODEC_ID_AC3)
+                    codec->block_align= 0;
                 break;
             case AVMEDIA_TYPE_VIDEO:
                 codec->pix_fmt            = icodec->pix_fmt;
@@ -4656,6 +4677,11 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
 
         video_enc->bits_per_raw_sample = frame_bits_per_raw_sample;
         MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);
+        if (frame_pix_fmt && *frame_pix_fmt == '+') {
+            ost->keep_pix_fmt = 1;
+            if (!*++frame_pix_fmt)
+                frame_pix_fmt = NULL;
+        }
         if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == PIX_FMT_NONE) {
             av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);
             exit_program(1);