除了在MJPEG中编码的文件外,我无法在OpenCV中打开任何视频文件。
我已经使用this脚本安装了OpenCV(它应该编译支持ffmpeg的OpenCV)并使用提供的示例here进行测试。
使用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
使用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
我正在运行x64 Ubuntu 12.04。
编辑:我在Ubuntu 13.10 x86虚拟机上尝试过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
答案 0 :(得分:0)
我不确定这个的主要原因。但我想这个问题与您系统上安装的解码器有关。根据github的安装脚本,它会删除你的ffmpg和x264,然后从源代码重建它们。在测试OpenCV代码之前,请尝试简单的" ffmpeg"命令测试视频。
例如:ffmpeg -i inputfile.avi -f image2 image-%3d.jpeg
答案 1 :(得分:0)
告诉我们你的代码,也许它有什么问题。