Write video in wide screen format
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm creating a video using MATLAB's video writer function but the video always shows in a different visual format. I'm creating the video from frames of another (videoIn.mp4) with resolution of 720 x 576.
When I reproduce videoIn.mp4 in a video reproducer, it shows correctly. But when I reproduce the one generated by MATLAB, it shows "compressed" on the sides (not wide enough).
Does anyone know how to fix it?
This is my code:
myVideo = VideoWriter('videoOut.mp4','MPEG-4');
myVideo.FrameRate = 25;
myVideo.Quality = 100;
open(myVideo);
videoObject = VideoReader('videoIn.mp4');
framesToCopy = 1:50;
for nFrame = 1:length(framesToCopy)
mov(nFrame).cdata = readFrame(videoObject);
writeVideo(myVideo,mov(nFrame).cdata);
end
close(myVideo);
This is a screenshot of both videos open with VLC
Risposta accettata
Guillaume
il 20 Mar 2019
Matlab assumes and always display the video with a pixel aspect ratio of 1:1.
My guess is that your original video specify a different aspect ratio, that VLC respects (hence it stretches the video horizontally). Unfortunaly, that property is not accessible within matlab. The MP4 format is sufficiently complex that extracting that information within matlab without the help of a library would be substantial work.
So, if you want to process that video in matlab, you'll be stuck with a final video with a 1:1 pixel aspect ratio. It must be noted that the video is not constrained. It's more that the original is artificially stretched from its actual 720 pixels width by VLC.
0 Commenti
Più risposte (1)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!