pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.52k stars 768 forks source link

HEVC (h.265) over RTMP? #1010

Closed biviel closed 6 months ago

biviel commented 2 years ago

hi, @pedroSG94 ,

There is a camera I own that can stream HEVC over RTMP and it works well to stream to my Wowza Streming Engine, but also toward YouTube, which can ingest h.265 encoded video. I think audio remains in aac.

A reference sample, even if FLV does not support, but clearly lot of platforms can ingest already hevc over RTMP. https://www.iiwnz.com/hevc-over-rtmp/

What do you think, is it enough to modify RTMP module? Would it be enough to modify packets only, like duplicating H264Packet.kt into H265acket.kt with some minimal changes only in the header and videospecification?

there is a patch for ffmpeg that works according to that article: https://gist.github.com/peerasan/4430be219ed425561f065c79525633d8

Is it possible that so small changes would make this great library also work in HEVC over RTMP? And the only part is missing from his library is that rtmp does not communicate toward servers the encoding properly ( i know its not part of flv...)?

It could spare about 30% of required bandwidth and that is very critical, especially in 4K resolution on mobile networks...

Thanks for your thoughts!

P.S. I know there was a communication a few years back, but lot of progress since, both on this library and media servers too. h265 is there already.

pedroSG94 commented 2 years ago

Hello,

Are you sure that your camera send video in H265 and it is not transcoded in server before send it to player?

I know about this patch of FLV. I didn't develop it because I don't know a server that support it. YouTube support ingest H265 only for HLS not for RTMP and I couldn't find any post about RTMP H265 on wowza. The only server that I could find for this was with a command of ffmpeg and it is not really interesting (you can't use it like a real server). You mentioned that wowza support H265 over RTMP but in the wowza docs page I can't find it: https://www.wowza.com/docs/understanding-protocols-and-formats-supported-by-wowza-streaming-engine#rtmp Same for YouTube RTMP: https://support.google.com/youtube/answer/2853702?hl=en Documentation for YouTube HLS: https://developers.google.com/youtube/v3/live/guides/hls-ingestion

If you can find a server with H265 support for RTMP using that patch I can try to develop it. Also, if possible a guide of installation/configuration

biviel commented 2 years ago

hi, I'm sure that camera I own qoocam 8k enterprise can stream h265 over RTMP, I tested it toward my server instance (wowza streaming engine) and used as source. In server I transcode it of course to HLS and mpegdash H.264 or VP9. The original H.265 source can also be played back on Edge browser if the machine has a proper hardware support to decode, would require in some cases to enable hardware acceleration. Moving toward 8k live streaming this is the only possible option for now.

For testing I also used the free version of larix broadcaster on various android phones to test especially H.265 over RTMP and it worked, resolution was limited as per devic, I published to my Wowza streaming engine, which is running on a proper dedicated hardware with GPU(s) via AWS, so it has hardware encoders/decoders including HEVC.

HEVC for camera, especially 360 is may be important, because of bandwidth and quality requirements. I'm planning also to build a restreaming service from my platform toward facebook or youtube, but I'm not there yet.

So my platform on top of Wowza streaming engine can ingest HEVC/H.265 encoded video via RTMP and transcode it to HLS and mpegdash (VP9 or H.264 encoded) and expose on website directly.

Would you like an early access I can give you an account so you would be able to login to my platform and book a time for live streaming for free and could develop, test? Directly on website you will be able to see the stream too (transcoded to mobile browsers and h.264 or vp9). I'm having now an issue, when transcoding incoming h.264 to vp9, the video is not working right at the moment, but transcoding incoming h.265 to VP9 works as it should. Not sure yet why, this is on my list to debug. Anyway h.264 has wider compatibility for now, at least it had in past.

Goal of my platform is to provide self service, so someone can come and register and book/buy a timeslot for live streaming and platform provides CMS, pages to setup with content, access control and there is also a shop behind so could ask viewers to buy online a ticket to participate the event. I'm planning to move toward multi server architecture, but for now I'm running 1 production instance only and it's not open yet to public but planning to start a beta test period after I'm done with alfa tests internally.

pedroSG94 commented 2 years ago

Ok, I did a test with wowza and it is working. I will start the develop soon.