Inserting SPS NAL Units into h.264 stream

1

I'm currently using FFmpeg to convert a Youtube livestream HLS into a H.264 UDP stream.

For it to work correctly with the device I'm using, the stream needs to have SPS NAL units inserted every so often.

I have found out that using the H.264 'main' profile, no SPS units are present. But when using the 'baseline' profile, one SPS unit gets inserted before each IDR NAL unit.

Unfortunately, the 'baseline' profile causes some video glitches (some patterns get repeated multiple times horizontally).

I have also tried dump_extra=all but still no SPS units.

Any ideas to make this work?

Here is the current command I use :

ffmpeg \
    -err_detect explode \
    -fflags "+genpts" -avoid_negative_ts "make_zero" \
    -loglevel warning -nostats \
    -re -i hls_url.m3u8 -segment_time 10 -hls_time 10 \
    -c:v libx264 -preset veryfast -r 30 -flags +cgop -profile:v main -level 3 -bufsize 5M -minrate 5M -maxrate 5M -b:v 5M -pix_fmt yuv420p -bf 3 -s ntsc -x264opts nal-hrd=cbr:force-cfr=1:aud=1:keyint=25:open_gop=0 -aspect 16:9 -refs 3 -g 50 \
    -acodec ac3 -ar 48000 -ab 192k \
    -vf "fifo,setpts=PTS-STARTPTS" -af "afifo,asetpts=PTS-STARTPTS" \
    -bsf:v h264_mp4toannexb \
    -threads 2 \
    -bitrate 6M -packetsize 188 -flush_packets 0 -f mpegts "udp://multicastip:multicastport?pkt_size=1316&dscp=32"

Thanks!

Julien Moreau

Posted 2019-08-28T20:59:19.330

Reputation: 11

How are you checking for NAL units? Which version of ffmpeg? – Gyan – 2019-08-29T08:05:54.843

@Gyan I am using tstools. It was recommended by the maker of the device on which I'm trying to play this stream. I am using ffmpeg version N-48944-g9b069eb14e-static.

– Julien Moreau – 2019-08-29T12:37:50.180

No answers