[FFmpeg-devel] [PATCH] ffmpeg: redesign video resampling in case of mid-stream video size/format change

Stefano Sabatini stefano.sabatini-lala at poste.it
Sat Apr 23 12:34:03 CEST 2011


On date Saturday 2011-04-23 01:48:56 +0200, Michael Niedermayer encoded:
> On Fri, Apr 22, 2011 at 10:51:35AM +0200, Stefano Sabatini wrote:
> > On date Thursday 2011-04-21 12:48:15 +0200, Stefano Sabatini encoded:
> > > On date Wednesday 2011-04-20 01:24:28 +0200, Michael Niedermayer encoded:
> > [...]
> > > > breaks stream copy
> > > > ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -vcodec copy tmp.avi
> > > > [IMGUTILS @ 0x7fff8c6a1b70] Picture size 0x0 is invalid
> > > > Cannot allocate temp picture, check pix fmt
> > > 
> > > Fixed by the pre_process_video_frmae() patch already applied.
> > > 
> > > Patch updated.
> > > -- 
> > > FFmpeg = Frenzy and Faithful Mastodontic Philosofic Ecumenical Gem
> > 
> > > From 648239f2e80278e04b3c78b4013abe30b332d2ef Mon Sep 17 00:00:00 2001
> > > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > > Date: Sat, 16 Apr 2011 23:14:44 +0200
> > > Subject: [PATCH] ffmpeg: redesign video resampling in case of mid-stream video size/format change
> > > 
> > > The new design supports video resolution/format change with and
> > > without AVFILTER_CONFIG, thus avoiding the need for the
> > > av_vsrc_buffer_add_frame2() hack.
> > > 
> > > When a change in video resolution/format is detected, a scaling
> > > context is lazily initialized, and used for rescaling the input video
> > > to the initial destination size/format.
> > > 
> > > The rescaling/conversion is moved from do_video_out() to
> > > pre_process_video_frame(), and all the resampling/conversion structs
> > > are moved from AVOutputStream to AVInputStream. Conversion is now
> > > performed *just after decoding*, and before feeding either the encoder
> > > (in case libavfilter is not enabled) or the filterchain source.
> > > 
> > > Tested with files:
> > > all_filese_together.avi
> > > crash_pirateszz_2_s25_r003.fuzz.sample
> > > kgv1.avi
> > > res_change_ffmpeg_aspect.ts
> > > resolutionchange.mpg
> > > size_change.nsv
> > > 
> > > Fix issues:
> > > roundup #2217
> > > trac #59
> > > trac #64
> > > trac #74
> > > 
> > > Signed-off-by: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > > ---
> > >  ffmpeg.c |  185 ++++++++++++++++++++++++++++++--------------------------------
> > >  1 files changed, 90 insertions(+), 95 deletions(-)
> > 
> > Ping.
> 
> compile without avfilter
> 
> then try
> ./ffmpeg -i 23.mpg -an -s 100x100 100.avi -s 200x200 200.avi
> 
> where 23.mpg is some file with a resolution change (here it was 200x200 -> 300x300)

Tested with and without CONFIG_AVFILTER, works fine.

ffmpeg -i midstream-format-change-samples/size_change.nsv -y size_change.out.avi
[...]
Input stream #0.0 frame changed from size:640x480 fmt:yuv420p to size:512x480 fmt:yuv420p
Input stream #0.0 frame changed from size:512x480 fmt:yuv420p to size:640x480 fmt:yuv420p
Input stream #0.0 frame changed from size:640x480 fmt:yuv420p to size:512x480 fmt:yuv420p
Input stream #0.0 frame changed from size:512x480 fmt:yuv420p to size:640x480 fmt:yuv420p
-- 
FFmpeg = Fabulous Fiendish Monstrous Puritan Enigmatic Guru


More information about the ffmpeg-devel mailing list