Write video in wide screen format
古いコメントを表示
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

6 件のコメント
Guillaume
2019 年 3 月 20 日
What is
size(mov(1).cdata)
?
Note that in the code above, you're reading a frame into mov(nframe) but writing mov(count) (with count not changing and undefined in the snippet).
Seven Eden
2019 年 3 月 20 日
Guillaume
2019 年 3 月 20 日
And in 'VideoOut.mp4' it's no longer 720x576?
Seven Eden
2019 年 3 月 20 日
It looks to me that VideoOut has got the correct aspect ratio for a 720x576 image. On the other hand, VideoIn looks like it is around twice as wide as tall, so does not match a 720x576 aspect ratio.
Seven Eden
2019 年 3 月 20 日
採用された回答
その他の回答 (1 件)
Seven Eden
2019 年 3 月 23 日
カテゴリ
ヘルプ センター および File Exchange で Video Formats and Interfaces についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!