[英]Reading video files with OpenCV VideoCapture
I am having trouble being able top open any video files in OpenCV besides those encoded in MJPEG. 除了以MJPEG编码的视频文件之外,我无法在OpenCV中打开任何视频文件。
I have installed OpenCV using this script (which should compile OpenCV with support for ffmpeg) and an testing using the sample provided here . 我已经使用此脚本安装了OpenCV(应使用ffmpeg的支持编译OpenCV)并使用此处提供的示例进行测试。
When running with a h264 encoded video I get: 当使用h264编码的视频运行时,我得到:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x123ed80] multiple edit list entries, a/v desync might occur, patch welcome
[h264 @ 0x12465e0] A non-intra slice in an IDR NAL unit.
[h264 @ 0x12465e0] decode_slice_header error
Could not open the output video for write: test.mp4
When running with an MPEG-2 encoded video I get: 当以MPEG-2编码的视频运行时,我得到:
[mpegts @ 0x1e92d80] PES packet size mismatch
[mpegts @ 0x1e92d80] PES packet size mismatch
[mpegts @ 0x1e92d80] max_analyze_duration reached
[mpegts @ 0x1e92d80] PES packet size mismatch
Could not open the output video for write: test.mpeg
I am running x64 Ubuntu 12.04. 我正在运行x64 Ubuntu 12.04。
EDIT: I tried OpenCV 2.4.8 on a Ubuntu 13.10 x86 VM, ffmpeg
works fine, however the sample code still fails, this time with the following error: 编辑:我在Ubuntu 13.10 x86 VM上尝试过OpenCV 2.4.8, ffmpeg
可以正常工作,但是示例代码仍然失败,这次出现以下错误:
[h264 @ 0x849ff40] A non-intra slice in an IDR NAL unit.
[h264 @ 0x849ff40] decode_slice_header error
Could not find encoder for codec id 28: Encoder not foundOpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend doesn't support this codec acutally.) in CvVideoWriter_GStreamer::open, file /home/dan/Install-OpenCV/Ubuntu/2.4/OpenCV/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp, line 505
terminate called after throwing an instance of 'cv::Exception'
what(): /home/dan/Install-OpenCV/Ubuntu/2.4/OpenCV/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp:505: error: (-210) Gstreamer Opencv backend doesn't support this codec acutally. in function CvVideoWriter_GStreamer::open
I am not sure about the main reason for this. 我不确定主要原因。 But I guess this problem is relate to the decoder installed on your system. 但是我想这个问题与您系统上安装的解码器有关。 According to the install script from github, it removes your ffmpg and x264 then rebuilds them from source code. 根据github上的安装脚本,它将删除ffmpg和x264,然后从源代码中重建它们。 Before testing your OpenCV code, try simple "ffmpeg" command on your test video. 在测试您的OpenCV代码之前,请在测试视频上尝试简单的“ ffmpeg”命令。 Such as: ffmpeg -i inputfile.avi -f image2 image-%3d.jpeg
例如: ffmpeg -i inputfile.avi -f image2 image-%3d.jpeg
And show us you code, maybe there is something wrong in it. 并向我们显示您的代码,也许其中有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.