[FFmpeg-user] Valid number of slices for libx264 and FFV1

Peter B. pb at das-werkstatt.com
Tue Apr 26 09:31:00 CEST 2016


On 04/26/2016 08:49 AM, Kal Sze wrote:
> And what is the valid number of slices when encoding as FFV1 level 3?
> The wiki says 4, 6, 9, 12, 16, 24, or 30; but I have not seen ffmpeg
> complain if I try to specify something like 25 slices for a 512x424
> video. Does ffmpeg just coerce the value to a valid one?

As far as I know, slices must be a number that allows the image to be
evenly divided in.
For example 25 slices = 5*5 - so it's fine.

FFmpeg usually throws an error if the slice number doesn't make sense.
It does not coerce that value to a valid one.


Here's the part of ffv1enc.c that decides whether the number of slices
is good or not:

[quote]
s->num_v_slices = (avctx->width > 352 || avctx->height > 288 ||
!avctx->slices) ? 2 : 1;
        for (; s->num_v_slices < 9; s->num_v_slices++) {
            for (s->num_h_slices = s->num_v_slices; s->num_h_slices <
2*s->num_v_slices; s->num_h_slices++) {
                if (avctx->slices == s->num_h_slices * s->num_v_slices
&& avctx->slices <= 64 || !avctx->slices)
                    goto slices_ok;
            }
        }
        av_log(avctx, AV_LOG_ERROR,
               "Unsupported number %d of slices requested, please
specify a "
               "supported number with -slices (ex:4,6,9,12,16, ...)\n",
               avctx->slices);
[/quote]

If I read the code correctly, there's also a condition slices must also
not exceed 64.



Kind regards,
Pb




More information about the ffmpeg-user mailing list