javacv
javacv copied to clipboard
Is it possible to stream MediaCodec outputbuffer to FFmpegFrameRecorder?
I'm trying to stream MediaCodec that records a surface over RTMP.
I understand that MediaCodec buffer is a raw h264 frame. How would I go about converting this to the correct format to feed to the FFmpegFrameRecorder?
Most likely yes. Please try to use packets: https://github.com/bytedeco/javacv/issues/93
@saudet Is there a working example of this?
/cc @alicanalbayrak @Baobomb You guys have anything?
Hi, @saudet !
Are there any updates on this question?
I googled around and found this project There MediaCodec and ffmpeg almost finely mixed together. I converted it into gradle based project and translated all ffmpeg calls to JNI calls using javaCV. And it work almost good: write long video with good stable fps. I still can't make it split video into ts files which seems like missconfiguration.
My first thought was to implement conversion between MediaCodec's output buffer and FFMpegFrameRecorder's input packet, but I have had no luck with that.
There you said it's needed to add a support for RAW (H264?) packets which seems to be exactly what I have tried to do.
I know this issue was pushed many times and I am sorry for doing it again but I am in real need in it. So I would greatly appreciate if you can kindly guid me or give an advice for next steps.
@balbelias I'm sorry, I don't have any more information about that. That's why I labeled this issue with "help wanted". If you do put the effort into making this work, please consider making a contribution back! Thank you
@saudet ok! I see, it's more about FFMPEG than JavaCV. But what did you mean by "add support for RAW packets"?
Support for packets was added here: https://github.com/bytedeco/javacv/pull/372
BTW, FFmpeg supports MediaCodec now and we should be able to use it easily like this, for example: https://github.com/bytedeco/javacv/issues/945#issuecomment-405795977
But how to construct AVFormatContext
from MediaCodec
output format? The only suggestion that I've seen is to dump few frames into FFmpegFrameGrabber
(https://github.com/OnlyInAmerica/FFmpegTest)
@alexey-pelykh We can do it with FFmpeg for sure. Contributions are welcome!
BTW, FFmpeg 6.0 now supports hardware accelerated encoding using MediaCodec, so we don't need to use its API directly anymore. Please give it a try with the snapshots: http://bytedeco.org/builds/