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

标签 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 native 格式?

最佳答案

我需要以我的网络摄像头支持的 native 压缩运动 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 之前(输入)指示设备应使用的录制编解码器(我的网络摄像头 native 支持 mjpeg),-c:v (视频编解码器)在 -i 之后(input) 表示 ffmpeg 应该转换成什么录音编解码器。 copy不会更改编解码器,它只是复制设备提供的字节。

关于ffmpeg 在奶酪以 20 fps 录制的设备上每秒录制 5 帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44960632/

相关文章:

java - 如何读取进程 getInputstream?

database - 在哪里保存视频文件 - 数据库或磁盘

c++ - OpenCV VideoCapture IP 摄像机重新连接

windows - Windows 上用于视频捕获的 DirectShow 替代品

c++ - 两次调用 avformat_find_stream_info() 崩溃

ffmpeg - 结合两个 ffmpeg 命令

javascript - 找不到 ffmpeg 文件夹错误

c++ - 如何使用 ffmpeg 以便不需要将其 dll 包含在您的应用程序文件夹中?

iPhone 上的 Flutter Camera 插件风景视频

c++ - 直接显示 ISampleGrabber : samples are upside-down and color channels reverse