avconv: make -aspect work with streamcopy

pull/23/head
Anton Khirnov 12 years ago
parent 564b7e0c00
commit 538bf76737
  1. 15
      avconv.c
  2. 11
      avconv_opt.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;

@ -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);

Loading…
Cancel
Save