[FFmpeg-user] multiple input video streams

Wes Morgan morganw at chemikals.org
Thu Mar 31 06:24:31 CEST 2011


On Wed, 30 Mar 2011, Wes Morgan wrote:

> On Tue, 29 Mar 2011, Rodney Baker wrote:
>
> > On Tue, 29 Mar 2011 09:36:53 Wes Morgan wrote:
> > > On Tue, 29 Mar 2011, Rodney Baker wrote:
> > > > On Mon, 28 Mar 2011 21:30:06 Wes Morgan wrote:
> > > > > I'm trying to transcode an m2ts file that contains three video streams,
> > > > > and I don't seem to be able to tell ffmpeg to use the first stream:
> > > > >
> > > > > /usr/local/bin/ffmpeg -i Frost-Nixon.m2ts -y -sn -sws_flags spline+sse2
> > > > > -vtag X264 -threads 6 -map 0.0 -refs 5 -an -vcodec libx264 -passlogfile
> > > > > Frost-Nixon.log -b 8771k -f matroska -vstats -vstats_file
> > > > > Frost-Nixon-1.vstats -bf 3 -b_strategy 1 -coder 1 -cmp +chroma
> > > > > -directpred 1 -flags +loop -g 250 -keyint_min 25 -level 41 -me_method
> > > > > dia -me_range 16 -sc_threshold 40 -deblockalpha -1 -deblockbeta -1
> > > > > -partitions
> > > > > -parti8x8-parti4x4-partp8x8-partp4x4-partb8x8 -i_qfactor 0.71 -qcomp
> > > > > 0.6 -subq 2 -qdiff 4 -qmax 51 -qmin 10 -trellis 0 -wpredp 2 -aq_mode 1
> > > > > -rc_lookahead 40 -maxrate 40000k -bufsize 30000k -flags2
> > > > > +wpred-mixed_refs-dct8x8+bpyramid+psy+ssim+mbtree -pass 1 /dev/null
> > > >
> > > > use -map 0.0 (for the video) and -map 0.x (subst x for whichever audio
> > > > stream you want). You need to map each stream that you want in the
> > > > output if you want fewer than what is in the source.
> > >
> > > That doesn't seem to work properly. I'm already using -map 0.0 for the
> > > video and -an to skip audio processing for remuxing later yet it seems to
> > > ignore that and use the last video stream. Normally it exits because the
> > > crop filter can't apply the parameters for the real stream 0 (which is HD,
> > > others are SD), but if you remove it and encode say 30 seconds of video,
> > > you have an SD resolution file.
> >
> > The order of options is important. Try the -map 0.0 after -vcodec. Put -an
> > last before your output file (after all the video codec parameters).
>
> Tried moving the -map options all over the place, to no avail. Strangely
> enough, if I do -map 0.12 it will use the proper stream, so it might just
> be a problem with the options parser. Will have to look at that later.
>

Looking at the code, the problem appears to come from the improper use of
global variables for storing the stream information for frames (ie,
frame_height, frame_width, frame_aspect_ratio and probably others).
new_video_stream() uses these values for setting up the output steam, and
since they contain whatever the parameters were for the *last* video
stream parsed from the input, your output stream is forced to use those
frame sizes, aspect ratios etc. I'll have to file a bug report.


More information about the ffmpeg-user mailing list