FFMPEG - Get creation and/or modification date
Asked Answered
S

5

5

I'm trying hard to get the modification date from a MP4 file hosted on my server.

I tried the following library:

ffmpeg -i video.mp4

Without any luck. All I get is duration and a few other fields but I'm not able to get modification date. I tried ffprobe as well and it is not there either.

Any suggestions??

Thanks a lot

Seavir answered 21/7, 2015 at 14:9 Comment(3)
Do you mean the unix mdate? Or a specific metadata field in the mp4 spec - in which case: which one? i.e. what is the four-letter code/tag of the metadata field?Boggers
I'm not sure about the format. I need it for the video metadata.Seavir
I thought I could get anything that comes with the file. Between all the metadata, there is always creation and modification date so I thought I could get it.Seavir
B
4

I checked for you, and indeed, mp4 has a modification time entry in the MDHD, but it's not exported (see code). You can file an enhancement request to get this metadata feature added to FFmpeg, but right now it won't help you and you'll need another tool to read this field.

Boggers answered 21/7, 2015 at 16:29 Comment(0)
A
22

Get creation_time with ffprobe:

ffprobe -v quiet input.mp4 -print_format json -show_entries stream=index,codec_type:stream_tags=creation_time:format_tags=creation_time

To view all tags:

ffprobe -v quiet input.mp4 -print_format json -show_entries stream_tags:format_tags

I can't find any reference to modification_time so consider using exiftool or mediainfo.

Anubis answered 21/7, 2015 at 14:58 Comment(4)
It says that -v is not an option for ffprobe, when I remove it, it says the same about -print_formatSeavir
You may be using an ancient version. I assure you the parameters are correct for the recent versions. Check ffmpeg.org/ffprobe.htmlAnubis
I didn't get creation_time in the output.Slothful
@RichardWiseman it'll only show it if it's present in the format metadataAnubis
J
7

A simpler alternative to aergistal in terms of output is

$ ffprobe -v quiet -select_streams v:0  -show_entries stream_tags=creation_time -of default=noprint_wrappers=1:nokey=1 input.mp4

which will just print the creation time like so:

2020-07-23T11:51:02.000000Z
Jeopardous answered 24/8, 2020 at 8:56 Comment(3)
This should be the accepted answer. (Not sure why the other answerer thought it was useful to print the result in JSON when the original question didn't specify that requirement.)Tachylyte
is there any way to get this as epoch timeHumphreys
This is simpler but also not necessarily working, unlike aergistal's suggestion. I have a file with several creation_time entries for different streams and this command only outputs one of them.Protonema
B
4

I checked for you, and indeed, mp4 has a modification time entry in the MDHD, but it's not exported (see code). You can file an enhancement request to get this metadata feature added to FFmpeg, but right now it won't help you and you'll need another tool to read this field.

Boggers answered 21/7, 2015 at 16:29 Comment(0)
R
1

The creation_time might be the wrong place to look at. I have a video that has both

"creation_time": "2022-08-11T03:01:40.000000Z",

and

"com.apple.quicktime.creationdate": "2022-08-10T12:18:23-0700"

and I know the 2022-08-10T12:18:23-0700 is the correct time.

Rickety answered 26/8, 2022 at 18:52 Comment(0)
D
0

If ffmpeg is not getting you the creation date metadata it simply may not be present in the file. The utility 'mediainfo' can show a lot more information, it may be worth investigating its output against your mp4s.

Destroy answered 21/7, 2015 at 14:59 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.