问题
I am using FFmpeg to do some video editing. I would like to have a progress bar but there is not a loop in my code. I've tried tqdm and putting my code in a loop with a range of 1 but that will only display the progress bar at 100%. Maybe there is another way to accomplish this? This is the code I'm using:
import subprocess
inmovie=mymovie.mp4
speed=str(4.0)
outmovie=newmovie.mp4
print('Converting file.......')
subprocess.call('ffmpeg -i '+inmovie+' -filter:v "setpts= '+speed+' *PTS" '+outmovie, shell=True)
print('Conversion done')
回答1:
You can use something like pv to monitor the progress of something through a pipe.
For example like this
pv infile.mp4 | ffmpeg
If you're to implement this into your code you can try something like
subprocess.call('pv '+inmovie+' | ffmpeg -filter:v "setpts= '+speed+' *PTS" '+outmovie, shell=True)
来源:https://stackoverflow.com/questions/47500953/is-it-possible-to-have-a-progress-bar-without-a-loop