Is it possible to have a progress bar without a loop?

本秂侑毒 提交于 2021-01-28 10:10:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!