Write video in wide screen format
조회 수: 14 (최근 30일)
이전 댓글 표시
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
![video2.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/209373/video2.jpeg)
채택된 답변
Guillaume
2019년 3월 20일
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
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!