Closed ankur2136 closed 6 years ago
[info] Running opencv2_cookbook.chapter11.Ex3WriteVideoSequence [info] Processing video file: /Users/ankurjain/Downloads/javacv-examples-22ef77c9ed889b9cf66ecc8f1972311966b2f1bd/OpenCV2_Cookbook/data/bike.avi [info] Processing video file: /Users/ankurjain/Downloads/javacv-examples-22ef77c9ed889b9cf66ecc8f1972311966b2f1bd/OpenCV2_Cookbook/bikeOut.avi [info] [info] Video processing done.
The resulting bikeOut.avi is an empty file.
I tried a similar code for writing a single frame to a video file and that also gives an empty file. I don't see any other errors.
{ val imagePath = getClass.getResource("/IMG_20170221_161618.jpg").getPath val origImage = imread(imagePath) val writer = createWriter() writeNextFrame(writer, origImage) writeNextFrame(writer, origImage) writeNextFrame(writer, origImage) writer.foreach(_.release()) } def createWriter(): Option[VideoWriter] = { val writer = new VideoWriter() val actualFrameRate = 1 val actualCodec = VideoWriter.fourcc('M', 'P', 'E', 'G') if (writer.open("abc.mpeg", actualCodec, actualFrameRate, new Size(3456, 4608), true)) { Some(writer) } else { None } }
Please use FFmpegFrameRecorder instead of VideoWriter.
FFmpegFrameRecorder
VideoWriter
VideoProcessor processor was modified to use FFmpegFrameRecorder instead of VideoWriter.
VideoProcessor
[info] Running opencv2_cookbook.chapter11.Ex3WriteVideoSequence [info] Processing video file: /Users/ankurjain/Downloads/javacv-examples-22ef77c9ed889b9cf66ecc8f1972311966b2f1bd/OpenCV2_Cookbook/data/bike.avi [info] Processing video file: /Users/ankurjain/Downloads/javacv-examples-22ef77c9ed889b9cf66ecc8f1972311966b2f1bd/OpenCV2_Cookbook/bikeOut.avi [info] [info] Video processing done.
The resulting bikeOut.avi is an empty file.
I tried a similar code for writing a single frame to a video file and that also gives an empty file. I don't see any other errors.