S
S
sv22042017-04-17 22:34:36
fmpeg
sv2204, 2017-04-17 22:34:36

How to fix ffmpeg errors?

I start ffmpeg with this line:

ffmpeg -i http://входящий поток -c:v libx264 -deinterlace -timecode `date '+%H:%m:%S.00'` -s 500x300 -r 25 -force_key_frames "expr:gte(t,n_forced*2)" -vb 400k -profile:v high -preset:v slow -cpu-used -16 -subq 3 -qblur 1 -c:a libmp3lame  -b:a 22k -ac 2 -ar 22050 -f flv "rtmp://выход flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) authmod=  live=1 playpath="

the problem is, when the incoming stream is in HD quality and it needs 8-11 Mb/s to download it, ffmpeg throws a bunch of errors and the stream slows down and lags, here are some errors from the console:
[h264 @ 0x35fa9e0] mmco: unref short failureime=00:00:20.63 bitrate= 392.3kbits/s speed=0.654x    65x
    Last message repeated 1 times
[h264 @ 0x35fa9e0] number of reference frames (0+5) exceeds max (4; probably corrupt input), discarding one
[mpegts @ 0x35f85a0] PES packet size mismatch10kB time=00:00:23.12 bitrate= 216.1kbits/s speed=0.565x
[mp2 @ 0x36b85c0] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[h264 @ 0x3636d20] reference picture missing during reorder
[h264 @ 0x3636d20] Missing reference picture, default is 66662
[h264 @ 0x37a7640] reference picture missing during reorder
[h264 @ 0x37a7640] Missing reference picture, default is 66663
[mpegts @ 0x35f85a0] PES packet size mismatch
[h264 @ 0x35fa9e0] Reference 2 >= 2
[h264 @ 0x35fa9e0] error while decoding MB 76 23, bytestream 40829
[h264 @ 0x37a7640] mmco: unref short failure
    Last message repeated 1 times
[h264 @ 0x37a7640] number of reference frames (0+5) exceeds max (4; probably corrupt input), discarding one
[h264 @ 0x3636d20] reference picture missing during reorder
[h264 @ 0x3636d20] Missing reference picture, default is 66712
[mp2 @ 0x36b85c0] Header missing0 size=     614kB time=00:00:23.40 bitrate= 214.9kbits/s speed=0.565x

Here are the input stream parameters:
Stream #0:0[0x65]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x66](rus): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 192 kb/s (clean effects)

At the same time, the load on the CPU is 35-40%, that is, the server is not overloaded.
Ubuntu Server 14.04
Internet speed 70-80 Mb/s.
I don’t understand what the problem is, if the incoming stream is not of HD quality and it takes 3-5 Mb / s to download it, then everything works fine, there are no errors, nothing slows down.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
norman_edance, 2018-02-08
@norman_edance

OK. Here's what I know so far:

[h264 @ 0x7e4600] non-existing PPS 0 referenced
[h264 @ 0x7e4600] decode_slice_header error
[h264 @ 0x7e4600] no frame!

This means that ffmpeg has not yet seen the keyframe that contains the SPS and PPS information. SPS and PPS are critical to the decoding of the incoming frame/slice. Keyframes are sent periodically (that is, every 5-10 seconds or more); so if it turns out that you joined the stream before the keyframe appeared; you'll see this warning for every frame until a keyframe appears.
Once a keyframe appears, ffmpeg will have enough information to decode that frame (and any subsequent frames until the next keyframe) and the warnings will disappear.
[h264 @ 0x14da960] reference picture missing during reorder
[h264 @ 0x14da960] Missing reference picture, default is 2147483647
[h264 @ 0x1595380] mmco: unref short failure
    Last message repeated 1 times
[h264 @ 0x1595380] number of reference frames (0+5) exceeds max (4; probably corrupt input), discarding one

From the description, it looks like it is waiting for a "reference" frame, and then a bunch of them arrive when it is already late, so one frame is simply thrown away. Translated comment from internet : All broadcasters I know set PES length to zero for H264 video streams because PES length is a 16-bit value with a maximum of 65535 bytes (the old standard for MPEG2 video). This is too small for most PES H264 packs so it needs to be set to zero (any length). Read about PES here .
PES Packet Length in Packet Header PES (2 bytes) Specifies the number of bytes remaining in the packet after this field. May be null. If the PES Packet Length is set to zero, the PES Packet can be any length. A value of zero for the PES packet length can only be used when the payload of the PES packet is a video elementary stream.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question