How can I restore file timestamps of video recordings using the embedded metadata? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionRename multiple files with spaces and prepending a number to the filenames in bashHow to recursively synchronize file timestamps across servers?Pull Metadata from a video in the terminalHow can I reverse a video clip?How can I list the available video modes for my screen?Using File Date/Time as Metadata: Reliable?Is there a way to know percentage of images and code in a given directory?find original video if you have a short clip from itCLI Tool to extract images from video slideshowHow to transition smoothly and repeatedly between two videos using command line tools?Evaluate the similarity between two video files
I am having problem understanding the behavior of below code in JavaScript
How can I reduce the gap between left and right of cdot with a macro?
AppleTVs create a chatty alternate WiFi network
Question about debouncing - delay of state change
Time to Settle Down!
What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?
How does the secondary effect of the Heat Metal spell interact with a creature resistant/immune to fire damage?
Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
Crossing US/Canada Border for less than 24 hours
Is CEO the "profession" with the most psychopaths?
How does Python know the values already stored in its memory?
How would a mousetrap for use in space work?
How often does castling occur in grandmaster games?
How do living politicians protect their readily obtainable signatures from misuse?
Effects on objects due to a brief relocation of massive amounts of mass
Why is the AVR GCC compiler using a full `CALL` even though I have set the `-mshort-calls` flag?
Is there any word for a place full of confusion?
Why should I vote and accept answers?
Illegal assignment from sObject to Id
Project Euler #1 in C++
Is it a good idea to use CNN to classify 1D signal?
Morning, Afternoon, Night Kanji
How could we fake a moon landing now?
How can I restore file timestamps of video recordings using the embedded metadata?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionRename multiple files with spaces and prepending a number to the filenames in bashHow to recursively synchronize file timestamps across servers?Pull Metadata from a video in the terminalHow can I reverse a video clip?How can I list the available video modes for my screen?Using File Date/Time as Metadata: Reliable?Is there a way to know percentage of images and code in a given directory?find original video if you have a short clip from itCLI Tool to extract images from video slideshowHow to transition smoothly and repeatedly between two videos using command line tools?Evaluate the similarity between two video files
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm looking for a command that will read the metadata of a ‘*.mp4
’ file and touch the file's timestamp with the creation time of the video. The command should be read-only with respect to the file contents, i.e. hashing the file before and after should yield the same result.
Situation: I made the mistake of moving pictures and videos from the internal storage of my phone to an SD card using Android's stock tool to do so (‘Settings’ → ‘Storage’ → ‘Transfer data to SD card’). Unfortunately, this bumped the timestamps of all of the files, and also messed around with directories other than DCIM/
(pictures and videos were also moved from the Download/
, image/
, Pictures/
, and video/
directories). In hindsight it seems silly that I used such a tool (I'd normally use Ghost Commander), but it appeared as a notification when running low on space and it just looked so easy. I'm now trying to piece back together the timestamps of various pictures and videos.
I'm effectively looking for a video equivalent to the following command, which I used to sort out the images in DCIM/100ANDRO/
:
exiv2 -T mv *.JPG
I skimmed through some FFmpeg documentation, but I see no mention of read-only commands or printing timestamps.
(Unfortunately for my situation, this approach does not offer a solution for files I didn't create, such as those in Download/
, for which I want to appear in the media collection in chronological order of when I obtained them.)
files video command timestamps
add a comment |
I'm looking for a command that will read the metadata of a ‘*.mp4
’ file and touch the file's timestamp with the creation time of the video. The command should be read-only with respect to the file contents, i.e. hashing the file before and after should yield the same result.
Situation: I made the mistake of moving pictures and videos from the internal storage of my phone to an SD card using Android's stock tool to do so (‘Settings’ → ‘Storage’ → ‘Transfer data to SD card’). Unfortunately, this bumped the timestamps of all of the files, and also messed around with directories other than DCIM/
(pictures and videos were also moved from the Download/
, image/
, Pictures/
, and video/
directories). In hindsight it seems silly that I used such a tool (I'd normally use Ghost Commander), but it appeared as a notification when running low on space and it just looked so easy. I'm now trying to piece back together the timestamps of various pictures and videos.
I'm effectively looking for a video equivalent to the following command, which I used to sort out the images in DCIM/100ANDRO/
:
exiv2 -T mv *.JPG
I skimmed through some FFmpeg documentation, but I see no mention of read-only commands or printing timestamps.
(Unfortunately for my situation, this approach does not offer a solution for files I didn't create, such as those in Download/
, for which I want to appear in the media collection in chronological order of when I obtained them.)
files video command timestamps
For sorting out the images and videos inDownload/
, I've asked a related question on Android Enthusiasts: How do I retrieve timestamps from my Firefox download history?
– James Haigh
Feb 24 '14 at 16:23
add a comment |
I'm looking for a command that will read the metadata of a ‘*.mp4
’ file and touch the file's timestamp with the creation time of the video. The command should be read-only with respect to the file contents, i.e. hashing the file before and after should yield the same result.
Situation: I made the mistake of moving pictures and videos from the internal storage of my phone to an SD card using Android's stock tool to do so (‘Settings’ → ‘Storage’ → ‘Transfer data to SD card’). Unfortunately, this bumped the timestamps of all of the files, and also messed around with directories other than DCIM/
(pictures and videos were also moved from the Download/
, image/
, Pictures/
, and video/
directories). In hindsight it seems silly that I used such a tool (I'd normally use Ghost Commander), but it appeared as a notification when running low on space and it just looked so easy. I'm now trying to piece back together the timestamps of various pictures and videos.
I'm effectively looking for a video equivalent to the following command, which I used to sort out the images in DCIM/100ANDRO/
:
exiv2 -T mv *.JPG
I skimmed through some FFmpeg documentation, but I see no mention of read-only commands or printing timestamps.
(Unfortunately for my situation, this approach does not offer a solution for files I didn't create, such as those in Download/
, for which I want to appear in the media collection in chronological order of when I obtained them.)
files video command timestamps
I'm looking for a command that will read the metadata of a ‘*.mp4
’ file and touch the file's timestamp with the creation time of the video. The command should be read-only with respect to the file contents, i.e. hashing the file before and after should yield the same result.
Situation: I made the mistake of moving pictures and videos from the internal storage of my phone to an SD card using Android's stock tool to do so (‘Settings’ → ‘Storage’ → ‘Transfer data to SD card’). Unfortunately, this bumped the timestamps of all of the files, and also messed around with directories other than DCIM/
(pictures and videos were also moved from the Download/
, image/
, Pictures/
, and video/
directories). In hindsight it seems silly that I used such a tool (I'd normally use Ghost Commander), but it appeared as a notification when running low on space and it just looked so easy. I'm now trying to piece back together the timestamps of various pictures and videos.
I'm effectively looking for a video equivalent to the following command, which I used to sort out the images in DCIM/100ANDRO/
:
exiv2 -T mv *.JPG
I skimmed through some FFmpeg documentation, but I see no mention of read-only commands or printing timestamps.
(Unfortunately for my situation, this approach does not offer a solution for files I didn't create, such as those in Download/
, for which I want to appear in the media collection in chronological order of when I obtained them.)
files video command timestamps
files video command timestamps
edited Feb 24 '14 at 3:59
James Haigh
asked Feb 24 '14 at 2:44
James HaighJames Haigh
379513
379513
For sorting out the images and videos inDownload/
, I've asked a related question on Android Enthusiasts: How do I retrieve timestamps from my Firefox download history?
– James Haigh
Feb 24 '14 at 16:23
add a comment |
For sorting out the images and videos inDownload/
, I've asked a related question on Android Enthusiasts: How do I retrieve timestamps from my Firefox download history?
– James Haigh
Feb 24 '14 at 16:23
For sorting out the images and videos in
Download/
, I've asked a related question on Android Enthusiasts: How do I retrieve timestamps from my Firefox download history?– James Haigh
Feb 24 '14 at 16:23
For sorting out the images and videos in
Download/
, I've asked a related question on Android Enthusiasts: How do I retrieve timestamps from my Firefox download history?– James Haigh
Feb 24 '14 at 16:23
add a comment |
4 Answers
4
active
oldest
votes
Thanks to Warren for informing me about the mediainfo
command in his partial answer.
I managed to construct a command that achieved the restoration of timestamps. It loops over the applicable files, and for each file, mediainfo
reads the metadata, grep
and sed
select and format the timestamp, and touch
applies it.
for file in *.mp4; do touch -t "$(mediainfo "$file" | grep -m 1 'Tagged date' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
The ‘select and format’ part could no doubt be a lot shorter/better; it looks cumbersome to me but I'm not fluent with regexs. Nevertheless, the command worked perfectly. I think I've quoted everything correctly, so it should work with any filename. It may not work if mediainfo
outputs a different format but it's easily adaptable.
For example, here is a regex that correctly matches both the format of output from my *.mp4
files such as UTC 2013-11-15 11:36:06
, and additionally the format of Warren's example of 2014-2-23T09:00:00Z
from my.mov
:
's/-/-0/g; s/.*([0-9]4)-0?([0-9]2)-0?([0-9]2)[T ]([0-9]2):([0-9]2):([0-9]2).*/12345.6/'
And apart from mediainfo
which I actually had to install manually due to it not being in my distro's repositories (though it looks like newer releases now package it), it should be fairly portable and useful to others if they encounter a similar problem.
Note: Remember to check timezones. According to the GNU info
pages, touch
, date
, and other GNU utilities use the TZ
environment variable if set and the ‘system default rules’ otherwise. To see the timezone offset that'll be used, issue:
date +%:::z
To change it, set the TZ
environment variable:
export TZ="UTC0"
If the video's timestamps are correct, and are correctly represented (i.e. the time value w.r.t. the timezone represents the correct point in time), then you should make sure that date +%:::z
outputs the matching offset for the timestamp's timezone before running touch -t
over those files (as above). Use stat
to check the files, as it shows the time offset (like date +%:::z
).
@Warren: Sorry! I've made a few too many tiny mistakes in critical places in the last few days! :- Probably a bit sleep deprived. Zz;-/
– James Haigh
Feb 24 '14 at 11:46
add a comment |
You can use MediaInfo for that:
$ mediainfo my.mov | grep 'Recorded date'
Recorded date : 2014-2-23T09:00:00Z
Getting from that date format to a touch
command should be a small matter of programming. Personally, I'd use Perl's Date::Manip
module for this. It can almost cope with the above format; it requires 2-digit months with zero padding to understand this particular date format. Fixing that only requires a trivial regexp, which is of course easy in Perl.
$ perl -M'Date::Manip' -e 'print ParseDate("2014-02-23T09:00:00Z")'
2014022302:00:00
The fact that it prints shows that it's parsing. If you drop the 0
, you'll see that it doesn't print anything, because ParseDate()
returns undef
.
Sorry about mistakenly writing*.MOV
in my question. They were actuallyMOV_####.mp4
files and I mis-remembered the extension. Thank you for informing me aboutmediainfo
, it was just the kind of tool I was looking for and I couldn't have solved this until I found such a tool. I have posted a complete solution.
– James Haigh
Feb 24 '14 at 10:22
Or to express it as a regex (seeing as I've been messing with them quite a bit on this problem), ‘MOV_[0-9]4.mp4
files’!
– James Haigh
Feb 24 '14 at 10:30
Btw., did you have a ‘Tagged date
’ field in your output? I didn't see a ‘Recorded date
’ field in mine, so I wonder if ‘Tagged date
’ would be more ubiquitous. I also had an ‘Encoded date
’ field, but although they were identical in this instance, I chose ‘Tagged date
’ because I assumed that tagging occurs after encoding so it would thus be closer to the modified time I was trying to restore if they were to be different.
– James Haigh
Feb 24 '14 at 10:53
My experience with this sort of problem is that your script may have to cope with many different date sources. MP4 — which actually derives from QuickTime, so the*.mov
distinction probably doesn't matter — is complicated enough that there may be multiple ways to guess a recording date from any given file. Programmers being programmers, different video encoders are going to provide different sets of these fields.
– Warren Young
Feb 24 '14 at 11:35
Thankfully in my case, all of the videos that I'd created on my phone were recordings from the camera so had the same format. My downloaded videos aren't applicable to this method because I want to restore the time of download. (I know that Firefox has the timestamps stored within its application data, probably to beyond second precision, but I haven't yet managed to retrieve it.) Anyway, the reason I was asking was just to try to make my answer a bit more useful to others.
– James Haigh
Feb 24 '14 at 11:58
add a comment |
Follow James' advice above for MP4 and most QuickTime files. For AVI files, mediainfo
will output Mastered date
but the format is mostly un-parseable. Install ffmpeg
to get ffprobe
(also known as avprobe
) then use:
for file in *.avi; do touch -t "$(ffprobe "$file" 2>&1 | grep -m 1 'creation_time' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
Note the mod before piping to grep
. This is because ffprobe
uses stderr not stdout.
add a comment |
exiftool:
exiftool "-CreateDate>FileModifyDate" FILES or FOLDERS
The name of the value you want may differ according to file format and other factors. Use below to print them:
exiftool -time:all -s FILE
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f116628%2fhow-can-i-restore-file-timestamps-of-video-recordings-using-the-embedded-metadat%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to Warren for informing me about the mediainfo
command in his partial answer.
I managed to construct a command that achieved the restoration of timestamps. It loops over the applicable files, and for each file, mediainfo
reads the metadata, grep
and sed
select and format the timestamp, and touch
applies it.
for file in *.mp4; do touch -t "$(mediainfo "$file" | grep -m 1 'Tagged date' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
The ‘select and format’ part could no doubt be a lot shorter/better; it looks cumbersome to me but I'm not fluent with regexs. Nevertheless, the command worked perfectly. I think I've quoted everything correctly, so it should work with any filename. It may not work if mediainfo
outputs a different format but it's easily adaptable.
For example, here is a regex that correctly matches both the format of output from my *.mp4
files such as UTC 2013-11-15 11:36:06
, and additionally the format of Warren's example of 2014-2-23T09:00:00Z
from my.mov
:
's/-/-0/g; s/.*([0-9]4)-0?([0-9]2)-0?([0-9]2)[T ]([0-9]2):([0-9]2):([0-9]2).*/12345.6/'
And apart from mediainfo
which I actually had to install manually due to it not being in my distro's repositories (though it looks like newer releases now package it), it should be fairly portable and useful to others if they encounter a similar problem.
Note: Remember to check timezones. According to the GNU info
pages, touch
, date
, and other GNU utilities use the TZ
environment variable if set and the ‘system default rules’ otherwise. To see the timezone offset that'll be used, issue:
date +%:::z
To change it, set the TZ
environment variable:
export TZ="UTC0"
If the video's timestamps are correct, and are correctly represented (i.e. the time value w.r.t. the timezone represents the correct point in time), then you should make sure that date +%:::z
outputs the matching offset for the timestamp's timezone before running touch -t
over those files (as above). Use stat
to check the files, as it shows the time offset (like date +%:::z
).
@Warren: Sorry! I've made a few too many tiny mistakes in critical places in the last few days! :- Probably a bit sleep deprived. Zz;-/
– James Haigh
Feb 24 '14 at 11:46
add a comment |
Thanks to Warren for informing me about the mediainfo
command in his partial answer.
I managed to construct a command that achieved the restoration of timestamps. It loops over the applicable files, and for each file, mediainfo
reads the metadata, grep
and sed
select and format the timestamp, and touch
applies it.
for file in *.mp4; do touch -t "$(mediainfo "$file" | grep -m 1 'Tagged date' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
The ‘select and format’ part could no doubt be a lot shorter/better; it looks cumbersome to me but I'm not fluent with regexs. Nevertheless, the command worked perfectly. I think I've quoted everything correctly, so it should work with any filename. It may not work if mediainfo
outputs a different format but it's easily adaptable.
For example, here is a regex that correctly matches both the format of output from my *.mp4
files such as UTC 2013-11-15 11:36:06
, and additionally the format of Warren's example of 2014-2-23T09:00:00Z
from my.mov
:
's/-/-0/g; s/.*([0-9]4)-0?([0-9]2)-0?([0-9]2)[T ]([0-9]2):([0-9]2):([0-9]2).*/12345.6/'
And apart from mediainfo
which I actually had to install manually due to it not being in my distro's repositories (though it looks like newer releases now package it), it should be fairly portable and useful to others if they encounter a similar problem.
Note: Remember to check timezones. According to the GNU info
pages, touch
, date
, and other GNU utilities use the TZ
environment variable if set and the ‘system default rules’ otherwise. To see the timezone offset that'll be used, issue:
date +%:::z
To change it, set the TZ
environment variable:
export TZ="UTC0"
If the video's timestamps are correct, and are correctly represented (i.e. the time value w.r.t. the timezone represents the correct point in time), then you should make sure that date +%:::z
outputs the matching offset for the timestamp's timezone before running touch -t
over those files (as above). Use stat
to check the files, as it shows the time offset (like date +%:::z
).
@Warren: Sorry! I've made a few too many tiny mistakes in critical places in the last few days! :- Probably a bit sleep deprived. Zz;-/
– James Haigh
Feb 24 '14 at 11:46
add a comment |
Thanks to Warren for informing me about the mediainfo
command in his partial answer.
I managed to construct a command that achieved the restoration of timestamps. It loops over the applicable files, and for each file, mediainfo
reads the metadata, grep
and sed
select and format the timestamp, and touch
applies it.
for file in *.mp4; do touch -t "$(mediainfo "$file" | grep -m 1 'Tagged date' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
The ‘select and format’ part could no doubt be a lot shorter/better; it looks cumbersome to me but I'm not fluent with regexs. Nevertheless, the command worked perfectly. I think I've quoted everything correctly, so it should work with any filename. It may not work if mediainfo
outputs a different format but it's easily adaptable.
For example, here is a regex that correctly matches both the format of output from my *.mp4
files such as UTC 2013-11-15 11:36:06
, and additionally the format of Warren's example of 2014-2-23T09:00:00Z
from my.mov
:
's/-/-0/g; s/.*([0-9]4)-0?([0-9]2)-0?([0-9]2)[T ]([0-9]2):([0-9]2):([0-9]2).*/12345.6/'
And apart from mediainfo
which I actually had to install manually due to it not being in my distro's repositories (though it looks like newer releases now package it), it should be fairly portable and useful to others if they encounter a similar problem.
Note: Remember to check timezones. According to the GNU info
pages, touch
, date
, and other GNU utilities use the TZ
environment variable if set and the ‘system default rules’ otherwise. To see the timezone offset that'll be used, issue:
date +%:::z
To change it, set the TZ
environment variable:
export TZ="UTC0"
If the video's timestamps are correct, and are correctly represented (i.e. the time value w.r.t. the timezone represents the correct point in time), then you should make sure that date +%:::z
outputs the matching offset for the timestamp's timezone before running touch -t
over those files (as above). Use stat
to check the files, as it shows the time offset (like date +%:::z
).
Thanks to Warren for informing me about the mediainfo
command in his partial answer.
I managed to construct a command that achieved the restoration of timestamps. It loops over the applicable files, and for each file, mediainfo
reads the metadata, grep
and sed
select and format the timestamp, and touch
applies it.
for file in *.mp4; do touch -t "$(mediainfo "$file" | grep -m 1 'Tagged date' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
The ‘select and format’ part could no doubt be a lot shorter/better; it looks cumbersome to me but I'm not fluent with regexs. Nevertheless, the command worked perfectly. I think I've quoted everything correctly, so it should work with any filename. It may not work if mediainfo
outputs a different format but it's easily adaptable.
For example, here is a regex that correctly matches both the format of output from my *.mp4
files such as UTC 2013-11-15 11:36:06
, and additionally the format of Warren's example of 2014-2-23T09:00:00Z
from my.mov
:
's/-/-0/g; s/.*([0-9]4)-0?([0-9]2)-0?([0-9]2)[T ]([0-9]2):([0-9]2):([0-9]2).*/12345.6/'
And apart from mediainfo
which I actually had to install manually due to it not being in my distro's repositories (though it looks like newer releases now package it), it should be fairly portable and useful to others if they encounter a similar problem.
Note: Remember to check timezones. According to the GNU info
pages, touch
, date
, and other GNU utilities use the TZ
environment variable if set and the ‘system default rules’ otherwise. To see the timezone offset that'll be used, issue:
date +%:::z
To change it, set the TZ
environment variable:
export TZ="UTC0"
If the video's timestamps are correct, and are correctly represented (i.e. the time value w.r.t. the timezone represents the correct point in time), then you should make sure that date +%:::z
outputs the matching offset for the timestamp's timezone before running touch -t
over those files (as above). Use stat
to check the files, as it shows the time offset (like date +%:::z
).
edited Feb 24 '14 at 14:14
answered Feb 24 '14 at 10:14
James HaighJames Haigh
379513
379513
@Warren: Sorry! I've made a few too many tiny mistakes in critical places in the last few days! :- Probably a bit sleep deprived. Zz;-/
– James Haigh
Feb 24 '14 at 11:46
add a comment |
@Warren: Sorry! I've made a few too many tiny mistakes in critical places in the last few days! :- Probably a bit sleep deprived. Zz;-/
– James Haigh
Feb 24 '14 at 11:46
@Warren: Sorry! I've made a few too many tiny mistakes in critical places in the last few days! :- Probably a bit sleep deprived. Zz;-/
– James Haigh
Feb 24 '14 at 11:46
@Warren: Sorry! I've made a few too many tiny mistakes in critical places in the last few days! :- Probably a bit sleep deprived. Zz;-/
– James Haigh
Feb 24 '14 at 11:46
add a comment |
You can use MediaInfo for that:
$ mediainfo my.mov | grep 'Recorded date'
Recorded date : 2014-2-23T09:00:00Z
Getting from that date format to a touch
command should be a small matter of programming. Personally, I'd use Perl's Date::Manip
module for this. It can almost cope with the above format; it requires 2-digit months with zero padding to understand this particular date format. Fixing that only requires a trivial regexp, which is of course easy in Perl.
$ perl -M'Date::Manip' -e 'print ParseDate("2014-02-23T09:00:00Z")'
2014022302:00:00
The fact that it prints shows that it's parsing. If you drop the 0
, you'll see that it doesn't print anything, because ParseDate()
returns undef
.
Sorry about mistakenly writing*.MOV
in my question. They were actuallyMOV_####.mp4
files and I mis-remembered the extension. Thank you for informing me aboutmediainfo
, it was just the kind of tool I was looking for and I couldn't have solved this until I found such a tool. I have posted a complete solution.
– James Haigh
Feb 24 '14 at 10:22
Or to express it as a regex (seeing as I've been messing with them quite a bit on this problem), ‘MOV_[0-9]4.mp4
files’!
– James Haigh
Feb 24 '14 at 10:30
Btw., did you have a ‘Tagged date
’ field in your output? I didn't see a ‘Recorded date
’ field in mine, so I wonder if ‘Tagged date
’ would be more ubiquitous. I also had an ‘Encoded date
’ field, but although they were identical in this instance, I chose ‘Tagged date
’ because I assumed that tagging occurs after encoding so it would thus be closer to the modified time I was trying to restore if they were to be different.
– James Haigh
Feb 24 '14 at 10:53
My experience with this sort of problem is that your script may have to cope with many different date sources. MP4 — which actually derives from QuickTime, so the*.mov
distinction probably doesn't matter — is complicated enough that there may be multiple ways to guess a recording date from any given file. Programmers being programmers, different video encoders are going to provide different sets of these fields.
– Warren Young
Feb 24 '14 at 11:35
Thankfully in my case, all of the videos that I'd created on my phone were recordings from the camera so had the same format. My downloaded videos aren't applicable to this method because I want to restore the time of download. (I know that Firefox has the timestamps stored within its application data, probably to beyond second precision, but I haven't yet managed to retrieve it.) Anyway, the reason I was asking was just to try to make my answer a bit more useful to others.
– James Haigh
Feb 24 '14 at 11:58
add a comment |
You can use MediaInfo for that:
$ mediainfo my.mov | grep 'Recorded date'
Recorded date : 2014-2-23T09:00:00Z
Getting from that date format to a touch
command should be a small matter of programming. Personally, I'd use Perl's Date::Manip
module for this. It can almost cope with the above format; it requires 2-digit months with zero padding to understand this particular date format. Fixing that only requires a trivial regexp, which is of course easy in Perl.
$ perl -M'Date::Manip' -e 'print ParseDate("2014-02-23T09:00:00Z")'
2014022302:00:00
The fact that it prints shows that it's parsing. If you drop the 0
, you'll see that it doesn't print anything, because ParseDate()
returns undef
.
Sorry about mistakenly writing*.MOV
in my question. They were actuallyMOV_####.mp4
files and I mis-remembered the extension. Thank you for informing me aboutmediainfo
, it was just the kind of tool I was looking for and I couldn't have solved this until I found such a tool. I have posted a complete solution.
– James Haigh
Feb 24 '14 at 10:22
Or to express it as a regex (seeing as I've been messing with them quite a bit on this problem), ‘MOV_[0-9]4.mp4
files’!
– James Haigh
Feb 24 '14 at 10:30
Btw., did you have a ‘Tagged date
’ field in your output? I didn't see a ‘Recorded date
’ field in mine, so I wonder if ‘Tagged date
’ would be more ubiquitous. I also had an ‘Encoded date
’ field, but although they were identical in this instance, I chose ‘Tagged date
’ because I assumed that tagging occurs after encoding so it would thus be closer to the modified time I was trying to restore if they were to be different.
– James Haigh
Feb 24 '14 at 10:53
My experience with this sort of problem is that your script may have to cope with many different date sources. MP4 — which actually derives from QuickTime, so the*.mov
distinction probably doesn't matter — is complicated enough that there may be multiple ways to guess a recording date from any given file. Programmers being programmers, different video encoders are going to provide different sets of these fields.
– Warren Young
Feb 24 '14 at 11:35
Thankfully in my case, all of the videos that I'd created on my phone were recordings from the camera so had the same format. My downloaded videos aren't applicable to this method because I want to restore the time of download. (I know that Firefox has the timestamps stored within its application data, probably to beyond second precision, but I haven't yet managed to retrieve it.) Anyway, the reason I was asking was just to try to make my answer a bit more useful to others.
– James Haigh
Feb 24 '14 at 11:58
add a comment |
You can use MediaInfo for that:
$ mediainfo my.mov | grep 'Recorded date'
Recorded date : 2014-2-23T09:00:00Z
Getting from that date format to a touch
command should be a small matter of programming. Personally, I'd use Perl's Date::Manip
module for this. It can almost cope with the above format; it requires 2-digit months with zero padding to understand this particular date format. Fixing that only requires a trivial regexp, which is of course easy in Perl.
$ perl -M'Date::Manip' -e 'print ParseDate("2014-02-23T09:00:00Z")'
2014022302:00:00
The fact that it prints shows that it's parsing. If you drop the 0
, you'll see that it doesn't print anything, because ParseDate()
returns undef
.
You can use MediaInfo for that:
$ mediainfo my.mov | grep 'Recorded date'
Recorded date : 2014-2-23T09:00:00Z
Getting from that date format to a touch
command should be a small matter of programming. Personally, I'd use Perl's Date::Manip
module for this. It can almost cope with the above format; it requires 2-digit months with zero padding to understand this particular date format. Fixing that only requires a trivial regexp, which is of course easy in Perl.
$ perl -M'Date::Manip' -e 'print ParseDate("2014-02-23T09:00:00Z")'
2014022302:00:00
The fact that it prints shows that it's parsing. If you drop the 0
, you'll see that it doesn't print anything, because ParseDate()
returns undef
.
answered Feb 24 '14 at 3:47
Warren YoungWarren Young
56.2k11144148
56.2k11144148
Sorry about mistakenly writing*.MOV
in my question. They were actuallyMOV_####.mp4
files and I mis-remembered the extension. Thank you for informing me aboutmediainfo
, it was just the kind of tool I was looking for and I couldn't have solved this until I found such a tool. I have posted a complete solution.
– James Haigh
Feb 24 '14 at 10:22
Or to express it as a regex (seeing as I've been messing with them quite a bit on this problem), ‘MOV_[0-9]4.mp4
files’!
– James Haigh
Feb 24 '14 at 10:30
Btw., did you have a ‘Tagged date
’ field in your output? I didn't see a ‘Recorded date
’ field in mine, so I wonder if ‘Tagged date
’ would be more ubiquitous. I also had an ‘Encoded date
’ field, but although they were identical in this instance, I chose ‘Tagged date
’ because I assumed that tagging occurs after encoding so it would thus be closer to the modified time I was trying to restore if they were to be different.
– James Haigh
Feb 24 '14 at 10:53
My experience with this sort of problem is that your script may have to cope with many different date sources. MP4 — which actually derives from QuickTime, so the*.mov
distinction probably doesn't matter — is complicated enough that there may be multiple ways to guess a recording date from any given file. Programmers being programmers, different video encoders are going to provide different sets of these fields.
– Warren Young
Feb 24 '14 at 11:35
Thankfully in my case, all of the videos that I'd created on my phone were recordings from the camera so had the same format. My downloaded videos aren't applicable to this method because I want to restore the time of download. (I know that Firefox has the timestamps stored within its application data, probably to beyond second precision, but I haven't yet managed to retrieve it.) Anyway, the reason I was asking was just to try to make my answer a bit more useful to others.
– James Haigh
Feb 24 '14 at 11:58
add a comment |
Sorry about mistakenly writing*.MOV
in my question. They were actuallyMOV_####.mp4
files and I mis-remembered the extension. Thank you for informing me aboutmediainfo
, it was just the kind of tool I was looking for and I couldn't have solved this until I found such a tool. I have posted a complete solution.
– James Haigh
Feb 24 '14 at 10:22
Or to express it as a regex (seeing as I've been messing with them quite a bit on this problem), ‘MOV_[0-9]4.mp4
files’!
– James Haigh
Feb 24 '14 at 10:30
Btw., did you have a ‘Tagged date
’ field in your output? I didn't see a ‘Recorded date
’ field in mine, so I wonder if ‘Tagged date
’ would be more ubiquitous. I also had an ‘Encoded date
’ field, but although they were identical in this instance, I chose ‘Tagged date
’ because I assumed that tagging occurs after encoding so it would thus be closer to the modified time I was trying to restore if they were to be different.
– James Haigh
Feb 24 '14 at 10:53
My experience with this sort of problem is that your script may have to cope with many different date sources. MP4 — which actually derives from QuickTime, so the*.mov
distinction probably doesn't matter — is complicated enough that there may be multiple ways to guess a recording date from any given file. Programmers being programmers, different video encoders are going to provide different sets of these fields.
– Warren Young
Feb 24 '14 at 11:35
Thankfully in my case, all of the videos that I'd created on my phone were recordings from the camera so had the same format. My downloaded videos aren't applicable to this method because I want to restore the time of download. (I know that Firefox has the timestamps stored within its application data, probably to beyond second precision, but I haven't yet managed to retrieve it.) Anyway, the reason I was asking was just to try to make my answer a bit more useful to others.
– James Haigh
Feb 24 '14 at 11:58
Sorry about mistakenly writing
*.MOV
in my question. They were actually MOV_####.mp4
files and I mis-remembered the extension. Thank you for informing me about mediainfo
, it was just the kind of tool I was looking for and I couldn't have solved this until I found such a tool. I have posted a complete solution.– James Haigh
Feb 24 '14 at 10:22
Sorry about mistakenly writing
*.MOV
in my question. They were actually MOV_####.mp4
files and I mis-remembered the extension. Thank you for informing me about mediainfo
, it was just the kind of tool I was looking for and I couldn't have solved this until I found such a tool. I have posted a complete solution.– James Haigh
Feb 24 '14 at 10:22
Or to express it as a regex (seeing as I've been messing with them quite a bit on this problem), ‘
MOV_[0-9]4.mp4
files’!– James Haigh
Feb 24 '14 at 10:30
Or to express it as a regex (seeing as I've been messing with them quite a bit on this problem), ‘
MOV_[0-9]4.mp4
files’!– James Haigh
Feb 24 '14 at 10:30
Btw., did you have a ‘
Tagged date
’ field in your output? I didn't see a ‘Recorded date
’ field in mine, so I wonder if ‘Tagged date
’ would be more ubiquitous. I also had an ‘Encoded date
’ field, but although they were identical in this instance, I chose ‘Tagged date
’ because I assumed that tagging occurs after encoding so it would thus be closer to the modified time I was trying to restore if they were to be different.– James Haigh
Feb 24 '14 at 10:53
Btw., did you have a ‘
Tagged date
’ field in your output? I didn't see a ‘Recorded date
’ field in mine, so I wonder if ‘Tagged date
’ would be more ubiquitous. I also had an ‘Encoded date
’ field, but although they were identical in this instance, I chose ‘Tagged date
’ because I assumed that tagging occurs after encoding so it would thus be closer to the modified time I was trying to restore if they were to be different.– James Haigh
Feb 24 '14 at 10:53
My experience with this sort of problem is that your script may have to cope with many different date sources. MP4 — which actually derives from QuickTime, so the
*.mov
distinction probably doesn't matter — is complicated enough that there may be multiple ways to guess a recording date from any given file. Programmers being programmers, different video encoders are going to provide different sets of these fields.– Warren Young
Feb 24 '14 at 11:35
My experience with this sort of problem is that your script may have to cope with many different date sources. MP4 — which actually derives from QuickTime, so the
*.mov
distinction probably doesn't matter — is complicated enough that there may be multiple ways to guess a recording date from any given file. Programmers being programmers, different video encoders are going to provide different sets of these fields.– Warren Young
Feb 24 '14 at 11:35
Thankfully in my case, all of the videos that I'd created on my phone were recordings from the camera so had the same format. My downloaded videos aren't applicable to this method because I want to restore the time of download. (I know that Firefox has the timestamps stored within its application data, probably to beyond second precision, but I haven't yet managed to retrieve it.) Anyway, the reason I was asking was just to try to make my answer a bit more useful to others.
– James Haigh
Feb 24 '14 at 11:58
Thankfully in my case, all of the videos that I'd created on my phone were recordings from the camera so had the same format. My downloaded videos aren't applicable to this method because I want to restore the time of download. (I know that Firefox has the timestamps stored within its application data, probably to beyond second precision, but I haven't yet managed to retrieve it.) Anyway, the reason I was asking was just to try to make my answer a bit more useful to others.
– James Haigh
Feb 24 '14 at 11:58
add a comment |
Follow James' advice above for MP4 and most QuickTime files. For AVI files, mediainfo
will output Mastered date
but the format is mostly un-parseable. Install ffmpeg
to get ffprobe
(also known as avprobe
) then use:
for file in *.avi; do touch -t "$(ffprobe "$file" 2>&1 | grep -m 1 'creation_time' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
Note the mod before piping to grep
. This is because ffprobe
uses stderr not stdout.
add a comment |
Follow James' advice above for MP4 and most QuickTime files. For AVI files, mediainfo
will output Mastered date
but the format is mostly un-parseable. Install ffmpeg
to get ffprobe
(also known as avprobe
) then use:
for file in *.avi; do touch -t "$(ffprobe "$file" 2>&1 | grep -m 1 'creation_time' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
Note the mod before piping to grep
. This is because ffprobe
uses stderr not stdout.
add a comment |
Follow James' advice above for MP4 and most QuickTime files. For AVI files, mediainfo
will output Mastered date
but the format is mostly un-parseable. Install ffmpeg
to get ffprobe
(also known as avprobe
) then use:
for file in *.avi; do touch -t "$(ffprobe "$file" 2>&1 | grep -m 1 'creation_time' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
Note the mod before piping to grep
. This is because ffprobe
uses stderr not stdout.
Follow James' advice above for MP4 and most QuickTime files. For AVI files, mediainfo
will output Mastered date
but the format is mostly un-parseable. Install ffmpeg
to get ffprobe
(also known as avprobe
) then use:
for file in *.avi; do touch -t "$(ffprobe "$file" 2>&1 | grep -m 1 'creation_time' | sed -r 's/.*([0-9]4)-([0-9]2)-([0-9]2) ([0-9]2):([0-9]2):([0-9]2).*/12345.6/')" "$file"; done
Note the mod before piping to grep
. This is because ffprobe
uses stderr not stdout.
answered Oct 14 '15 at 6:24
Glenn BatuyongGlenn Batuyong
11
11
add a comment |
add a comment |
exiftool:
exiftool "-CreateDate>FileModifyDate" FILES or FOLDERS
The name of the value you want may differ according to file format and other factors. Use below to print them:
exiftool -time:all -s FILE
add a comment |
exiftool:
exiftool "-CreateDate>FileModifyDate" FILES or FOLDERS
The name of the value you want may differ according to file format and other factors. Use below to print them:
exiftool -time:all -s FILE
add a comment |
exiftool:
exiftool "-CreateDate>FileModifyDate" FILES or FOLDERS
The name of the value you want may differ according to file format and other factors. Use below to print them:
exiftool -time:all -s FILE
exiftool:
exiftool "-CreateDate>FileModifyDate" FILES or FOLDERS
The name of the value you want may differ according to file format and other factors. Use below to print them:
exiftool -time:all -s FILE
answered Apr 14 at 18:09
Gringo SuaveGringo Suave
1113
1113
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f116628%2fhow-can-i-restore-file-timestamps-of-video-recordings-using-the-embedded-metadat%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
For sorting out the images and videos in
Download/
, I've asked a related question on Android Enthusiasts: How do I retrieve timestamps from my Firefox download history?– James Haigh
Feb 24 '14 at 16:23