start time of video on Garmin VFAT camera

Nils Kassube kassube at gmx.net
Fri Jan 22 13:09:19 UTC 2016


Adam Funk wrote:
> On 2016-01-20, Nils Kassube wrote:
> > 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.

No, it isn't really clever because it wouldn't work, sorry. When I read 
it again in your reply, I spotted a bug: My original script from which I 
stole the code, changed to the input directory before the loop. When I 
adopted the code for your purpose, I added the "/input/path/" which is 
wrong as it would still be included in the output file name.

> I understand how it works although I probably
> couldn't have come up with something that short on my own.

Well, that is the result of "several" modifications of the script ... it 
was much longer and more complicated in the beginning. :)

> 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

Hmm, I didn't realise that you only needed the date/time as the new file 
name - that would make the loop even shorter.


Nils





More information about the ubuntu-users mailing list