How to convert ffmpeg complex_filter to ffmpeg-python code example
Example: How to convert ffmpeg complex_filter to ffmpeg-python
audios = []
inputs = []
#generate an empty audio
e_aud_src = rendering_helper.generate_empty_audio(0.1)
e_aud = (
ffmpeg.input(e_aud_src)
.audio
)
for k, i in enumerate(videos):
inp = ffmpeg.input(i['src'], ss=i['start'], t=(i['end'] - i['start']))
inp_f = (inp.filter_multi_output('split')[k]
.filter_('scale', width=(i['width'] * Factors().factors['w_factor']), height=(i['height'] * Factors().factors['h_factor'])).filter('setsar', '1/1')
.setpts(f"PTS-STARTPTS+{i['showtime']}/TB"))
audio = ffmpeg.probe(i['src'], select_streams='a')
if audio['streams'] and i['muted'] == False:
a = (inp.audio.filter('adelay', f"{i['showtime'] * 1000}|{i['showtime'] * 1000}"))
else:
a = e_aud
audios.append(a)
e_frame = (e_frame.overlay(inp_f, x=(i['xpos'] * Factors().factors['w_factor']), y=(i['ypos'] * Factors().factors['h_factor']), eof_action='pass'))
mix_audios = ffmpeg.filter_(audios, 'amix') if len(audios) > 1 else audios[0]
inp_con = ffmpeg.concat(e_frame, mix_audios, v=1, a=1)
return inp_con