How to convert 4K mp4 video into frames?
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How do i convert 4K video into frames..
video recorded in gopro camera and stored in mp4 format.
0 Commenti
Risposta accettata
Nitin Kapgate
il 11 Gen 2021
Modificato: Nitin Kapgate
il 11 Gen 2021
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 Commenti
Nitin Kapgate
il 19 Gen 2021
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.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!