简体   繁体   English

在 OpenCV 中使用 High profile 从 high profile mp4 文件中编写 H.264 视频

[英]Writing a video with H.264 in OpenCV with High profile from a high profile mp4 file

I have High profile mp4 video i am using opencv to overlay some text inside but output.mp4 is writing in simple profile format.我有 High profile mp4 视频,我正在使用 opencv 在里面覆盖一些文本,但 output.mp4 正在以简单的配置文件格式编写。 is there a way to write it in high profile I am using opencv 3.4.16 latest有没有办法高调写出来我用的是opencv 3.4.16 latest

Devlopment platform is: Windows C++ VS2019开发平台为:Windows C++ VS2019

VideoWriter videocc(destFile, VideoWriter::fourcc('M', 'P', '4', 'V'), fps, cv::Size(width, height)); VideoWriter videocc(destFile, VideoWriter::fourcc('M', 'P', '4', 'V'), fps, cv::Size(width, height));

I have tried X264, H264,AVC1 in fourcc, But not writing in high profile我在fourcc中试过X264,H264,AVC1,但是写的不是high profile

Is there a way or sample available to generate high profile output video format有没有一种方法或示例可用于生成高配置文件 output 视频格式

please find the following attachment for main profile coded problem请找到以下附件以了解主要配置文件编码问题

在此处输入图像描述

I tried using AVC1 as the fourCC code (as suggested by Rackwitz) and also set the environment variable:我尝试使用 AVC1 作为 fourCC 代码(如 Rackwitz 所建议的那样)并设置了环境变量:

export OPENCV_FFMPEG_WRITER_OPTIONS="vcodec;x264|vprofile;high|vlevel;4.0"

To verify that the H264 codec and high profile was used, I checked using ffprobe为了验证是否使用了 H264 编解码器和 high profile,我使用ffprobe进行了检查

It worked prefectly.它工作得很好。

  • OS Ubuntu 18.04操作系统 Ubuntu 18.04
  • OpenCV 3.4.14 OpenCV 3.4.14
  • FFMPEG 3.4.8 FFMPEG 3.4.8

You would need to pass parameters through OpenCV, to ffmpeg and libx264.您需要通过 OpenCV 将参数传递给 ffmpeg 和 libx264。

As far as I can tell from official documentation, OpenCV doesn't support that.据我从官方文档中可以看出,OpenCV 不支持。

However , the source contains access to the environment variable OPENCV_FFMPEG_WRITER_OPTIONS但是,源包含对环境变量OPENCV_FFMPEG_WRITER_OPTIONS的访问

You should be able to pass parameters like you would give them to ffmpeg, except the syntax is a little weird (semicolon between key and value, pipe between pairs).应该能够像将参数传递给 ffmpeg 一样传递参数,除了语法有点奇怪(键和值之间的分号,对之间的 pipe)。

Here is some talk of such facilities:以下是有关此类设施的一些讨论:

You should pass avc1 as fourcc.您应该将avc1作为fourcc 传递。 AFAIK that's the fourcc defined by standards. AFAIK 那是标准定义的fourcc。 It does not however guarantee that you get libx264, only that you get some encoder for AVC.但是,它不能保证您获得 libx264,只能保证您获得一些 AVC 编码器。

I've opened an issue for this .为此打开了一个问题 Documentation issues are always a nice way for newbies to get their feet wet contributing to an open source project.对于新手来说,文档问题总是一种很好的方式来为开源项目做出贡献。

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

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