tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

Android: How to pipe videochunks (from MediaRecorder) #689

Closed athlyzer-janos closed 3 years ago

athlyzer-janos commented 3 years ago

Description I get videochunks h264 encoded (Browser delivers them from MediaRecorder.ondataavailable via websockets to my local server on an android phone). Thy are sent as ByteBuffer.

I read the wiki about pipe (Runtime.getRuntime().exec(new String[]{"sh", "-c", "cat > " + pipe1});

How can i pipe these chunks (ByteBuffer) to the ffmpeg process?

Expected behavior On windows and mac (electron) this appoach worked like a charm

Current behavior invalid data

Screenshots

Logs

Environment

Other `String pipe = Config.registerNewFFmpegPipe(this.getActivity()); String ffmpegCommand = "-i " + pipe + " -c:v copy -c:a aac -strict -2 -ar 44100 -b:a 64k -y -use_wallclock_as_timestamps 1 -async 1 -bufsize 1000 -max_muxing_queue_size 9999 " + this.outputPath + outputFilename + ".m3u8"; FFmpeg.execute(ffmpegCommand)

public void onMessage(WebSocket conn, ByteBuffer videoChunk) { Runtime.getRuntime().exec(new String[]{"sh", "-c", ???? > " + pipe}); }`

athlyzer-janos commented 3 years ago

by the way: thank you so much for mobile-ffmpeg, it's amazing

tanersener commented 3 years ago

pipe is a path. You need to open it as a file and write your video chunks into it.