即使将`verbose`设置为'False`,Moviepy仍会打印进度条

时间:2017-03-09 12:44:05

标签: python moviepy

我试图在调用" write_videofile"时禁止从moviepy生成的控制台输出。方法。 我把冗长的论点作为False传递无济于事。 它仍然输出如下内容:

0%| | 0/1624 [00:00<?, ?it/s]
0%| | 8/1624 [00:00<00:20, 77.64it/s]
1%| | 16/1624 [00:00<00:20, 78.31it/s]
2%|1 | 25/1624 [00:00<00:20, 77.90it/s]
2%|2 | 34/1624 [00:00<00:19, 80.80it/s]
3%|2 | 42/1624 [00:00<00:20, 75.91it/s]
3%|3 | 51/1624 [00:00<00:20, 76.07it/s]
4%|3 | 58/1624 [00:00<00:25, 62.44it/s]
4%|4 | 65/1624 [00:00<00:28, 54.77it/s]
4%|4 | 71/1624 [00:01<00:28, 53.63it/s]
5%|4 | 77/1624 [00:01<00:29, 52.69it/s]
5%|5 | 83/1624 [00:01<00:28, 54.06it/s]
5%|5 | 89/1624 [00:01<00:29, 52.80it/s]
6%|5 | 96/1624 [00:01<00:26, 56.95it/s]
6%|6 | 102/1624 [00:01<00:29, 52.38it/s]
7%|6 | 108/1624 [00:01<00:29, 51.74it/s]
...
...
...
100%|#########9| 1621/1624 [00:28<00:00, 51.43it/s]
100%|##########| 1624/1624 [00:28<00:00, 57.75it/s]

有没有办法完全抑制输出?

3 个答案:

答案 0 :(得分:2)

是。

write_vidiofilewrite_audiofile中有一个名为progress_bar的参数。通过progress_bar=False删除进度条。通常,您也希望通过verbose=False,就像您一样。

为了获得此功能,您可能必须运行pip install moviepy --upgrade(如果使用Python 3,则pip交换pip3,因为这刚刚添加(在moviepy版本0.2.3.1中添加)。

完整用法是:

clip = VideoFileClip("video.mp4")  # Generate a clip
clip.write_videofile("output.mp4")  # Prints progress bar and info
clip.write_videofile("output.mp4", verbose=False)  # Just prints progress bar
clip.write_videofile("output.mp4", verbose=False, progress_bar=False)  # Prints nothing

progress_bar参数也应该来write_images_sequence,我们目前的目标是0.2.3.2版。

答案 1 :(得分:1)

现在,在2019年,您必须使用clip.write_videofile("output.mp4", verbose=False, logger=None)隐藏进度栏,使用progress_bar=True时会出现类似TypeError: write_audiofile() got an unexpected keyword argument 'progress_bar'

的错误

答案 2 :(得分:0)

调用 help(clip.write_videofile) 表明:

<块引用>

verbose(已弃用,为了兼容性而保留) 以前用于打开/关闭消息。现在使用 logger=None。

所以你必须设置参数logger=None