DEV Community

PJ
PJ

Posted on • Updated on

Writing ffmpeg filter complex in python

I am new to ffmpeg. I am trying to learn to convert ffmpeg command line of multiple audio merge to ffmpeg-python format.

'ffmpeg -i first.mka -i second.mka -i third.mka -i fourth.mka -filter_complex "[1]adelay=104000|104000[b]; [2]adelay=260000|260000[c]; [3]adelay=362000|362000[d]; [0][b][c][d]amix=4" merged.mka

Can anyone help me learn full transformation syntax? Specifically i want to know how to represent filter complex in ffmpeg-python This is what i have tried so far

[lk = [60,120] # delay time in seconds
audios = []
for k, i in enumerate(audio_file):
audio = ffmpeg.input(i['src'], select_streams='a')
if audio['streams'] and i['muted'] == False:
a = (audio.filter('adelay', f"{i[lk] * 1000}|
{i[lk] * 1000}"))
audios.append(a)
mix_audios = ffmpeg.filter_(audios, 'amix') if len(audios) > 1
else audios[0]]

Top comments (0)