是否有Python库可以提取视频元数据,例如[标题、描述、说明文字/副标题]?
我目前正在尝试寻找可以帮助我从视频文件(例如 [mp4、Mkv、Avi、WebM、mpg] 格式)中提取元数据或信息的 python 库。
我重点从视频文件中提取的主要数据主要是[标题、描述、评论、字幕/副标题]。
我尝试按照本指南使用 FFmpeg-python: https:// www.thepythoncode.com/article/extract-media-metadata-in-python
来自我的据了解,FFmpeg-python 从 probe() 函数提供了最多的数据,但输出不包含 [Title, Description, Comment] 和 lined_captions > 只是“0”,我认为这是源轨道。
感谢您提供的任何帮助。
I'm currently trying to find python libraries that can assist me in extracting metadata or information from video files such as [mp4, Mkv, Avi, WebM, mpg] formats for example.
The main data that I'm focusing on extracting from the video files are mostly the [Title, Description, Comment, Captions/Subtitles].
I've tried using FFmpeg-python following this guide: https://www.thepythoncode.com/article/extract-media-metadata-in-python
and Tinytag, https://www.geeksforgeeks.org/access-metadata-of-various-audio-and-video-file-formats-using-python-tinytag-library/
From my understanding, FFmpeg-python provided the most data from the probe() function but the output does not contain [Title, Description, Comment] and closed_captions is simply '0' which I assume is the source track.
Thank you for any help provided.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 ffprobe 来获取元数据:
对于字幕/隐藏式字幕,您需要使用 ffmpeg 读取字幕流:
然后您可以使用像
webvtt-py
解析字幕数据。 (我没有第一手经验,所以自己尝试一下。)不过有一点需要注意。如果您的视频是 DVD rip,则其字幕流 (dvd_subtitle) 是位图而不是文本,并且 FFmpeg 无法将其转换为文本数据。
You can use
ffprobe
to get the metadata:For the substitles/closed-captions, you need to read the subtitle streams with
ffmpeg
:Then you can use a library like
webvtt-py
to parse the subtitle data. (I don't have firsthand experience, so try it yourself.)One caveat though. If your video is a DVD rip, then its subtitle streams (dvd_subtitle) are bitmaps and not text, and FFmpeg cannot convert it to a text data.