简体   繁体   中英

Bash process substitution in Python with Popen

I'm attempting to create a looped video file by calling ffmpeg from the python subprocess library. Here's the part that's giving me problems:

import subprocess as sp
sp.Popen(['ffmpeg', '-f', 'concat', '-i', "<(for f in ~/Desktop/*.mp4; do echo \"file \'$f\'\"; done)", "-c", "copy", "~/Desktop/sample3.mp4"])

With the above code I'm getting the following error:

<(for f in /home/delta/Desktop/*.mp4; do echo "file '$f'"; done): No such file or directory

I did find a similarly phrased question here . But I'm not sure how the solution might apply to solving my issue.

Following the advice in the comments and looking elsewhere I ended up changing the code to this:

sp.Popen("ffmpeg -f concat -i <(for f in ~/Desktop/*.mp4; do echo \"file \'$f\'\"; done) -c copy ~/Desktop/sample3.mp4",
         shell=True, executable="/bin/bash")

--which works fine. – moorej

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM