I
I
Inlarion2019-08-31 19:06:25
Android
Inlarion, 2019-08-31 19:06:25

FFmpeg how to set PES packet length to zero?

There is a multicast stream inside mpegts h264, the task is to overtake it in hls without changes.

/usr/bin/ffmpeg -i udp://239.0.110.16:1234 -map 0:0 -map 0:1 -vcodec copy -acodec copy  -copyts -async 100 -ignore_unknown -loglevel warning -f hls -hls_list_size 5 -hls_time 5 -hls_flags delete_segments /var/www/html/ffmpeg/stream.m3u8

It works great, but sometimes errors arrive in the ffmpeg log in the incoming stream, you can observe the following entry:
[mpegts @ 0x56397b59a500] PES packet size mismatch
What does this error mean, I know how to normalize the incoming stream is not possible.
After this error, all normal consumers and players work fine. Except for Android consoles that take hls using Stagefright (versions starting from Nougat). The image on the prefix periodically falls apart until you restart ffmpeg, as soon as ffmpeg "catch" PES packet size mismatch the picture falls apart again. Moreover, the problem is in ffmpeg, because rebooting the console does not give anything. In other clients, the picture is just perfect without problems and glitches.
Googling led to a five year old email with the ffmpeg developers where a person describes this problem and says that setting PES packet length = 0 solves it. A similar issue is known on wowza and they have this setting:
mpegtsAlwaysSendZeroPacketLen – If you don't want video frames to be wrapped in multiple TS packets for very high bitrate streams, set to true to set packetized elementary stream (PES) packet length to 0 (zero)

The question is how to force the PES packet length = 0 header to be set using ffmpeg? Smoking kilometer docks did nothing, and constant restarts of ffmpeg are a crutch.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Evseev, 2019-09-11
@IlyaEvseev

A fix was proposed in https://ffmpeg.org/pipermail/ffmpeg-devel/2014-Apr... in 2014.
Judging by https://github.com/FFmpeg/FFmpeg/blob/master/libav... - the fix is ​​accepted, but in a modified form, another codec is checked + the omit_video_pes_length flag. https://ffmpeg.org/ffmpeg-formats.html says that the flag is enabled by default
. Therefore, it makes sense to check: 1) the sources of the used version of ffmpeg - do they have this piece? 2) Does setting the flag explicitly help? 3) manually building the latest ffmpeg version 4) manually building with the patch from the first link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question