bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.45k stars 1.57k forks source link

how to convert rtmp input stream's audio samplerate and channel count #2011

Open ggslayer opened 1 year ago

ggslayer commented 1 year ago

Hi, I wan't help about:

In my server, I use javacv to pull a stream with samplerate and channel count unknow, I want to convert the stream's sample rate and channel count to the fixed 22050 and 2 channels by FFmpegFrameGrabber, can you give me some advise about this? thank you.

saudet commented 1 year ago

We can use FFmpegFrameGrabber and FFmpegFrameRecorder, but it's a lot easier to use the ffmpeg program instead: http://bytedeco.org/javacpp-presets/ffmpeg/apidocs/org/bytedeco/ffmpeg/ffmpeg.html

ggslayer commented 1 year ago

Thank you for your reply, In my scene, my program is a server , It pull a stream , and mix audios from the stream and local audio file, then , push result stream out, becouse audio mix, I should get two same sample rate and sample channel count. So, I think ffmpeg is not suite for my case. I saw the FFmpegFrameFilter, Is this can done this? If yes, is there some example about this case? Thank you!