using ffmpeg command line with python's subprocess module

Chris Angelico rosuav at gmail.com
Mon Dec 2 06:40:52 EST 2013


On Mon, Dec 2, 2013 at 10:34 PM, iMath <redstone-cold at 163.com> wrote:
> I have few wav files that I can use either of the following command line mentioned here
> https://trac.ffmpeg.org/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files
>  to concatenate
>
>
> ffmpeg -f concat -i <(for f in ./*.wav; do echo "file '$f'"; done) -c copy output.wav
> ffmpeg -f concat -i <(printf "file '%s'\n" ./*.wav) -c copy output.wav
> ffmpeg -f concat -i <(find . -name '*.wav' -printf "file '%p'\n") -c copy output.wav

In bash, the <(...) notation is like piping: it executes the command
inside the parentheses and uses that as standard input to ffmpeg. So
if you work out what the commands are doing (it looks like they emit a
line saying "file '...'" for each .wav file in the current directory,
possibly including subdirectories) and replicate that in Python, you
should be able to make it cross-platform.

ChrisA



More information about the Python-list mailing list