1

I tried saving image from my webcam, since strftime in ffmpeg 4.2.2 does not provide microseconds, to avoid overwriting the image in the same seconds, I plan to use both strftime and sequence number.

ffmpeg -i /dev/video0 -f image2 "%04d.jpg"

gives 0001.jpg, 0002.jpg

ffmpeg -i /dev/video0 -f image2 -strftime 1 "%F_%H-%M-%S.jpg"

gives 2020-07-25_01-02-03.jpg, 2020-07-25_01-02-04.jpg ...

ffmpeg -i /dev/video0 -f image2 "%F_%H-%M-%S_%%04d.jpg"

gives 2020-07-25_01-02-03_%04d.jpg, 2020-07-25_01-02-04_%04d.jpg ...

I would expect the %%04d will be replaced with numbers, but it does not. Is there any other solution?

1 Answer 1

0

I belive the command you entered, look like this:

ffmpeg -i /dev/video0 -f image2 "$(date +"%Y_%m_%d_%I_%M_%%d").jpg"

According to manpage date command can give you a nanoseconds (not microseconds). Use following command as a possible solution:

ffmpeg -i /dev/video0 -f image2 "$(date +"%Y_%m_%d_%I_%M_%S_%N").jpg

2
  • Thanks for the answer. Inject the date by shell command will cause all filename saved using the same date that the command first start. What I am going to achieve is naming the filename at the moment of saving. Commented Jul 25, 2020 at 15:20
  • I didn't get the question right. FFMpeg can use strftime c++ function for output filename. But strftime function can't show microseconsds or similair value (cplusplus.com/reference/ctime/strftime). All I can afford is to use frame number ("%04d.jpg"). It seems you cant combine strftime 1` and standart filename pattern.
    – anex5
    Commented Jul 25, 2020 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .