- Take an (raw) image sequence or video file and use the VideoWriter to create a .mj2 video.
 - Use the VideoReader to read the video frame by frame
 - Compare both
 
Lossless compression in Motion JPEG 2000 (.mj2) file. How do I tell?
    12 views (last 30 days)
  
       Show older comments
    
I found that Matlab's VideoWriter has the capability to write a Motion JPEG 2000 file with the LosslessCompression flag. Is there a way to find out whether images in a Motion JPEG 2000 file has been compressed losslessly?
0 Comments
Answers (1)
  Janosch Kunczik
 on 13 Jun 2017
        Hello Spencer,
Yes there is a way:
 %%Write the video
 writer = VideoWriter('test.mj2','Motion JPEG 2000');
 writer.LosslessCompression = true;
 for i=1:length(testData)
    writeVideo(writer,testData(:,:,:,i));
 end
 close(writer);
 vidObj = VideoReader('test.mj2');
 for i=1:length(testData)
   frame = readFrame(vidObj);
   orig_frame = rawObj.Data(i).frame;
   error = frame - orig_frame;
   disp(max(max(abs(error)));
end
This little snippet will let you prove that the result isn't lossless, although the LosslessCompression flag has been set.
I you want to have a lossless Motion JPEG 200 video, you will have to use the 'Archival' profile.
 writer = VideoWriter('test.mj2','Archival');
Kind regards,
Josh
0 Comments
See Also
Categories
				Find more on Audio and Video Data in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!