Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to record video and audio frames using ffmpeg

Tags:

ffmpeg

How to record video and audio in a separate files for every 40ms continuously upto 10 seconds from webcam using FFMPEG?

Thanks.

like image 607
VijayR Avatar asked May 11 '26 00:05

VijayR


1 Answers

Step 1: Webcam Capture

As already mentioned in the comments follow this instructions for audio capturing. How can I capture audio AND video simultenaous with ffmpeg from a linux USB capture device
We start with his:

./ffmpeg -f alsa -i hw:0 -f video4linux2 -i /dev/video0

More details are explained in the FFmpeg documentation.

Step 2: Segmentation

./ffmpeg -f alsa -i hw:0 -f video4linux2 -i /dev/video0 -t 0:10 -segment_time 00:00.040 -f segment out_%003d.mp4
  • -t 0:10 records only for 10 seconds
  • -segment_time 00:00.040 split every 40 milliseconds
  • -f segment use a segmented format
  • out_%03d.mp4 output file name template (%03d is used for a better formatting; 001, 002, 003 and so on)

Again here's the link to the FFmpeg documentation for segmentation.

like image 121
martinr92 Avatar answered May 20 '26 00:05

martinr92



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!