Best approach to "mix" a video playlist (MP4 with audio), with an audio playlist (Wav) and output a video stream (with both audios) #3258
Replies: 5 comments 1 reply
-
Thinking about this more, I realized I should demo this with FFMPEG. These three commands successfully deliver an
The magic seems to happen here: So. I am now thinking that what I should be trying to do in Liquidsoap is use this same filter on my source playlists? I see page 221, in the Liquidsoap manual:
Maybe I need to adapt this, change input and output logic, and use the |
Beta Was this translation helpful? Give feedback.
-
This is either very challenging, or maybe I am taking the wrong approach, but this is what I have so far:
This fails with the error:
But there are so many questions in my mind.. It doesn't seem clear to me that liquidsoap even supports "complex" filters, or filters with more than one input? |
Beta Was this translation helpful? Give feedback.
-
Hi @kingpalethe and welcome! I think that the biggest challenge that you will find is indeed synchronization. While we have a pretty flexible and new support for multitrack muxing and demuxing, I'm not sure if you can do the level of granularity that you are lookin for. The best option for you as of now would be to implement your own protocol. At the higher level, the protocol would be taking whatever tracks you want to mux, fetch them, prepare a muxed track using an external command line such as ffmpeg and returning the resulting file. This way, you would be sure that every single request is muxed exactly and synchronously as you want them. To be more specific, let's imagine that each track is identified with an
(you could even use the Then your protocol declaration would look like:
We'll be keeping in mind your use-case. I created an issue to track it here: #3262 |
Beta Was this translation helpful? Give feedback.
-
Thanks! Regarding synchronization. Actually my synchronization requirement is limited.... Given the inputs:
I need an output
BUT -- I only need Explained another way. Imagine it's a TV show, with dialog (speaking). I want to add a music "soundtrack" or "bed" to go underneath the video + dialog. The soundtrack isn't really tightly timed to the video, I just want music to generally play "in the background". I'm not sure if this makes the whole thing "easier" or not. It occurs to me that a simple strategy might be TWO simultaneous liquidsoap scripts... one that sequences the video + audio playlist, and one that sequences the audio-only playlist. Each script would output an RTMP stream, and then, on the same machine, I would run a continuous FFMPEG process as shown here: https://stackoverflow.com/questions/18618191/ffmpeg-merge-multiple-rtmp-stream-inputs-to-a-single-rtmp-output
I'm going to try this next and report back my findings here. |
Beta Was this translation helpful? Give feedback.
-
Ah, yes, this works, thanks much. |
Beta Was this translation helpful? Give feedback.
-
Thanks for this great library!
I've spent hours with to documentation but I still have a lot of doubt about how to reliably implement this scenario.
I have a playlist of WAV files:
Each WAV file in the playlist currently looks like this in
ffmpeg
:I have a playlist of .MP4 files:
Each MP4 in the playlist currently looks like this in
ffmpeg
:You can see that these MP4 files have two streams -- a Video stream
0:0
, and an Audio stream0:1
.You can see that these WAV files have one stream -- and Audio stream
0:0
.Note -- if necessary, I could easily change the format of any of these streams, if that would make my goal possible or reliable in liquidsoap....
What I want to do is "mix" these playlists... To be as explicit as possible... I want to output a final Video stream which has
There are lots of examples in the documentation of various kinds of
source.mux
operations... For example, on page 151 of the manual, we find this example:But I think this is the wrong path for me, because I actually want to "mix" stream
0:1
of the video (i.e, the audio track of the video), with the WAV file.... and then output a new video stream.And here is the tricky part -- the synchronization is really critical here, because these are videos of people speaking.. so even a second of bad synchronization will look bad!
Can anyone point me toward the right strategy to do this?
Clearly just using
.add
will not work -- liquidsoap seems to refuse to add an audio source to a video source.I also see that there is a very new API, here https://www.liquidsoap.info/doc-dev/multitrack.html ... but I don't even find the word "mix" anywhere on this page!
This seems like a simple and common thing to do, but I'm struggling to figure out the right strategy.
One more thing -- if necessary, instead of using MP4 files as input (with and audio stream and a video stream), it would be no problem for me to pre-process these files, to split the audio and the video, and bring those two parts separately into liquidsoap, but this then brings up further doubts in my mind -- then they would have to be separate playlists, and for sure I would not get millisecond-tight synchronization.
And also: I know from experience that A/V sync issues are sometimes very tricky -- and have looked at this comment with some fear: #1091 (comment) ......
.... thanks again!
Beta Was this translation helpful? Give feedback.
All reactions