更改 mp4ize.py 以在 Windows 上运行
Mp4ize (python) 是将视频文件转换为 mp4 以在 iPhone 和 iPod 上使用的实用程序。我正在尝试让它在 Windows 上运行。
python脚本依赖于库fcntl,并根据另一个问题(Windows 上的 fcntl 替代 ),Windows 等效项是 win32api。另一个问题也说:
如果您提供有关 fcntl 调用的更多详细信息,人们可以找到 Windows 等效项。
由于我没有尝试自己重写代码,所以我想我应该在这里问。
如何重写以下代码以在 Windows 上使用?
fcntl.fcntl( p.stderr.fileno(), fcntl.F_SETFL, fcntl.fcntl(p.stderr.fileno(), fcntl.F_GETFL) | fcntl.fcntl(p.stderr.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK, )
请参阅此处获取完整源代码。
Mp4ize (python) is a utility for converting video files to mp4 for use on iPhone and iPod. I'm trying to get it to run on Windows.
The python script relies on the library fcntl, and according to another question ( fcntl substitute on Windows ), the Windows equivalent is win32api. The other question also says:
If you provide more details about the fcntl calls people can find windows equivalents.
and since I've had no luck trying to rewrite the code myself, I thought I'd ask here.
How can I rewrite the following code for use on Windows?
fcntl.fcntl( p.stderr.fileno(), fcntl.F_SETFL, fcntl.fcntl(p.stderr.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK, )
See here for the full source code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此命令设置标准错误文件描述符的 NONBLOCK 选项。这使得它可以在将整个数据写入其中之前传递数据。
http://pastebin.com/Zr5LN8Ui 上的补丁将在 Windows 上运行,并带有进度指示器。然而,即使编码是好的,它有时也会报告错误的编码。
它使用 Non-blocking read on a subprocess.PIPE 的解决方案在 python 中允许非阻塞 IO,并修复了现代 FFMpeg 的 pad 选项(您的版本不适用于我的测试文件)和进度条。
请注意,当 FFMpeg 传递 3 个或更多命令行选项时,它会被硬编码为使用链接方法,因为它会弄乱对获取输入文件分辨率的 FFMpeg 的第一次调用。
This command sets the NONBLOCK option of the standard error file descriptor. This lets it pass data through before the entirety of the data has been written to it.
The patch at http://pastebin.com/Zr5LN8Ui will work, with progress indicators, on Windows. However, it will sometimes report a bad encode even when the encode was good.
It uses the solution from Non-blocking read on a subprocess.PIPE in python to allow non blocking IO, and fixes the pad option (your version didn't work for my test file) and progress bar for a modern FFMpeg.
Note that it is hardcoded to use the linked method when FFMpeg gets passed 3 or more command line options, as it messes up the first call to FFMpeg which gets the resolution of the input file.