1

I am using ffmpeg to record a video using a Raspberry Pi with its camera module. I would like to run a image classifier on a regular interval for which I need to extract a frame from the stream.

This is the command I currently use for recording:

$ ffmpeg -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 30 -i /dev/video0 -vcodec copy -an test.h264

In other threads this command is recommended:

ffmpeg -i file.mpg -r 1/1 $filename%03d.bmp

I don't think this is intended to be used with files that are still appended to and I get the error "Cannot use -sseof, duration of test.h264 not known".

Is there any way that ffmpeg allows this?

nilolo
  • 13
  • 2

1 Answers1

1

I don't have a Raspberry Pi set up with a camera at the moment to test with, but you should be able to simply append a second output stream to your original command, as follows to get, say, 1 frame/second of BMP images:

ffmpeg -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 30 -i /dev/video0 -vcodec copy -an test.h264 -r 1 frame-%03d.bmp
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432