简体   繁体   English

FFMPEG + V4L2 选项

[英]FFMPEG + V4L2 OPTIONS

I am looking for a way to integrate the parameters of v4l2-ctl on ffmpeg the problem what ffmpeg overwrite v4l2-ctl and I need specific parameter has v4l2-ctl :( my v4l2-ctl commands is :我正在寻找一种将 v4l2-ctl 的参数集成到 ffmpeg 上的方法 ffmpeg 覆盖 v4l2-ctl 的问题,我需要特定参数有 v4l2-ctl :( 我的 v4l2-ctl 命令是:

v4l2-ctl -v width=640,height=480,pixelformat=4 -p 30 -c h264_profile=0,repeat_sequence_header=1 v4l2-ctl -v width=640,height=480,pixelformat=4 -p 30 -c h264_profile=0,repeat_sequence_header=1

I want to use these parameters to then stream directly with FFMPEG how can I do ?我想使用这些参数直接使用 FFMPEG 进行流式传输,我该怎么办?

Thanks !谢谢 !

You can tell FFmpeg to use video4linux2 (v4l2) as an input "device" ( which it treats like a demuxer ).您可以告诉 FFmpeg 使用 video4linux2 (v4l2) 作为输入“设备”(它像解复用器一样对待它)。 Depending on your device, v4l2 can provide video in several different formats (for example, raw video like yuv420p, or compressed video like h264, possibly via a hardware accelerator).根据您的设备,v4l2 可以提供多种不同格式的视频(例如,像 yuv420p 这样的原始视频,或者像 h264 这样的压缩视频,可能通过硬件加速器)。 It looks like you are trying to use h264, so you are probably looking for something along these lines:看起来您正在尝试使用 h264,因此您可能正在寻找以下方面的内容:

ffmpeg -f video4linux2 -input_format h264 -video_size 640x480 -framerate 30 -i /dev/video0 out.h264

FFmpeg will tell v4l2 to provide an h264-encoded stream with the given framerate and size as an input to ffmpeg, which will copy the stream into the file out.h264 . FFmpeg 将告诉 v4l2 提供具有给定帧速率和大小的 h264 编码流作为 ffmpeg 的输入,ffmpeg 会将流复制到文件out.h264中。 You will need to specify your output format and options depending on your use case.您需要根据用例指定输出格式和选项。

Note: this assumes your input device is /dev/video0 .注意:这假设您的输入设备是/dev/video0 You can use v4l2-ctl --list-devices to see which devices are available.您可以使用v4l2-ctl --list-devices查看哪些设备可用。

It is not clear from the ffmpeg documentation for v4l2 how to provide additional flags (such as h264_profile and repeat_sequence_header ) to v4l2.从 v4l2 的ffmpeg 文档中不清楚如何为 v4l2提供附加标志(例如h264_profilerepeat_sequence_header )。 FFmpeg does provide a multitude of options for encoding, but those may require you to specify a raw video -input_format from v4l2 and use FFmpeg's x264 encoder instead, which could be much slower than a hardware encoder. FFmpeg 确实提供了多种编码选项,但这些选项可能需要您从 v4l2 指定原始视频-input_format并改用 FFmpeg 的 x264 编码器,这可能比硬件编码器慢得多。

Disclaimer: this question probably belongs on Super User or Video Production rather than Stack Overflow, since it only deals with the command-line tool.免责声明:这个问题可能属于超级用户或视频制作而不是 Stack Overflow,因为它只处理命令行工具。

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

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