- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试将 YOLO
的结果保存到 .avi
文件中。已经看过this post ...(我什至在那里问过这个问题)我找不到任何解决方案。这是我试图保存 .avi
的代码。
{
CvSize size;
size.width = disp->width;
size.height = disp->height;
static CvVideoWriter* output_video = NULL; // cv::VideoWriter output_video;
if (output_video == NULL)
{
printf("\n SRC output_video = %p \n", output_video);
const char* output_name = "test_dnn_out.avi";
output_video = cvCreateVideoWriter(output_name, CV_FOURCC('D', 'I', 'V', 'X'), 25, size, 1);
printf("\n cvCreateVideoWriter, DST output_video = %p \n", output_video);
}
cvWriteFrame(output_video, disp);
}
尝试大量编解码器(更改 CV_FOURCC('D', 'I', 'V', 'X')
)我得到以下错误:
**CODEC :-1**
**ERROR**
SRC output_video = (nil) OpenCV: FFMPEG: tag 0xffffffff/'����' is not
found (format 'avi / AVI (Audio Video Interleaved)')' OpenCV Error:
Unsupported format or combination of formats (Gstreamer Opencv backend
does not support this codec.) in CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1522 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1522:
error: (-210) Gstreamer Opencv backend does not support this codec. in
function CvVideoWriter_GStreamer::open
**CODEC: CV_FOURCC('M', 'J', 'P', 'G')**
**ERROR**
SRC output_video = (nil) OpenCV Error: Unspecified error (GStreamer:
cannot put pipeline to play ) in CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1690 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690:
error: (-2) GStreamer: cannot put pipeline to play in function
CvVideoWriter_GStreamer::open
**CODEC: CV_FOURCC('P','I','M','1')** SRC output_video = (nil)
**ERROR**
** (Demo:6801): CRITICAL **: gst_ffmpeg_cfg_set_property: assertion 'qdata-
size == sizeof (gint64)' failed OpenCV Error: Unspecified
error (GStreamer: cannot put pipeline to play ) in
CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1690 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690:
error: (-2) GStreamer: cannot put pipeline to play in function
CvVideoWriter_GStreamer::open
**CODEC:CV_FOURCC('M', 'P', '4', '2')**
**ERROR**
SRC output_video = (nil)
** (Demo:7437): CRITICAL **: gst_ffmpeg_cfg_set_property: assertion 'qdata-
size == sizeof (gint64)' failed OpenCV Error: Unspecified
error (GStreamer: cannot put pipeline to play ) in
CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1690 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690:
error: (-2) GStreamer: cannot put pipeline to play in function
CvVideoWriter_GStreamer::open
**CODEC::CV_FOURCC('D', 'I', 'V', '3')**
**ERROR**
SRC output_video = (nil) OpenCV Error: Unspecified error (GStreamer:
cannot put pipeline to play ) in CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1690 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690:
error: (-2) GStreamer: cannot put pipeline to play in function
CvVideoWriter_GStreamer::open
**CODEC:CV_FOURCC('D', 'I', 'V', 'X')**
**ERROR**
SRC output_video = (nil) OpenCV Error: Unspecified error (GStreamer:
cannot put pipeline to play ) in CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1690 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690:
error: (-2) GStreamer: cannot put pipeline to play in function
CvVideoWriter_GStreamer::open
**CODEC:CV_FOURCC('U', '2', '6', '3')**
**ERROR**
OpenCV Error: Unspecified error (GStreamer: cannot put pipeline to
play ) in CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1690 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1690:
error: (-2) GStreamer: cannot put pipeline to play in function
CvVideoWriter_GStreamer::open
cvCreateVideoWriter, DST output_video = (nil)
SRC output_video = (nil) Could not open codec 'h263': Unspecified
error
** (Demo:8342): CRITICAL **: gst_ffmpeg_cfg_set_property: assertion 'qdata-
size == sizeof (gint64)' failed
**CODEC:CV_FOURCC('I', '2', '6', '3')**
**ERROR**
SRC output_video = (nil) Could not find encoder for codec id 21:
Encoder not found OpenCV Error: Unspecified error (GStreamer: cannot
link elements ) in CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1626 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1626:
error: (-2) GStreamer: cannot link elements in function
CvVideoWriter_GStreamer::open
cvCreateVideoWriter, DST output_video = (nil)
**CODEC:CV_FOURCC('F', 'L', 'V', '1')**
**ERROR**
SRC output_video = (nil) OpenCV Error: Unspecified error (GStreamer:
cannot link elements ) in CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1626 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1626:
error: (-2) GStreamer: cannot link elements in function
CvVideoWriter_GStreamer::open
cvCreateVideoWriter, DST output_video = (nil)
**CODEC:CV_FOURCC('i','Y', 'U', 'V')**
**ERROR**
SRC output_video = (nil) OpenCV: FFMPEG: tag 0x56555969/'iYUV' is not
supported with codec id 14 and format 'avi / AVI (Audio Video
Interleaved)' OpenCV Error: Unsupported format or combination of
formats (Gstreamer Opencv backend does not support this codec.) in
CvVideoWriter_GStreamer::open, file
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp, line
1522 VIDEOIO(cvCreateVideoWriter_GStreamer (filename, fourcc, fps,
frameSize, is_color)): raised OpenCV exception:
/home/akde/opencv-3.3.0/modules/videoio/src/cap_gstreamer.cpp:1522:
error: (-210) Gstreamer Opencv backend does not support this codec. in
function CvVideoWriter_GStreamer::open
这是我的设置
-ubuntu 16.04
-opencv 3.3.0
-ffmpeg 版本 2.8.14
在我看来,问题很可能与编解码器有关。因为人们通过使用不同的编解码器解决了同样的问题。尽管我尝试了很多编解码器并正确安装了 ffmepeg
,但我找不到任何解决方案。所以我该怎么做?期待您的回复...
最佳答案
你没有使用 ffmpeg 来创建视频,你应该首先检查,如果 OpenCV 是用 ffmpeg 构建的,正如@zindarod 指出的那样。为此,您可以在 C++ 中运行以下代码:
#include <opencv2/opencv.hpp>
int main(void)
{
std::cout << cv::getBuildInformation() << std::endl;
}
还有一件事,除非必要,否则不要使用 C API。它已被弃用,不应使用,特别是如果您的代码如您问题的标签所建议的那样使用 C++。
在 C++ API 中,您实际上可以选择不同的后端。查看 documentation of VideoWriter 。
cv::VideoWriter::VideoWriter ( const String & filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor = true )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The apiPreference parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.
这意味着,如果两者都已安装并且 OpenCV 是在两者的支持下构建的,您可以根据自己的喜好切换它:)
GStreamer 是一个不错的后端,我实际上使用它,但我更多地使用它来打开视频而不是创建视频,但是你需要安装插件才能使其与更多编解码器一起使用... gstreamer webpage建议这样安装:
apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools
1.0 可能会根据您已经使用的版本而变化。
我希望这能解决您的问题,如果不能发表评论的话。
关于c++ - 在 OpenCV FOURCC 编解码器中写入视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51514532/
我正在尝试为 uint32_t 类型定义一个 .natvis ,以显示为一个包含四个字符的数组,在调试期间,在 Watch 窗口中,它会被表示为一点像这样:(char*)&fourcc,4。 不幸的是
fourcc = cv2.VideoWriter_fourcc('X','2','6','4') AttributeError: 'module' object has no attribute 'V
我在项目中使用适用于 Android 的 OpenCV 3.1 库来处理图像并基于多个单独的 OpenCv::Mat 编译视频文件。 我的问题是找到正确的 fourCC 代码。使用“MJPG”在 Go
我正在尝试将 YOLO 的结果保存到 .avi 文件中。已经看过this post ...(我什至在那里问过这个问题)我找不到任何解决方案。这是我试图保存 .avi 的代码。 { CvSize
我需要根据一系列图像编写视频。我正在使用这段代码: int main() { //Read sequence of images Size frameSize(1360,1024);
我想设置一个FourCC C++ 中的值,即一个无符号的 4 字节整数。 我想最明显的方法是#define,例如 #define FOURCC(a,b,c,d) ( (uint32) (((d) st
这似乎是一个太简单的问题, 但我没有成功获得它: 我在解码流和访问数据方面没有问题。 但我还需要比特率和流的类型。 AVCodecContext 成员使用的比特率和编解码器 bit_rate 和 co
我正在尝试重新编码fourcc V210 (这是一个打包的 YUV4:2:2 格式)到 P010 (平面 YUV4:2:0)。我想我已经按照规范实现了它,但是渲染器给出了错误的图像,所以有些东西是关闭
我正在使用 RIFFCHUNK 结构,声明(在“外部”模块中)为(引用 MMSystem 和 DirectShow9): type FOURCC = DWORD;
我有一个 Delphi 6 应用程序,要求用户使用 AVISaveOptions() 选择音频和视频压缩器。然后,我将每个选择的 FOURCC ID 存储在数据文件中。我想使用属于每个压缩器/过滤器的
这是我在运行 Raspbian Buster 的 Raspberry Pi 4 上录制视频的代码: fourcc = cv2.VideoWriter_fourcc(*'MJPG') writer =
我是 python (2.7) 和 opencv (3.0)(以及一般的视频流/写作)的新手,所以请原谅。 我使用 logitech c920 作为我的网络摄像头,它可以流式传输以 h264 格式压缩
我是一名优秀的程序员,十分优秀!