Realtime Muxing of videos

507 views Asked by At

My problem basically comes from me having 2 different streams for videoplayback and having to mux them realtime in memory. One for video, and another for audio.

My goal is to create a proxy which can mux 2 different webm streams from their URLs, while supporting range requests (requires knowing the encoded file size). Would this be possible?

This is how I mux the audio and video streams manually using ffmpeg:

ffmpeg -i video.webm -i audio.webm -c copy output.webm

But, this requires me to download the video fully to process it, which I don't want to do unfortunately.

Thanks in advance!

2

There are 2 answers

1
Kelsnare On

Checkout ffmpeg pipes.

Also since you have tagged go - i'm assuming you will use os/exec - in which case also checkout Cmd.ExtraFiles. This lets you use additional pipes(files) beyond just the standard 0, 1 and 2.

So let's say you have a stream for video and one for audio piping to 3 and 4 respectively. The ffmpeg bit of your command becomes:

ffmpeg -i pipe:3 -i pipe:4 -c copy output.webm

0
Shubham Srivastava On

If you are looking for this to work in go you can look into

github.com/at-wat/ebml-go/webm

This provides a BlockWriter interface to write to webm file using buffers; You can see the test file to checkout how to use it

https://github.com/at-wat/ebml-go