Zend certified PHP/Magento developer

FFmpeg Record videos every second and save them in individual files

I am trying to create video every one second. I have the following code below.

It creates the first video correctly but the following does not create them correctly. Anyone know what I may be missing, it would be a great help.

ffmpeg -f v4l2 -input_format mjpeg -video_size 1280x720 -i /dev/video0 -r 30 -b:v 3M -c:v h264_v4l2m2m -pix_fmt yuv420p -f segment -segment_time 1 output%03d.mp4 -y