【问题标题】:Moviepy still prints a progress bar even after setting `verbose` to `False`即使将 `verbose` 设置为 `False`,Moviepy 仍会打印进度条
【发布时间】:2017-03-09 12:44:04
【问题描述】:

在调用“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]

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

【问题讨论】:

标签: python moviepy


【解决方案1】:

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

【讨论】:

  • 仍在 2019 年。有趣的是,函数write_videofile实际上接受progress_bar参数zulko.github.io/moviepy/_modules/moviepy/video/…
  • 是的,但至少对我来说,这给出了一个错误,我解决了这个设置logger=none
  • verbose 不再使用,都包含在logger 参数中。
【解决方案2】:

更新 - 此答案现已过时。使用logger=None,或将logger 设置为Proglog logger 的自定义子类,以获得更细粒度的控制。


是的。

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 版本。

【讨论】:

  • 我接受了答案,但现在我收到了很多警告,例如:[WARNING] 2017-03-10T08:49:57.111Z 6ea1aca8-056e-11e7-bea1-ad162b1b8df2 /var/task/moviepy/video/io/ffmpeg_reader.py:113: UserWarning: Warning: in file /tmp/49502576-b270-4935-b087-26f4c08bffed/1.mp4, 1166400 bytes wanted but 0 bytes read,at frame 705/712, at time 23.50/23.70 sec. Using the last valid frame instead. UserWarning)
  • @anarchos78 将其作为一个问题发布在 GitHub 上,以及创建它的代码(最好是视频)。如果它仅在使用 progress_bar=False 时出现,请确保也将其添加。
  • 这已经被添加到发布的 PyPI 版本中,因此只需在命令行中运行 pip install moviepy --upgrade 会将 progress_bar 参数添加到 write_videofile
  • @anarchos78,该错误应该在最新的moviepy更新中得到修复。如果是这种情况,请告诉我们!
  • 只有我,还是没有办法禁用 ImageSequenceClip.write_gif 的进度条?
【解决方案3】:

调用help(clip.write_videofile) 表明:

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

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

【讨论】:

    【解决方案4】:

    对于moviepy==1.0.3

    使用

    logger=None
    

    【讨论】:

      【解决方案5】:

      现在在 Moviepy 版本 1.0.3 中如下:

      video.audio.write_audiofile(audio_file_path.wav, verbose= False, logger= None)

      progress_bar 更改为记录器。 如果您不想要进度条,只需将其设置为 None。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多