Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
opencv VideoWriter for Java在MacOS上无法正常工作_Java_Opencv - Fatal编程技术网

opencv VideoWriter for Java在MacOS上无法正常工作

opencv VideoWriter for Java在MacOS上无法正常工作,java,opencv,Java,Opencv,在试图解决问题的时候 我发现了以下相关链接: 然后提出了尝试扩展和FOURCC代码组合的方法 该环境是使用Java 8和Macports 2.6.2的Mac Os 10.13.6。使用OpenCV 3.4.8 我还使用OpenJDK1.8.0_232和libopencv_java343.so在Ubuntu18.04 LTS上进行了测试 消息和文件显示,我尝试的21种组合都不起作用 要使录像正常工作,有什么问题和解决方案? 产生的信息包括: recording: 640x480 mo

在试图解决问题的时候 我发现了以下相关链接:

然后提出了尝试扩展和FOURCC代码组合的方法

该环境是使用Java 8和Macports 2.6.2的Mac Os 10.13.6。使用OpenCV 3.4.8 我还使用OpenJDK1.8.0_232和libopencv_java343.so在Ubuntu18.04 LTS上进行了测试

消息和文件显示,我尝试的21种组合都不起作用

要使录像正常工作,有什么问题和解决方案?

产生的信息包括:

recording: 640x480 mov video with MJPG
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x6765706a/'jpeg'
recording: 640x480 mov video with X264
OpenCV: FFMPEG: tag 0x34363258/'X264' is not supported with codec id 27 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
recording: 640x480 mov video with H264
OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
recording: 640x480 mov video with MP4V
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
recording: 640x480 mov video with AVC1
OpenCV: FFMPEG: tag 0x31435641/'AVC1' is not supported with codec id 27 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
recording: 640x480 mov video with FMP4
OpenCV: FFMPEG: tag 0x34504d46/'FMP4' is not supported with codec id 12 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
recording: 640x480 mov video with JPEG
OpenCV: FFMPEG: tag 0x4745504a/'JPEG' is not supported with codec id 7 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x6765706a/'jpeg'
recording: 640x480 avi video with MJPG
recording: 640x480 avi video with X264
recording: 640x480 avi video with H264
recording: 640x480 avi video with MP4V
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'avi / AVI (Audio Video Interleaved)'
OpenCV: FFMPEG: fallback to use tag 0x34504d46/'FMP4'
recording: 640x480 avi video with AVC1
OpenCV: FFMPEG: tag 0x31435641/'AVC1' is not supported with codec id 27 and format 'avi / AVI (Audio Video Interleaved)'
OpenCV: FFMPEG: fallback to use tag 0x34363248/'H264'
recording: 640x480 avi video with FMP4
recording: 640x480 avi video with JPEG
OpenCV: FFMPEG: tag 0x4745504a/'JPEG' is not supported with codec id 7 and format 'avi / AVI (Audio Video Interleaved)'
OpenCV: FFMPEG: fallback to use tag 0x47504a4d/'MJPG'
recording: 640x480 mpg video with MJPG
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 7 and format 'mpeg / MPEG-1 Systems / MPEG program stream'
recording: 640x480 mpg video with X264
OpenCV: FFMPEG: tag 0x34363258/'X264' is not supported with codec id 27 and format 'mpeg / MPEG-1 Systems / MPEG program stream'
recording: 640x480 mpg video with H264
OpenCV: FFMPEG: tag 0x34363248/'H264' is not supported with codec id 27 and format 'mpeg / MPEG-1 Systems / MPEG program stream'
recording: 640x480 mpg video with MP4V
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'mpeg / MPEG-1 Systems / MPEG program stream'
recording: 640x480 mpg video with AVC1
OpenCV: FFMPEG: tag 0x31435641/'AVC1' is not supported with codec id 27 and format 'mpeg / MPEG-1 Systems / MPEG program stream'
recording: 640x480 mpg video with FMP4
OpenCV: FFMPEG: tag 0x34504d46/'FMP4' is not supported with codec id 12 and format 'mpeg / MPEG-1 Systems / MPEG program stream'
recording: 640x480 mpg video with JPEG
OpenCV: FFMPEG: tag 0x4745504a/'JPEG' is not supported with codec id 7 and format 'mpeg / MPEG-1 Systems / MPEG program stream'
产生的文件包括:

-rw-r--r-- 1 wf    5686  9. Jan 10:19 test_AVC1_2020-01-09101907.avi
-rw-r--r-- 1 wf     185  9. Jan 10:19 test_AVC1_2020-01-09101907.mov
-rw-r--r-- 1 wf       0  9. Jan 10:19 test_AVC1_2020-01-09101907.mpg
-rw-r--r-- 1 wf    5686  9. Jan 10:19 test_FMP4_2020-01-09101907.avi
-rw-r--r-- 1 wf     185  9. Jan 10:19 test_FMP4_2020-01-09101907.mov
-rw-r--r-- 1 wf       0  9. Jan 10:19 test_FMP4_2020-01-09101907.mpg
-rw-r--r-- 1 wf    5686  9. Jan 10:19 test_H264_2020-01-09101907.avi
-rw-r--r-- 1 wf     185  9. Jan 10:19 test_H264_2020-01-09101907.mov
-rw-r--r-- 1 wf       0  9. Jan 10:19 test_H264_2020-01-09101907.mpg
-rw-r--r-- 1 wf    5686  9. Jan 10:19 test_JPEG_2020-01-09101907.avi
-rw-r--r-- 1 wf     185  9. Jan 10:19 test_JPEG_2020-01-09101907.mov
-rw-r--r-- 1 wf       0  9. Jan 10:19 test_JPEG_2020-01-09101907.mpg
-rw-r--r-- 1 wf    5686  9. Jan 10:19 test_MJPG_2020-01-09101907.avi
-rw-r--r-- 1 wf     185  9. Jan 10:19 test_MJPG_2020-01-09101907.mov
-rw-r--r-- 1 wf       0  9. Jan 10:19 test_MJPG_2020-01-09101907.mpg
-rw-r--r-- 1 wf    5686  9. Jan 10:19 test_MP4V_2020-01-09101907.avi
-rw-r--r-- 1 wf     185  9. Jan 10:19 test_MP4V_2020-01-09101907.mov
-rw-r--r-- 1 wf       0  9. Jan 10:19 test_MP4V_2020-01-09101907.mpg
-rw-r--r-- 1 wf    5686  9. Jan 10:19 test_X264_2020-01-09101907.avi
-rw-r--r-- 1 wf     185  9. Jan 10:19 test_X264_2020-01-09101907.mov
-rw-r--r-- 1 wf       0  9. Jan 10:19 test_X264_2020-01-09101907.mpg
Junit测试用例

包nl.vaneijndhoven.dukes.imageview;
导入静态org.junit.Assert.assertTrue;
导入java.io.File;
导入org.junit.BeforeClass;
导入org.junit.Test;
导入org.opencv.core.Mat;
导入org.opencv.core.Size;
导入com.bitplan.opencv.nativellibrary;
导入nl.vaneijndhoven.opencv.video.ImageUtils;
/**
*测试视频录制功能
* 
*@author wf
*
*/
公共类测试录像机{
@课前
public static void setup()引发异常{
NativeLibrary.load();
}
@试验
公共录像机(){
字节[]testImage=DebugImageServer.testImage();
Mat testMat=ImageUtils.imageBytes2Mat(testImage);
布尔值isColor=true;
for(字符串ext:VideoRecorder.exts){
用于(字符串FOURCC:VideoRecorder.FOURCCs){
Size frameSize=新尺寸(testMat.width(),testMat.height());
录像机=新录像机(“测试”,iColor);
recorder.ext=ext;
记录器。FOURCC=FOURCC;
String msg=String.format(“录制:%dx%d%s与%s的视频”,
testMat.width()、testMat.height()、ext、FOURCC);
System.out.println(msg);
记录器。启动(25.0,帧大小);

对于(int i=1;i而言,问题在于测试图像是具有4个通道的PNG图像

修正了这种情况:

确保我们使用jpg:

DebugImageServer.ext=“.jpg”;
显示使用的通道数:

String msg=String.format(“录制:%dx%d%d频道%s视频和%s”,
testMat.width()、testMat.height()、testMat.channels()、ext、FOURCC);
System.out.println(msg);
现在有很多组合都起作用了:

-rw-r--r-- 1 wf     81845  9. Jan 11:05 test_avc1_2020-01-09110505.mov
-rw-r--r-- 1 wf     87402  9. Jan 11:05 test_avc1_2020-01-09110506.avi
-rw-r--r-- 1 wf     81920  9. Jan 11:05 test_avc1_2020-01-09110507.mpg
-rw-r--r-- 1 wf    389053  9. Jan 11:05 test_fmp4_2020-01-09110505.mov
-rw-r--r-- 1 wf    395162  9. Jan 11:05 test_fmp4_2020-01-09110506.avi
-rw-r--r-- 1 wf    391168  9. Jan 11:05 test_fmp4_2020-01-09110507.mpg
-rw-r--r-- 1 wf     81845  9. Jan 11:05 test_h264_2020-01-09110506.mov
-rw-r--r-- 1 wf     87402  9. Jan 11:05 test_h264_2020-01-09110507.avi
-rw-r--r-- 1 wf     81920  9. Jan 11:05 test_h264_2020-01-09110508.mpg
-rw-r--r-- 1 wf   3618564  9. Jan 11:05 test_jpeg_2020-01-09110506.mov
-rw-r--r-- 1 wf   3624510  9. Jan 11:05 test_jpeg_2020-01-09110507.avi
-rw-r--r-- 1 wf   3631104  9. Jan 11:05 test_jpeg_2020-01-09110508.mpg
-rw-r--r-- 1 wf   3618564  9. Jan 11:05 test_mjpg_2020-01-09110506.mov
-rw-r--r-- 1 wf   3624510  9. Jan 11:05 test_mjpg_2020-01-09110507.avi
-rw-r--r-- 1 wf   3631104  9. Jan 11:05 test_mjpg_2020-01-09110508.mpg
-rw-r--r-- 1 wf    389053  9. Jan 11:05 test_mp4v_2020-01-09110506.mov
-rw-r--r-- 1 wf    395162  9. Jan 11:05 test_mp4v_2020-01-09110507.avi
-rw-r--r-- 1 wf    391168  9. Jan 11:05 test_mp4v_2020-01-09110508.mpg
-rw-r--r-- 1 wf     81845  9. Jan 11:05 test_x264_2020-01-09110506.mov
-rw-r--r-- 1 wf     87402  9. Jan 11:05 test_x264_2020-01-09110507.avi
-rw-r--r-- 1 wf     81920  9. Jan 11:05 test_x264_2020-01-09110508.mpg
-rw-r--r-- 1 wf    389053  9. Jan 11:05 test_xvid_2020-01-09110506.mov
-rw-r--r-- 1 wf    395162  9. Jan 11:05 test_xvid_2020-01-09110507.avi
-rw-r--r-- 1 wf    391168  9. Jan 11:05 test_xvid_2020-01-09110508.mpg