ffmpeg: Infinite amount of filters/crossfading dynamic playlist

Viewed 493

I want to use ffmpeg to play a dynamic playlist infinitely. The idea is, that an external command/script is executed to request the path to the next file (using the predicted start-time of the file as an argument) and continue playing files infinitely.

From the answer to "Using FFMPEG to stream continuously videos files to a RTMP server" i learned, that i need to write a custom demuxer, that is similar to the concat demuxer. The problem arises from the fact, that i want to crossfade between the audio files and from my understanding of the demuxer i would have to implement that functionality into the demuxer itself to be able to do it, because a demuxer can only produce one (or a finite number) audio output stream and you need two to use the acrossfade-filter.

So i would have to set up the filter graph like this:

file1 --------------------------------*-->| cross | ---->more filters ---> Output
file2 -----------------*-->| cross |----->| fade  |
file3 --*-->| cross |----->| fade  |
      ... ->| fade  |

Using an infinite number of crossfade-filters.

Also i would really like to pre-filter(*, e.g. silenceremove) the audio files before cross-fading, which makes it even more complicated and the "implement everything in the demuxer"-approach even worse.

My current solution would be to implement a custom demuxer that alternates between two output streams and does the prefiltering internally as well as an input-alternating crossfade filter like this:

files -> | alternating |----->| alternating | ----> more filters--->
         |   demuxer*  |----->|  crossfade  |

The problem i see with this approach is that i would need to send multiple EOF-terminated files from the demuxer to the crossfade-filter and i don't know if that is even possible/allowed when using the standard ffmpeg functions like ff_request_frame.

Can you tell me if this approach is feasible or do you have a better solution to this problem or any idea that would make this easier?

0 Answers
Related