[FFmpeg-user] Add white padding with filter_complex

Fernando Irías Escher fernandoiriase at gmail.com
Wed Apr 10 03:04:55 CEST 2013


I'm actually going to receive four videos with size 320x180 after they were
scaled in a previous step. The goal is to make a grid with four videos, and
it will have a size of  640x360. The ffmpeg command I'm using is based on
this one:

*ffmpeg -f lavfi -i testsrc -f lavfi -i testsrc -f lavfi -i testsrc -f
lavfi -i testsrc -filter_complex
"[0:0]pad=iw*2:ih*2[a];[1:0]negate[b];[2:0]hflip[c];[3:0]edgedetect[d];[a][b]overlay=w[x];[x][c]overlay=0:h[y];[y][d]overlay=w:h"
-y -c:v ffv1 -t 5 multiple_input_grid.avi*

*
*
So the reason I'm using a complex filter is to allow filtering with
multiple inputs and one output. The -s flag is kind of redundant once all
the calculations were made from the size of the first input in the complex
filter, but I have set it just to be explicit about it.

Thanks for your insights!


On Tue, Apr 9, 2013 at 6:06 PM, Lou <lou at lrcd.com> wrote:

> On Tue, 9 Apr 2013 17:09:10 -0600
> Fernando Irías Escher <fernandoiriase at gmail.com> wrote:
>
> > I'm using this command to generate a white padding for a grid:
> > *
> > *
> >
> > *ffmpeg -i 1.mp4   -filter_complex "[0:0]pad=iw*2:ih*2::0:0:0xFFFFFF"
> -c:v
> > libx264 -preset:v veryfast -threads 0 -s 640:360        -map 0:a -c:a
> > libfaac -b:a 96k grid.mp4*
>
> I don't quite understand what you're trying to do with -s 640:360. I
> think your pad will result in 1280x960. If you want that to be half that
> size it will be 640x480: the same size as your input. Forcing 640x360
> will vertically squish your video. Also, you can avoid using -s outside
> of your filterchain so you have more control over when the scale is
> applied:
>
> -vf "pad=iw*2:ih*2:0:0:0xFFFFFF,scale=iw/2:-1"
>
> If you still want 640x360 you can crop instead of forcing the size with
> scale. This example will crop from the bottom (default will "center"
> the crop):
>
> -vf "pad=iw*2:ih*2:0:0:0xFFFFFF,scale=iw/2:-1,crop=iw:360:0:0"
>
> Since you only have one input and one output, resulting in a simple
> filtergraph [1], you can use -vf instead of -filter_complex. I'm not
> sure if using -filter_complex for a simple filtergraph will cause any
> issues (I don't think it would, but feel free to correct me).
>
> [1] http://ffmpeg.org/ffmpeg.html#Simple-filtergraphs
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list