Opened 10 years ago

Closed 9 years ago

#273 closed defect (fixed)

h264 video decoding aborts due to too low number of "slices"

Reported by: gerhard_s Owned by:
Priority: normal Component: avcodec
Version: unspecified Keywords: h264 slice MAX_SLICES
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no


I'm using h264 video codec for VoIP between linphone (on my machine, openSUSE 11.4, x86_64, using ffmpeg git dated on 20110604 and libx264-115) and Bria 3.2 (on Windows 7) on the other end.

I had the problem that after a few seconds the call terminated issuing
the message "Too many slices, increase MAX_SLICES and recompile".

I patched h264.h by increasing MAX_SLICES from 16 to 32 and now it works fine again.

I think MAX_SLICES is currently too low, should be increased to at least 32.
I don't know if Bria would send even more slices if the bandwidth was even bigger or video resolution was bigger. Is there a limit given by the codec for a reasonable upper threshold?

Change History (7)

comment:1 Changed 10 years ago by gerhard_s

In case "Bria" is too unspecific, it's available on

comment:2 Changed 10 years ago by cehoyos

  • Status changed from new to open

Could you confirm "abort"/"terminated"?
I thought "Too many slices" should only affect output visually, but shouldn't be a fatal error.

comment:3 Changed 10 years ago by gerhard_s

Unfortunately, it is.

It seems to trigger this piece of code in avcodec/h264.c:

if(h->slice_num >= MAX_SLICES){

av_log(s->avctx, AV_LOG_ERROR, "Too many slices, increase MAX_SLICES and recompile\n");


the result of which is a crash (log level = AV_LOG_ERROR).

comment:4 Changed 10 years ago by cehoyos

Could you elaborate?
(av_log is supposed to print a message, not to crash.)

comment:5 Changed 10 years ago by michael

Unless there are vissual artifacts/the decode output differs or a crash/abort is reproduced, i see no reason to increase the parameter.
It could be made less chatty and scary maybe though.

comment:6 Changed 10 years ago by karol

I'm new here, so please cut me some slack. Sorry if I'm reporting it in the wrong place.

I'm using another system, 32-bit Arch Linux, and I got the same message "Too many slices, increase MAX_SLICES and recompile". when trying to watch some videos with mplayer2. This only happens with a couple of videos from the same source e.g.

I got horrible artifacts and A/V desync / slo-mo video. A quick websearch returned this page so I increased the MAX_SLICES from 16 to 32 - as the OP suggested. This allowed me to actually watch the video - it wasn't slow, but the artifacts were still there if I e.g. fast-forwarded 10 seconds I had to wait a couple seconds until the window with the video finished "redrawing" (it looked like you would wipe the artifacts clean from left to right) and my terminal was still flooded with the same messages.

I then increased MAX_SLICES from 32 to 64 and I get no more "Too many slices" messages, but the artifacts still appear if I fast forward / backward the video.

Should I open a separate bug report?

comment:7 Changed 9 years ago by michael

  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from open to closed

locally fixed, will be pushed soon

Note: See TracTickets for help on using tickets.