[FFmpeg-devel] Multiple frame dimensions in a single stream

Ivo ivop
Fri May 4 14:55:28 CEST 2007


On Friday 04 May 2007 14:13, Michael Niedermayer wrote:
> On Fri, May 04, 2007 at 01:00:02PM +0200, Ivo wrote:
> > On Friday 04 May 2007 03:10, Michael Niedermayer wrote:
> > > On Fri, May 04, 2007 at 01:10:12AM +0200, Ivo wrote:
> > > > I am working on a TXD demuxer and decoder
> > > > (http://wiki.multimedia.cx/index.php?title=TXD) and I have stumbled
> > > > upon a problem. Basically the demuxer and decoder work fine when
> > > > all frames have the same width and height. But if the size changes,
> > > > the output stays at the old size. e.g. [fronten2.txd is from GTA:SA
> > > > and contains eight frames]
> > > >
> > > > ffmpeg -i fronten2.txd %02d.ppm
> > > >
> > > > All ppm images are 512x512, but 07.ppm should be 512x256. The upper
> > > > half of the 512x512 image does contain the right contents though.
> > > > When I do
> > > >
> > > > ffplay fronten2.txd
> > > >
> > > > I see the output window resize but it does not display the right
> > > > contents. It then switches back to 512x512 for the eight frame,
> > > > which displays correctly again.
> > > >
> > > > I have RTFS but I can not figure out what I am doing wrong. Can
> > > > anybody explain to me how I should handle mid-stream dimension
> > > > changes? Preferably decoder driven, though I could change that if
> > > > it should be really done in the demuxer.
> > >
> > > iam not sure if ffplay supports changing dimension, try to
> > > concatenate 2 mpeg streams with differing dimension to check if
> > > ffplay can handle that
> >
> > I did the following:
> >
> > cat small.mpg big.mpg > up.mpg
> > cat big.mpg small.mpg > down.mpg
> >
> > big.mpg's dimensions are twice those of small.mpg.
> >
> > $ ffplay up.mpg
> >
> > Window resizes but the contents are not correct. Only the left half of
> > the image is shown and the right half is green.
> >
> > $ ffplay down.mpg
> >
> > Seems to play correctly. Window resizes and the contents match what I
> > expected.
> >
> > $ ffmpeg -i up.mpg %04d.ppm
> >
> > The images after the switch stay at the old dimensions and show only
> > the upper left corner of the frame (one quarter of the image).
> >
> > $ ffmpeg -i down.mpg %04d.ppm
> >
> > The images after the switch stay at the old dimensions and show the
> > frame twice (upper left corner, and upper right corner one scanline
> > shifted up) and the lower half of the image contains garbage.
> >
> > So it looks like it's ffmpeg and ffplay that have to be adjusted to
> > work with changing dimensions mid-stream? Any idea how I should
> > proceed? For example, if the width and height of a frame change, do
> > st->codec->width/height also have to be changed? (by the demuxer) or is
> > that considered a hackish no-go?
>
> hmm ideally the codec should do the change but if the w/h is not
> available in some header which the codec sees then the demxuxer could do
> it too

Ok. That's what my current code does. The decoder gets one frame which 
contains a full txd_texture_data structure, including its width and height. 
I probably should post my code shortly and the ffmpeg/ffplay not handling 
dimension changes properly should be fixed separately.

--Ivo






More information about the ffmpeg-devel mailing list