go2rtc
go2rtc copied to clipboard
Challenges using ffmpeg to copy & stream an HLS/fMP4 stream to RTP (but works with an HLS/TS stream) -- Octoprint/Obico questions
Octoprint (for 3D printing) seems to best support HLS for mp4 (at least out of the box, WebRTS and MSE don't seem to work). I am using a stream like the following for my PiCamera v3 on a RPi5
picam_h264:
- exec:libcamera-vid -t 0 --libav-format h264 -o -
The streaming seems to have less latency when using HLS/fMP4 (stream_url = http://mypi:1984/api/stream.m3u8?src=picam_h264&mp4
)
rather than HLS/TS ( stream_url = http://mypi:1984/api/stream.m3u8?src=picam_h264
).
However for the obico plugin, I need to use ffmpeg to copy the stream to an rtp Janus stream using something like:
ffmpeg -re -i <stream url> -an -c:v copy -an -f rtp rtp://127.0.0.1:17732?pkt_size=1300
However, ffmpeg terminates when using HLS/fMP4 after about 3 frames (though works fine with the lesser quality HLS/TS stream)
ffprobe shows the following differences between the streams: HLS/TS:
Input #0, hls, from 'http://mypi:1984/api/stream.m3u8?src=picam_h264':
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:
Input #0, hls, from 'http://mypi:1984/api/stream.m3u8?src=picam_h264&mp4':
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 fail to copy and stream to RTP with HLS/fMP4 but succeeds with HLS/TS?
- Are there any parameters/filters I can add to ffmpeg (short of re-transcoding) that will allow it to work with HLS/fMP4?
Thanks