0

I need to get an mpeg4 file to use in another application, from an original mpeg4 video I loaded into matlab and edited (frame by frame). To do so, I tried using VideoWriter, setting the quality to 100%:

newVid = VideoWriter(outputfilename, 'MPEG-4');
newVid.FrameRate = fps;
newVid.Quality = 100;

However, the result I'm getting is very poor and if the original unedited video size was ~50MB, the one I get post-edit in matlab is around ~20MB, and I don't know how to keep the quality and size as they were. I also tried saving as .avi and converting to mpeg4 with ffmpeg, but it gave even poorer results. Any ideas?

guyts
  • 899
  • 2
  • 17
  • 34

1 Answers1

0

MPEG-4is a compressed format so there is information loss when you save it in this format. Quality is the quality of the compression but you do not want any compression. To force Matlab not to use compression my guess is to use the statement below as the default is H.264


    newVid.VideoCompressionMethod = 'none'

MosGeo
  • 1,012
  • 9
  • 9
  • Then I guess, you will have to use another format that is uncompressed ('Uncompressed AVI') and convert it outside matlab like you tried. It seems that ffmpeg can do lossless H.264 enconding (https://trac.ffmpeg.org/wiki/Encode/H.264) – MosGeo Aug 17 '17 at 16:05
  • I'm not the one asking and ffmpeg can do anything ;-) (and this part of matlab seems poorly designed) – sascha Aug 17 '17 at 16:06
  • I did not notice that, sorry! Matlab has other format other than MPEG-4 that are lossless. That being said, it is true, I would expect the highest quality should mean lossless in matlab but apparently it is not. – MosGeo Aug 17 '17 at 16:12
  • This does not work as sascha mentioned. I did use uncompressed AVI, but I need MATLAB to provide the MP4 output rather than ffmpeg it for the purpose of my project. – guyts Sep 07 '17 at 14:38