使用YUV 4:2:0平面色彩模型在Mac OS X上进行ffmpeg屏幕截图 [英] Making a ffmpeg screen capture on Mac OS X using YUV 4:2:0 Planar color model

查看:141
本文介绍了使用YUV 4:2:0平面色彩模型在Mac OS X上进行ffmpeg屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ffmpeg Mac OS X 上使用 avfoundation ,在上使用 x11grab 进行屏幕录像 Windows 上的Linux gdigrab .

生成的文件应与现代Web浏览器(< video/> )兼容,因此我使用H.264编解码器并请求YUV 4:2:0平面像素格式.

Mac OS X 上,(不同于 Linux Windows ),我收到以下日志记录:

 /usr/local/bin/ffmpeg -y -v错误-f avfoundation-线程0 -hide_banner -i 1:无-f mp4 -vcodec h264 -pix_fmt yuv420p -r 25/1 -qscale:v1 -vf scale = -1:1080 target.mp4[avfoundation @ 0x7fdba2003a00]输入设备不支持所选的像素格式(yuv420p).[avfoundation @ 0x7fdba2003a00]支持的像素格式:[avfoundation @ 0x7fdba2003a00] uyvy422[avfoundation @ 0x7fdba2003a00] yuyv422[avfoundation @ 0x7fdba2003a00] nv12[avfoundation @ 0x7fdba2003a00] 0rgb[avfoundation @ 0x7fdba2003a00] bgr0 

不过,据 mplayer 称,生成的MP4文件似乎具有YUV 4:2:0平面颜色模型:

  [h264 @ 0x1048a8ac0]格式化yuv420p,由get_format()选择.[h264 @ 0x1048a8ac0]将上下文重新初始化为1728x1088,pix_fmt:yuv420p[h264 @ 0x1048a8ac0]格式化yuv420p,由get_format()选择.[h264 @ 0x1048a8ac0]将上下文重新初始化为1728x1088,pix_fmt:yuv420p[swscaler @ 0x1048c3cc0]使用MMXEXT从yuv420p到yuyv422的双立方缩放器*** [scale]汇出mp_image_t,1728x1080x12bpp YUV平面,2799360位元组*** [vo]分配mp_image_t,打包为1728x1080x16bpp YUV,3732480字节 

ffmpeg 确认的相同内容:

  $ ffmpeg -i target.mp4 -hide_banner从'target.mp4'输入#0,mov,mp4,m4a,3gp,3g2,mj2:元数据:major_brand:isomminor_version:512兼容品牌:isomiso2avc1mp41编码器:Lavf58.20.100持续时间:00:00:04.72,开始:0.000000,比特率:201 kb/s流#0:0(und):视频:h264(高)(avc1/0x31637661),yuv420p,1728x1080、197 kb/s,25 fps,25 tbr,12800 tbn,50 tbc(默认)元数据:handler_name:VideoHandler 

问题:

  1. 有人可以解释上面的 ffmpeg 日志记录吗?
  2. 如果我仍然需要将 avfoundation 视频流转换为 yuv420p ,我该如何即时制作(在单个 ffmpeg 中通过)?

解决方案

avfoundation模块的像素格式默认设置为yuv420p.如果不可用,它将打印该警告并尝试选择其他格式.您应该在该警告下方看到一行,以覆盖所选像素格式以使用..

开头

如果输出正常,则可以忽略.您不需要第二次通过或任何其他更改.

I make screen recordings with ffmpeg, using avfoundation on Mac OS X, x11grab on Linux and gdigrab on Windows.

The resulting files should be compatible with modern web browsers (<video/>), so I use H.264 codec and request YUV 4:2:0 Planar pixel format.

On Mac OS X, however (unlike Linux and Windows), I receive the following logging:

/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

Still, according to mplayer, the resulting MP4 file seems to have YUV 4:2:0 Planar color model:

[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

the same confirmed by 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

Questions:

  1. Can someone explain the above ffmpeg logging?
  2. If I still need to convert the avfoundation video stream to yuv420p, how do I make it on the fly (in a single ffmpeg pass)?

解决方案

The avfoundation module has its pixel format default set to yuv420p. When not available, it will print that warning and attempt to select another format. You should see a line below that warning starting with Overriding selected pixel format to use ..

If the output's fine, this can be ignored. You don't need a second pass or any other change.

这篇关于使用YUV 4:2:0平面色彩模型在Mac OS X上进行ffmpeg屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆