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

2 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]
Run Code Online (Sandbox Code Playgroud)

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

Lor*_*lli 9

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

  • 是的,但是,至少对我来说,这给出了一个错误,我解决了这个设置 `logger=none` (2认同)

tbu*_*s13 8

更新- 这个答案现在已经过时了。使用logger=None, 或设置为Proglog 记录器logger的自定义子类以进行更细粒度的控制。


是的。

中有参数write_vidiofilewrite_audiofile称为progress_bar。通过progress_bar=False删除进度条。通常你也会想通过verbose=False,就像你已经做到的那样。

为了获得此功能,您可能必须运行pip install moviepy --upgrade(如果使用Python 3则交换pippip3,因为这只是刚刚添加的(在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
Run Code Online (Sandbox Code Playgroud)

progress_bar还应该有一个参数write_images_sequence,我们目前的目标是版本 0.2.3.2。