start time of video on Garmin VFAT camera

Adam Funk a24061 at ducksburg.com
Fri Jan 22 12:08:36 UTC 2016


On 2016-01-20, Nils Kassube wrote:

> Adam Funk wrote:
>> I have a Garmin video camera that plays nicely with Ubuntu as a USB
>> device with a VFAT filesystem.  It records files with sequential
>> numbers, e.g.,
>> 
>> VIRB0123.MP4
>> VIRB0124.MP4
>> VIRB0125.MP4
>
>> What I want to do now is write something in bash or python to copy
>> files off the camera but rename the destination file to include the
>> start time of the recording.  From looking at the `stat` output on the
>> files, I get the impression that the "change" timestamp could well be
>> when the recording started & the "modify" one could be when it
>> finished.  Has anyone else corroborated this sort of thing?

Doh!  I checked the GPX files that the camera records at the same time
in another directory (but confusingly, with unrelated filenames).  My
impression about the timestamps was right.


> This should do the trick:
>
> for f in /input/path/*.MP4;do
>   n="${f%.MP4}-$(date -d @$(stat -c %X "$f") +%m%d%H%M)"
>   echo "$f" "/output/path/$n.MP4"
> done
>
> Replace the "/input/path/" and "/output/path/" accordingly. This version 
> only shows the filames - if everything is OK, you can replace the "echo" 
> with "cp" or "mv". Do you need some explanation how it works?

That's terse & clever.  I understand how it works although I probably
couldn't have come up with something that short on my own.  As it
happens, I'm probably going to write something in Python to read the
timestamps and use them with some command-line arguments to call
ffmpeg to cut down the file & rename it, along these lines.

my_command -s 3:50 -t 30 -o /output/directory VIRB0123.MP4

-->

ffmpeg -ss 3:50 -i VIRB0123.MP4 -t 30 -vcodec copy -acodec copy 2016-01-10-0850.mp4





More information about the ubuntu-users mailing list