简体   繁体   English

如何编辑 MP4 文件的创建日期?

[英]How to edit creation date of MP4 files?

Currently, I'm working on a python3 script that helps me sort the Google Photos takeout files.目前,我正在开发一个 python3 脚本,它可以帮助我对 Google Photos 外卖文件进行排序。 The Takeout service for Google Photos actually strips all the metadata of an image/video into a separate JSON file. Google Photos 的 Takeout 服务实际上将图像/视频的所有元数据剥离到一个单独的 JSON 文件中。

This script that I'm working on helps me to merge the timestamp present in the JSON file into its subsequent photo or video.我正在处理的这个脚本帮助我将 JSON 文件中存在的时间戳合并到其后续照片或视频中。 In order to achieve this, I'm currently using - ExifTool by Phil Harvey , which is a Perl executable.为了实现这一点,我目前正在使用Phil Harvey 的 ExifTool ,它是一个 Perl 可执行文件。 I call this tool in a subprocess to edit the Date tags in EXIF/Metadata.我在子流程中调用此工具来编辑 EXIF/元数据中的日期标签。

This process is quite hefty and is taking a large amount of time.这个过程非常繁重,需要花费大量时间。 Then I realised that most of my photos are JPG and videos are MP4, it is very easy to edit Exif data of JPG files in python using some of the libraries present & for the lesser proportion of photos like PNG I can use exiftool.然后我意识到我的大部分照片是 JPG,视频是 MP4,使用现有的一些库很容易编辑 python 中 JPG 文件的 Exif 数据,对于较小比例的照片,如 PNG,我可以使用 exiftool。

This has drastically improved the runtime of my script.这极大地改善了我的脚本的运行时间。 Now I want to know that is there any way to edit the creation dates of MP4 files natively in python which can theoretically execute faster than the subprocess method.现在我想知道有什么方法可以在 python 中本地编辑 MP4 文件的创建日期,理论上可以比 subprocess 方法执行得更快。

Please help.请帮忙。 Thanks in advance.提前致谢。

Im not too familiar with it, but ffmpeg seems like an option for just the mp4's.我不太熟悉它,但 ffmpeg 似乎只是 mp4 的一个选项。

cmd = 'ffmpeg -i "file.mp4" -codec copy -metadata timestamp="new_time_here" "output.mp4"'
subprocess.call(shlex.split(cmd))

modified from: https://www.reddit.com/r/learnpython/comments/3yotj2/comment/cyfiyb7/?utm_source=share&utm_medium=web2x&context=3修改自: https://www.reddit.com/r/learnpython/comments/3yotj2/comment/cyfiyb7/?utm_source=share&utm_medium=web2x&context=3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM