是否有没有循环的进度条? [英] Is it possible to have a progress bar without a loop?

查看:73
本文介绍了是否有没有循环的进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FFmpeg进行一些视频编辑.我想要一个进度条,但是我的代码中没有循环.我已经尝试过tqdm并将我的代码放入一个范围为1的循环中,但这只会显示进度条为100%.也许还有另一种方法可以做到这一点?这是我正在使用的代码:

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') 

推荐答案

您可以使用pv 监视通过管道进行的操作.

You can use something like pv to monitor the progress of something through a pipe.

例如这样的

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)

这篇关于是否有没有循环的进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆