我使用ffmpeg
进行屏幕录像,在 Mac OS X 上使用avfoundation
,在 Linux 上使用x11grab
和{{1 }}在 Windows 上。
生成的文件应与现代Web浏览器(gdigrab
)兼容,因此我使用H.264编解码器并请求YUV 4:2:0平面像素格式。
在 Mac OS X 上,(不同于 Linux 和 Windows ),我收到以下日志记录:
<video/>
根据/usr/local/bin/ffmpeg -y -v error -f avfoundation -threads 0 -hide_banner -i 1:none -f mp4 -vcodec h264 -pix_fmt yuv420p -r 25/1 -qscale:v 1 -vf scale=-1:1080 target.mp4
[avfoundation @ 0x7fdba2003a00] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation @ 0x7fdba2003a00] Supported pixel formats:
[avfoundation @ 0x7fdba2003a00] uyvy422
[avfoundation @ 0x7fdba2003a00] yuyv422
[avfoundation @ 0x7fdba2003a00] nv12
[avfoundation @ 0x7fdba2003a00] 0rgb
[avfoundation @ 0x7fdba2003a00] bgr0
,仍然如此,生成的MP4文件似乎具有YUV 4:2:0平面颜色模型:
mplayer
由[h264 @ 0x1048a8ac0]Format yuv420p chosen by get_format().
[h264 @ 0x1048a8ac0]Reinit context to 1728x1088, pix_fmt: yuv420p
[h264 @ 0x1048a8ac0]Format yuv420p chosen by get_format().
[h264 @ 0x1048a8ac0]Reinit context to 1728x1088, pix_fmt: yuv420p
[swscaler @ 0x1048c3cc0]bicubic scaler, from yuv420p to yuyv422 using MMXEXT
*** [scale] Exporting mp_image_t, 1728x1080x12bpp YUV planar, 2799360 bytes
*** [vo] Allocating mp_image_t, 1728x1080x16bpp YUV packed, 3732480 bytes
确认的相同内容:
ffmpeg
问题:
$ ffmpeg -i target.mp4 -hide_banner
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'target.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:00:04.72, start: 0.000000, bitrate: 201 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1728x1080, 197 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
日志记录吗?ffmpeg
视频流转换为avfoundation
,该如何进行动态转换(一次yuv420p
传递)?答案 0 :(得分:1)
avfoundation模块的像素格式默认设置为yuv420p。如果不可用,它将打印该警告并尝试选择其他格式。您应该在该警告下方看到一行Overriding selected pixel format to use ..
如果输出正常,则可以忽略。您不需要第二次通过或任何其他更改。