[FFmpeg-user] Apply format with overlay and -ss in front of inputfile is strange?

Nicolas George george at nsup.org
Mon Jul 13 19:18:55 CEST 2015


Le quintidi 25 messidor, an CCXXIII, Carl Eugen Hoyos a écrit :
> I can confirm that there may be an issue 
> but it is not overlay-related:
> $ ffmpeg -i input -vf 
> "split[x][z];[x]format=gray[x1];[x1]nullsink" 
> -strict -2 -vcodec jpeg2000 -ss 1 out1.avi
> 
> $ ffmpeg -ss 1 -i input -vf 
> "split[x][z];[x]format=gray[x1];[x1]nullsink" 
> -strict -2 -vcodec jpeg2000 out2.avi

If the issue is that the output is converted to gray too, then this is the
expected behaviour.

Let me explain. I suspect users easily assume that "format=foo" means
"convert to pixel format foo", but it does not; it really means "make sure
the frames are in pixel format foo here". It usually involves converting at
some point before, but not necessarily right before, and not necessarily a
plain convert.

The idea is that libavfilter tries to minimize the number of conversions.
For example, assume the filter graph is "frobnicate,foobarify,format=foo",
frobnicate supports many output formats including foo, and foobarify
supports many formats provided it is the same at input and output (a lot of
filters are like that). Then libavfilter will not convert at all, it will
just select foo as the pixel format for all the frobnicate-foobarify-format
branch.

If there are no filter capable of outputting in pixel format foo, then
libavfilter will have to convert, and it does so by inserting the scale
filter somewhere. The exact place where it is inserted depends on the
particulars of the filter graph. Usually, it does not matter.

For the rare cases where it does matter, for example to be sure to
deinterlace before converting, you need to insert the scale filter
explicitly at the point you want the format conversion.

In this particular case, my guess is that libavfilter decided to insert the
scale filter before split. Insert explicitly after split and it should work
as expected.

I realize the documentation for the format filter is misleading.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20150713/7c866047/attachment.sig>


More information about the ffmpeg-user mailing list