0

I'm trying to concat two audiofiles using ffmpeg-python. I've got the proper result with the direct use of ffmpeg in the CLI. The following command gave the proper result

.\ffmpeg -f concat -safe 0 -i input.txt -codec copy output.mp4

But now I'm trying to investigate whether the Python wrapper can provide the solution without running ffmpeg directly from python script using subprocess. It's possible to trim audiofiles, change volumes and make many other things with the use of ffmpeg-python. But for the concatenating audiofiles I've failed to found a solution.

1 Answers1

2
input_mp3 = ffmpeg.input(path)
input_mp3_2 = ffmpeg.input(path_2)
cut_1 = input_mp3.audio.filter('atrim', start=5, end=10)
cut_2 = input_mp3_2.audio.filter('atrim', start=5, end=10)
audio_output = ffmpeg.concat(cut_1, cut_2, v=0, a=1).output('out_merger.mp3')
ffmpeg.run(audio_output)
  • Thanks for the answer. For more info please refer to [official documentation](https://ffmpeg.org/ffmpeg-filters.html#concat) or [code repository](https://github.com/kkroening/ffmpeg-python/blob/master/ffmpeg/_filters.py#L406). – alexopoulos7 Dec 06 '22 at 12:42
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 12 '22 at 01:07