Manevolent / ffmpeg4j

A Java OOP FFmpeg wrapper around the JavaCPP FFmpeg native library bindings
Apache License 2.0
105 stars 15 forks source link

Any example on how to stream to an RTMP endpoint? #4

Closed arisprung18 closed 3 years ago

Manevolent commented 3 years ago

I don't have any examples of this, but I have used ffmpeg4j successfully to (somewhat easily) stream to an RTMP endpoint.

The trick is to use FFmpegIO.openNativeUrlOutput(String), where your first (and only) argument is in the format rtmp://.... From there, you acquire an FFmpegTargetStream object, which you should pass the format flv to, and for your substreams: use the codecs aac for audio, and libx264 for video.

Additionally, if you want to ingest an RTMP stream (i.e. host your own RTMP server), you can wire together ffmpeg4j and a pretty old (but quite useful) library called Flazr: https://github.com/mconf/flazr.

Unfortunately, the code I wrote earlier on which uses ffmpeg4j to input and output RTMP livestreams is some of the only code I haven't put on my GitHub yet, due to several reasons. I don't anticipate I'll publish it soon (i.e. this year) but I have mulled over the idea of sharing it out some day.

Hope this helps!

kinsleykajiva commented 7 months ago

Hello sir do you care you have code worth sharing yet or sample to help us out on this part ?