I am using go2rtc
to generate HLS streams to stream video from a PiCamera v3 running on an RPi5 for use in Octoprint.
I also need to copy and restream the HLS stream to an RTP Janus server for Spaghetti detection.
ffmpeg
works fine on an HLS/TS (H264) stream but fails on a similar HLS/fMP4 (H264, H265, AAC) stream — however, for quality reasons, I would prefer to use an HLS/fMP4 stream.
Specifically, I am running the following:
ffmpeg -re -i <STREAM_URL> -an -c:v copy -an -f rtp rtp://127.0.0.1:17732?pkt_size=1300```
It streams properly forever when STREAM_URL is in HLS/TS format but fails when in HLS/fMP4 format after about 3-4 frames.
Running ffprobe
gives the following:
HLS/TS:
Duration: N/A, start: 0.000000, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 192000
Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1536x864, 15 tbr, 90k tbn
Metadata:
variant_bitrate : 192000
HLS/fMP4:
Duration: N/A, start: 0.000000, bitrate: 1248005 kb/s
Program 0
Metadata:
variant_bitrate : 192000
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1536x864, 1248005 kb/s, 90k tbr, 90k tbn (default)
Metadata:
variant_bitrate : 192000
major_brand : iso5
minor_version : 512
compatible_brands: iso5iso6mp41
- Why does
ffmpeg
succeed on a HLS/TS stream but fail on an HLS/fMP4 stream? - Are there any parameters or simple envelope filters I can add to
ffmpeg
that will allow it to succeed on HLS/fMP4 streams, short of a computationally intensive re-transcoding?