При попытке решить проблемы в http://wiki.bitplan.com/index.php/OpenCV#OpenCV_VideoWriter я нашел следующие соответствующие ссылки:
, а затем придумал код, приведенный ниже , чтобы опробовать комбинации расширений и FOUR CC коды.
Среда Ma c Os 10.13.6 с использованием Java 8 и Macports 2.6.2. с OpenCV 3.4.8 я также тестировал вещи на Ubuntu 18.04 LTS, используя OpenJDK 1.8.0_232 с libopencv_java343.so
Сообщения и файлы показывают, что ни одна из 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 TestCase
package nl.vaneijndhoven.dukes.imageview;
import static org.junit.Assert.assertTrue;
import java.io.File;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import com.bitplan.opencv.NativeLibrary;
import nl.vaneijndhoven.opencv.video.ImageUtils;
/**
* test the video recording functionality
*
* @author wf
*
*/
public class TestVideoRecorder {
@BeforeClass
public static void setup() throws Exception {
NativeLibrary.load();
}
@Test
public void testVideoRecorder() {
byte[] testImage = DebugImageServer.testImage();
Mat testMat = ImageUtils.imageBytes2Mat(testImage);
boolean isColor = true;
for (String ext : VideoRecorder.exts) {
for (String FOURCC : VideoRecorder.FOURCCs) {
Size frameSize = new Size(testMat.width(), testMat.height());
VideoRecorder recorder = new VideoRecorder("test", isColor);
recorder.ext=ext;
recorder.FOURCC=FOURCC;
String msg = String.format("recording: %dx%d %s video with %s",
testMat.width(), testMat.height(), ext, FOURCC);
System.out.println(msg);
recorder.start(25.0, frameSize);
for (int i = 1; i <= 50; i++) {
recorder.recordMat(testMat);
}
recorder.stop();
File videoFile = new File(recorder.path);
assertTrue(videoFile.exists());
}
}
}
}
VideoRecorder