Collection of stupid methods to stream H.265 RTSP from an IP camera to Youtube without video transcoding
I have a IP cam that output RTSP stream with:
- H.265 video codec
- Weird resolution of 1920x2160 (which is the result of stacking two 1920x1080 streams vertically into one frame)
- Super unstable timing (pts + dts is not even provided)
- 15fps when stable (yes that's what the camera output)
and I want to stream that to Youtube (using ffmpeg)
Transcoding is NOT an option since my server is just a little 4x Cortex A53 SoC with no hardware encoding/decoding capability for H.265 (and maybe H.264). I have tried transcoding from H.265 to H.264. It works, but at the even at the fastest preset and at the resolution of 640x720, it barely reaches 10fps.
(You can retry if you think you have a better ffmpeg command for the approach)
- Read the RTSP stream using ffmpeg and stream directly to Youtube via RTMP (ffmpeg input RTSP output RTMP) => Not work since ffmpeg's flv container does not support H.265.
- Read the RTSP stream using ffmpeg and stream directly to Youtube via HLS (ffmpeg input RTSP output HLS) => Not work due to missing pts and dts (I think there should be a way to fix this but currently I don't know of one since. I have tried flags like genpts and use wallclock time but none worked)
- Read the RTSP stream using ffmpeg, convert to mpeg live stream format and pipe to another ffmpeg which take that package and stream to HLS => Not work due to missing pts and dts
- Record the RTSP stream to mp4 file segments, and another ffmpeg read these files and stream to Youtube via HLS (worked, see segmented_stream.py)
- Record the RTSP stream to mp4 file segments, implement dual ffmpeg concat lists to continuous read new mp4 segments without restarting ffmpeg (promising, but my implementation failed since ffmpeg has really weird timing)