Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Name ffmpeg generated images using timestamp rather than sequential numbers

As far as I can tell from the ffmpeg docs, they don't provide a way to use timestamps in the filename rather than sequential numbers. What they provide allows you to create 0001.jpg, 0002.jpg, 0003.jpg but not 2011-08-01 7:30:00.jpg, 2011-08-01 7:30:01.jpg, 2011-08-01 7:30:02.jpg. Can anyone think of a solution that could take the sequentially named files from ffmpeg and name them using their created time?

like image 731
weotch Avatar asked Oct 20 '25 14:10

weotch


1 Answers

At least the newer versions of ffmpeg have the strftime option that allow you to do what you want.

For example:

ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg"

Will generate files such as:

2015-11-20_16-25-06.jpg
like image 62
guilleuy Avatar answered Oct 23 '25 07:10

guilleuy