Repository metrics
- Stars
- (6,985 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
I have a use case to get packets from a streaming server, from an RTMP encoder. And transcode to Ogg/Opus using recordSamples. It's similar to the microphone examples but different. Giving the recorder the raw AAC bytes produces a noisy output. Using the frame grabber to be the rtmp client works.
Does the AAC packets need to be decoded to PCM first to be usable ? Is there a way to do this without passing them to the framegrabber or can they be sent to a frame grabber using PipedInputStream ?
It's not a common use case it seems I only see microphone inputs that is PCM already. The server might have a utility already to decode the AAC packets to PCM to be consumable by the recorder.
Example of what I am trying to do right now but the output has to go to an outputstream for sending bytes to a websocket service.
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("D:\\test.ogg", 1);
recorder.setFormat("ogg");
recorder.setAudioCodec(AV_CODEC_ID_OPUS);
recorder.setSampleFormat(AV_SAMPLE_FMT_FLT);
recorder.setAudioOption("vbr", "constrained");
recorder.setAudioBitrate(24000);
recorder.setSampleRate(16000);
recorder.setAudioChannels(1);
recorder.start();
Then in the packet capture method. I dont know the method yet to get the samplerate from the input packets. packet.getData is an AAC packet.
byte[] data = packet.getData();
ByteBuffer buffer = ByteBuffer.wrap(data);
recorder.recordSamples(48000, 2, buffer);