aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-01-31 20:48:35 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-01-31 21:32:06 +0100
commit7b3ea5507cd79d7e80cb435fda20e70f90e18663 (patch)
tree212f3f588acbca910e82e124b7e024727be28186 /ffmpeg.c
parent14b171cd71f2b5f1cc66e4df89c2692f68ac098b (diff)
downloadffmpeg-7b3ea5507cd79d7e80cb435fda20e70f90e18663.tar.gz
Add sample_aspect_ratio fields to vsrc_buffer arguments.
This fixes aspect handling in ffmpeg This is based on a patch by baptiste
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index df890185aa..3ffa5c42f0 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -355,13 +355,21 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
AVCodecContext *codec = ost->st->codec;
AVCodecContext *icodec = ist->st->codec;
FFSinkContext ffsink_ctx = { .pix_fmt = codec->pix_fmt };
+ AVRational sample_aspect_ratio;
char args[255];
int ret;
graph = avfilter_graph_alloc();
- snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width,
- ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE);
+ if (ist->st->sample_aspect_ratio.num){
+ sample_aspect_ratio = ist->st->sample_aspect_ratio;
+ }else
+ sample_aspect_ratio = ist->st->codec->sample_aspect_ratio;
+
+ snprintf(args, 255, "%d:%d:%d:%d:%d:%d:%d", ist->st->codec->width,
+ ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE,
+ sample_aspect_ratio.num, sample_aspect_ratio.den);
+
ret = avfilter_graph_create_filter(&ist->input_video_filter, avfilter_get_by_name("buffer"),
"src", args, NULL, graph);
if (ret < 0)
@@ -415,6 +423,8 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
codec->width = ist->output_video_filter->inputs[0]->w;
codec->height = ist->output_video_filter->inputs[0]->h;
+ codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
+ ist->output_video_filter->inputs[0]->sample_aspect_ratio;
return 0;
}
@@ -2845,6 +2855,10 @@ static void opt_frame_aspect_ratio(const char *arg)
ffmpeg_exit(1);
}
frame_aspect_ratio = ar;
+
+ x = vfilters ? strlen(vfilters) : 0;
+ vfilters = av_realloc(vfilters, x+100);
+ snprintf(vfilters+x, x+100, "%csetdar=%f\n", x?',':' ', ar);
}
static int opt_metadata(const char *opt, const char *arg)