简体   繁体   English

如何使用 ffmpeg 录制视频和音频帧

[英]How to record video and audio frames using ffmpeg

How to record video and audio in a separate files for every 40ms continuously upto 10 seconds from webcam using FFMPEG?如何使用 FFMPEG 从网络摄像头连续每 40 毫秒在单独的文件中录制视频和音频,最长 10 秒?

Thanks.谢谢。

Step 1: Webcam Capture第 1 步:网络摄像头捕获

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 如何使用 ffmpeg 从 linux USB 捕获设备同时捕获音频和视频
We start with his:我们从他的开始:

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

More details are explained in the FFmpeg documentation . FFmpeg 文档中解释了更多详细信息。

Step 2: Segmentation第 2 步:细分

./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 -t 0:10只记录 10 秒
  • -segment_time 00:00.040 split every 40 milliseconds -segment_time 00:00.040每 40 毫秒拆分一次
  • -f segment use a segmented format -f segment使用分段格式
  • out_%03d.mp4 output file name template ( %03d is used for a better formatting; 001, 002, 003 and so on) out_%03d.mp4 output 文件名模板( %03d 03d 用于更好的格式;001、002、003 等)

Again here's the link to the FFmpeg documentation for segmentation .同样,这里是FFmpeg 文档的链接,用于分段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM