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

3
  • 1
    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? Jul 21, 2015 at 14:35
  • I'm not sure about the format. I need it for the video metadata. Jul 21, 2015 at 14:54
  • 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. Jul 21, 2015 at 14:56

5 Answers 5

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.

4
  • It says that -v is not an option for ffprobe, when I remove it, it says the same about -print_format Jul 22, 2015 at 7:32
  • 1
    You may be using an ancient version. I assure you the parameters are correct for the recent versions. Check ffmpeg.org/ffprobe.html
    – aergistal
    Jul 22, 2015 at 8:05
  • 2
    I didn't get creation_time in the output.
    – IpsRich
    Jun 26, 2019 at 13:18
  • 1
    @RichardWiseman it'll only show it if it's present in the format metadata
    – aergistal
    Jun 26, 2019 at 13:52
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
2
  • 1
    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.)
    – Raleigh L.
    Jun 25, 2022 at 2:36
  • is there any way to get this as epoch time
    – ihsan
    Dec 23, 2022 at 12:44
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.

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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.