ffmpeg_extract_subclip函数和moviepy字符串输出错误
我一直在开发这个小应用程序来下载和剪切 Youtube 视频。 它工作正常,但错误或格式错误的消息是我尚未解决的问题。当谈到切割过程时,使用了函数 ffmpeg_extract_subclip ,在那之后,我得到了下面奇怪的错误:
负责剪切视频的函数
# cutting the video by section
def cut_video(video_local_path, start_time, end_time, final_file):
print("- Cutting your video...")
ffmpeg_extract_subclip(video_local_path, time_to_sec(start_time), time_to_sec(end_time), targetname=f"{final_file}.mp4")
如有需要可以查看完整代码这里 在 github 上。
我广泛阅读了 ffmpeg 和 moviepy 的 API,在 vscode 上进行了调试,并检查了 VideoFileClip 等替代方案,但它永远不会给我相同的性能。
提前致谢。
I have been developing this small application to download and cut Youtube videos. It works fine but an error or misformatted message is the issue I have not fixed. When it comes to the cutting process, the function ffmpeg_extract_subclip
is used and right after that point, I get the weird error below:
Below, the script working fine.
The function responsible for cutting the video
# cutting the video by section
def cut_video(video_local_path, start_time, end_time, final_file):
print("- Cutting your video...")
ffmpeg_extract_subclip(video_local_path, time_to_sec(start_time), time_to_sec(end_time), targetname=f"{final_file}.mp4")
If necessary, you can check the full code here on github.
I have extensively read the API for ffmpeg and moviepy, debugged on vscode and checked alternatives like VideoFileClip but it would never give me the same performance.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种方法可以解决此问题。
1.暂时重定向 stdout/stderr
请参阅这篇文章
2.直接使用FFmpeg
moviepy
< /a> 似乎取决于imageio-ffmpeg
了解其 FFmpeg 支持,以及imageio-ffmpeg
从IMAGEIO_FFMPEG_EXE
环境路径获取FFmpeg路径安装包时下载FFmpeg可执行文件。因此,您应该能够执行以下操作现在,如果您仅将
moviepy
用于此操作(以及其他 FFmpeg 操作),则可以完全删除它并设置ffmpeg_path
到 FFmpeg 路径。然后通过。ffmpeg-downloader
下载 FFmpeg 二进制文件 或static-ffmpeg
包。如果您在多个 venv 中使用 FFmpeg,则前者是更好的选择(因为它将 FFmpeg 文件保存在操作系统指定的用户数据区域中,因此只下载一次)。后者是 100% 自动下载方法,与imageio-ffmpeg
类似,但没有任何多余的装饰[编辑:
imageio-ffmpeg
不会自行下载 FFmpeg,因此您的系统上应该已经有 FFmpeg 可执行文件。]There are a couple ways to work around this behavior.
1. Momentarily redirect stdout/stderr
See this post
2. Use FFmpeg directly
moviepy
appears to be depending onimageio-ffmpeg
for its FFmpeg support, andimageio-ffmpeg
gets the FFmpeg path fromIMAGEIO_FFMPEG_EXE
environmental pathdownloads FFmpeg executables when the package is installed. So, you should be able to do the followingNow, if you are using
moviepy
only for this operation (and other FFmpeg operations), you can drop it altogether and setffmpeg_path
to the FFmpeg path.and just download the FFmpeg binaries via.ffmpeg-downloader
orstatic-ffmpeg
package. The former is a better choice if you use FFmpeg in multiple venvs (as it saves FFmpeg files in an OS designated user data area, so it only downloads once). The latter is 100% automatic downloading approach similar toimageio-ffmpeg
but with no frills[edit:
imageio-ffmpeg
does not download FFmpeg on its own, so you should already have the FFmpeg executables on your system.]