[FFmpeg-cvslog] avconv: make -aspect work with streamcopy
Anton Khirnov
git at videolan.org
Tue May 28 08:57:56 CEST 2013
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun May 26 15:31:09 2013 +0200| [538bf767373f176b6487e30181155e74b37cced6] | committer: Anton Khirnov
avconv: make -aspect work with streamcopy
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=538bf767373f176b6487e30181155e74b37cced6
---
avconv.c | 15 ++++++++-------
avconv_opt.c | 11 ++++++-----
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/avconv.c b/avconv.c
index 7f8c6a6..cce9a83 100644
--- a/avconv.c
+++ b/avconv.c
@@ -1490,6 +1490,7 @@ static int transcode_init(void)
}
if (ost->stream_copy) {
+ AVRational sar;
uint64_t extra_size;
av_assert0(ist && !ost->filter);
@@ -1547,13 +1548,13 @@ static int transcode_init(void)
codec->width = icodec->width;
codec->height = icodec->height;
codec->has_b_frames = icodec->has_b_frames;
- if (!codec->sample_aspect_ratio.num) {
- codec->sample_aspect_ratio =
- ost->st->sample_aspect_ratio =
- ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :
- ist->st->codec->sample_aspect_ratio.num ?
- ist->st->codec->sample_aspect_ratio : (AVRational){0, 1};
- }
+ if (ost->frame_aspect_ratio)
+ sar = av_d2q(ost->frame_aspect_ratio * codec->height / codec->width, 255);
+ else if (ist->st->sample_aspect_ratio.num)
+ sar = ist->st->sample_aspect_ratio;
+ else
+ sar = icodec->sample_aspect_ratio;
+ ost->st->sample_aspect_ratio = codec->sample_aspect_ratio = sar;
break;
case AVMEDIA_TYPE_SUBTITLE:
codec->width = icodec->width;
diff --git a/avconv_opt.c b/avconv_opt.c
index ae9b72e..3245709 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -983,15 +983,20 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
AVStream *st;
OutputStream *ost;
AVCodecContext *video_enc;
+ char *frame_aspect_ratio = NULL;
ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO);
st = ost->st;
video_enc = st->codec;
+ MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st);
+ if (frame_aspect_ratio)
+ ost->frame_aspect_ratio = parse_frame_aspect_ratio(frame_aspect_ratio);
+
if (!ost->stream_copy) {
const char *p = NULL;
char *frame_rate = NULL, *frame_size = NULL;
- char *frame_aspect_ratio = NULL, *frame_pix_fmt = NULL;
+ char *frame_pix_fmt = NULL;
char *intra_matrix = NULL, *inter_matrix = NULL;
int do_pass = 0;
int i;
@@ -1008,10 +1013,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
exit(1);
}
- MATCH_PER_STREAM_OPT(frame_aspect_ratios, str, frame_aspect_ratio, oc, st);
- if (frame_aspect_ratio)
- ost->frame_aspect_ratio = parse_frame_aspect_ratio(frame_aspect_ratio);
-
MATCH_PER_STREAM_OPT(frame_pix_fmts, str, frame_pix_fmt, oc, st);
if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == AV_PIX_FMT_NONE) {
av_log(NULL, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt);
More information about the ffmpeg-cvslog
mailing list