How to get the original file date from a video file?

Hi, I want to get the real file date from a video file taken with an Iphone.
Unfortunately it is not possible to preserve the original file dates of Images and Videos when you transfer them from your Iphone to your computer.
You always get the date and the time of the transfer and not the original date and time from the creation of the file.
So I managed to get the CreationDate fron the exif data of images, but this doesn’t work with video files.
I know there are matadata within the video files and within them there is also the original creation date.
But I was not able to get this date from the metadata.
How do I get it using Xojo?

Desktop or iOS?
Impossible on desktop- the data of the original is transformed into a brand new file when you export it elsewhere. That transformation date is what you get.

On the iPhone itself, however, it may be possible.

In swift:

let attrs = try NSFileManager.defaultManager().attributesOfItemAtPath(path) as NSDictionary
attrs.fileCreationDate()

Desktop
If I’m using VLC, I can see the real CreateDate of the file.
So there has to be a way to extract these data from the file.

Fair enough. Maybe MBS has something.

AVMetadataItemMBS ?

If you provide a 2 or 3 seconds video file (taken from your iPhone, of course), some people may have food to work with… :innocent:

That’ll be this one:
https://www.vacationx.de/transfer/2023-05-15_20-41-38_IMG_3217.mov
The date in the name is correct, but the time is not.
In VLC under media information it shows me the correct time: “2023-05-15T13:36:18+0100”.
I’m currently writing an application which renames our images and videos taken on vacation to {DATE}{TIME}-{ORIGINAL_NAME}.
It’s working with images taken with my sony cameras, but not with photos taken with smartphones.
In this case it’s the iphone.
I don’t want to pay for plug ins, because this is a strictly private project.
I’m not making any money out of this.

Information found at the end of the file:
iPhone 14 Pro
data
16.4.1
0
(data
2023-05-15T13:36:18+0100

You may try to (on a copy of the file) open the file as binary, load the last (say) 512 bytes (or 256 ?) ;
display the whole as Hex.

Check with many files if the information is always located at the same place, then code your method to return only the relevant informationfrom the end of the file.

In the Xojo Blog, there is an article that is related to what you want to do:

Of course, this does not works because it deals with images… You have to search in the Apple documentation (Video):

seems to do what you want.

2 Likes

Here’s code and hex representation of the end of your example video file:


Var source As FolderItem

source = SpecialFolder.Documents.Parent.Child("Downloads")
source = source.Child("Video")
source = source.Child("2023-05-15_20-41-38_IMG_3217 copie.mov")

Var Video_BS As BinaryStream
Var Video_MB As New MemoryBlock(512)

Video_BS = BinaryStream.Open(source, False) // Open as read-only

Video_BS.BytePosition = Video_BS.Length - 512
Video_MB = Video_BS.Read(512)
Break // Allows you to read as hex the data

Hi @Emile_Schwarz ,
this looks pretty great.
I did a new search for older threads in the forum.
This time I used “quicktime metadata” instead of “video metadata”.
As a result there was an older post about the cli application mediainfo.
It delivers the metadata as json.
I guess I have a more universal approach getting the meta data fron video files using mediainfo.
Reading Hexdata from a file always comes with the risk, that Apple (or any other vendor) changes the specification or the location within the file.
If this happens, i have to rewrite the method to get the metadata.

I would like to embed the mediainfo binary into the application.
Now i need a way to execute it out of my application using shell.
It would be easy if it was somewhere in the filesystem, but I have no idea how to do it from within the application.
Do you have a solution for that as well?

AVMetaDataItemMBS provides me with this:

Bear in mind that the time shown is based on my timezone, rather than your timezone.

Hi @James_Pitchford ,
I completely understand, that the MBS-Plugins would do the job.
For me it’s just not worth it to buy the complete set of plugins to use just this function.
I’m using Xojo only to write some helper applications which are only used by me.
For this, even Xojo is too expensive because I haven’t earned a single cent with it.
So I have to use workarounds to solve the problem.

To do that, simply drag the file into the navigation pane (left area). At (run in the IDE and) compile time, the dropped file is embedded in the application.

How to use it is a different beast as I do not have an idea on that subject. Sorry.

Got it…

Var m As FolderItem = SpecialFolder.Resource("mediainfo")
App.mediainfo = m

Var s As New Shell
s.Backend = "bash"
s.Execute("chmod 755 " + app.mediainfo.ShellPath)
System.DebugLog(s.Result)
s.Execute(app.mediainfo.ShellPath + " --help")
System.DebugLog(s.Result)
1 Like