Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make ffmpeg insert timestamp in filename

Tags:

ffmpeg

I'm trying to make a bash script that grabs a still shot from an IP camera and than emails it.

Using

ffmpeg -i http://admin:[email protected]/Streaming/channels/1/picture \
  -f image2 -updatefirst 1 doorbell.jpg 

From what I have read this should work but the output file name is still doorbell.jpg How can I make the filename TIMESTAMPdoorbell.jpg?

like image 717
sealfab Avatar asked Jan 19 '16 18:01

sealfab


1 Answers

Use the "strftime" feature:

ffmpeg -i http://admin:[email protected]/Streaming/channels/1/picture -vframes 1 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S_doorbell.jpg"

"-vframes 1" will cause it to only process the first frame that it receives.

You can change the date/time format using a strftime compatible string: http://man7.org/linux/man-pages/man3/strftime.3.html

Further documentation/examples: https://www.ffmpeg.org/ffmpeg-formats.html#image2-2

like image 117
Brian Avatar answered Oct 15 '22 20:10

Brian