How to convert 4K mp4 video into frames?
11 ビュー (過去 30 日間)
古いコメントを表示
How do i convert 4K video into frames..
video recorded in gopro camera and stored in mp4 format.
0 件のコメント
採用された回答
Nitin Kapgate
2021 年 1 月 11 日
編集済み: Nitin Kapgate
2021 年 1 月 11 日
You can refer to the code snippet below which demonstrates extraction of frames and export of the frames to a folder:
% import the in-built video file, replace 'xylophone.mp4' with your file name
vidObj = VideoReader('xylophone.mp4');
% read the total number of frames
frames = vidObj.NumFrames;
% file format of the frames to be saved in
imageFormat ='.png';
% create a new folder for frames
mkdir frames
% reading and writing the frames
for x = 1 : frames
% converting integer to string
frameIndex = num2str(x);
% concatenating 2 strings to get indexed frame name
frameName = strcat(frameIndex, imageFormat);
% read x'th frame from video
vidFrame = read(vidObj, x);
cd frames
% exporting the frames to the folder
imwrite(vidFrame, frameName);
cd ..
end
5 件のコメント
Nitin Kapgate
2021 年 1 月 19 日
I understand that the error "Failed to Initialize internal resources" pops up when trying to use the 'VideoReader' function.
There could be various reasons behind this error which are listed as follows:
- The required codec is missing for the particular video file. Determine whether the codec is installed on the computer.
- The video file contains an audio stream (eg. AC-3) not supported by the API (QTKit, in AC-3 case) used by VideoReader. The only workaround is to re-encode the audio stream in the file into a different format such as MPEG-4/AAC and then try to read the file.
- Sometimes, VideoReader cannot open a video file for reading on Windows platforms. This might occur if you have installed a third-party codec that overrides your system settings. Uninstall the codec and try opening the video file in MATLAB again.
The supported container formats and codecs link explains supported codecs in detail. Go through the troubleshooting section to determine if that could be a possibility in this particular case.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!