ffmpeg在奶酪以20 fps记录的设备上每秒记录5帧

时间:2017-07-07 00:11:11

标签: ffmpeg video-capture

在我内置的网络摄像头上运行以下ffmpeg捕获:

ffmpeg -f v4l2 -framerate 30 -video_size 1920x1080 -i /dev/video0 output.mkv

我只得到5 fps并看到此消息:

The driver changed the time per frame from 1/30 to 1/5

当我使用奶酪录制时,我会在该设备上获得20 fps的内容。 v4l2似乎声称它可以做到30 fps。

v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : Motion-JPEG
        Size: Discrete 1920x1080
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 800x600
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 160x120
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUYV 4:2:2
        Size: Discrete 1920x1080
            Interval: Discrete 0.200s (5.000 fps)
        Size: Discrete 1280x720
            Interval: Discrete 0.100s (10.000 fps)
        Size: Discrete 800x600
            Interval: Discrete 0.050s (20.000 fps)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 640x360
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 160x120
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 320x240
            Interval: Discrete 0.033s (30.000 fps)
        Size: Discrete 640x480
            Interval: Discrete 0.033s (30.000 fps)

当我运行ffmpeg时:

Output #0, mjpeg, to 'output.mjpg':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: mjpeg, yuvj422p(pc), 1920x1080, q=2-31, 200 kb/s, 5 fps, 5 tbn, 5 tbc
    Metadata:
      encoder         : Lavc56.60.100 mjpeg

我猜测它是从设备以原始形式录制并在ffmpeg中进行编码。如果这是正确的,我如何让ffmpeg使用mjpeg原生格式?

1 个答案:

答案 0 :(得分:1)

我需要以我的网络摄像头支持的本机压缩运动jpeg格式进行录制。配置完成后(见下文),它以全分辨率以30 fps记录。

ffmpeg -f v4l2 -framerate 30 -video_size 1920x1080 -c:v mjpeg -i /dev/video0 -c:v copy output.mov

注意-c:v(视频编解码器)之前-i(输入)指示设备应使用的录制编解码器(我的网络摄像头本机支持mjpeg)和-c:v (视频编解码器)-i(输入)后指示ffmpeg应转换为哪个录制编解码器。 copy不会更改编解码器,它只是复制设备提供的字节。