how do i find the date a video (.AVI .MP4) was act

2019-02-08 00:28发布

properties> date created... i thought this meant the date the video was created, but finally realized that date changes every time i move, reorganize, even open a file. often, the date modified is earlier than date created. the date a jpeg was taken is readily available. is there any way to get the same information from an AVI or MP4 FILE? thank you for any information you can give.

5条回答
Summer. ? 凉城
2楼-- · 2019-02-08 00:52

There doesn't seem to be a well defined standard for video metadata (compared to photos and audio files, which have EXIF and ID3/etc. respectively)

Some tags exists like e.g. Title, Composer etc. You can see those if you select a movie file in Windows 7 (perhaps earlier versions also) explorer or right click and view properties. I have not found a tag for recording date unfortunately - the closest thing available is Year (integer) :-(

Programatically, you can read and write most of these tags in .NET using Taglib Sharp from the mono project. Source and binaries are available on the banshee FTP server. It has a pretty impressive list of formats it supports (but still, make sure you catch exceptions when trying to read or write tags - it will throw whenever it finds a file it cannot understand, something which happened to me several times for my modest collection of home recordings.)

To read tags:

using (var f = TagLib.File.Create(@"c:\Path\To\MyVideo.mp4"))
{
    if (f.Tag != null)
    {
        string title = f.Tag.Title;
        Size resolution = new Size(f.Properties.VideoWidth, f.Properties.VideoHeight);
        int year = f.Tag.Year;
        // etc.
    }
}

And similarly, to write metadata back to the file:

using (var f = TagLib.File.Create(@"c:\Path\To\MyVideo.mp4"))
{
    f.Tag.Title = "My Awesome Movie";
    f.Tag.Year = (uint)2011;
    f.Save();
}
查看更多
聊天终结者
3楼-- · 2019-02-08 01:06

Have a try to exiftools or mediainfo, which provides you an export function as text. Just pay attention to daylight saving.

查看更多
Rolldiameter
4楼-- · 2019-02-08 01:06

The best way I found of getting the "dateTaken" date for either video or pictures is to use:

 Imports Microsoft.WindowsAPICodePack.Shell
 Imports Microsoft.WindowsAPICodePack.Shell.PropertySystem
 Imports System.IO
 Dim picture As ShellObject = ShellObject.FromParsingName(path)
 Dim picture As ShellObject = ShellObject.FromParsingName(path)
 Dim ItemDate=picture.Properties.System.ItemDate

The above code requires the shell api, which is internal to Microsoft, and does not depend on any other external dll.

查看更多
老娘就宠你
5楼-- · 2019-02-08 01:13

For me the mtime (modification time) is also earlier than the create date in a lot of (most) cases since, as you say, any reorganisation modifies the create time. However, the mtime AFAIUI is an accurate reflection of when the file contents were actually changed so should be an accurate record of video capture date.

After discovering this metadata failure for movie files, I am going to be renaming my videos based on their mtime so I have this stored in a more robust way!

查看更多
姐就是有狂的资本
6楼-- · 2019-02-08 01:14

The existence of that piece of metadata is entirely dependent on the application that wrote the file. It's very common to load up JPG files with metadata (EXIF tags) about the file, such as a timestamp or camera information or geolocation. ID3 tags in MP3 files are also very common. But it's a lot less common to see this kind of metadata in video files.

If you just need a tool to read this data from files manually, GSpot might do the trick: http://www.videohelp.com/tools/Gspot

If you want to read this in code then I imagine each container format is going to have its own standards and each one will take a bit of research and implementation to support.

查看更多
登录 后发表回答