필터 지우기
필터 지우기

動画ファイルから画像ファイルに変換

조회 수: 10 (최근 30일)
舞美
舞美 2023년 10월 19일
댓글: Dyuman Joshi 2023년 10월 25일
動画ファイルから画像ファイルに変換し、JPGファイルとして保存したいのですが、動画のファイルが大きいせいかエラーが出てしまいます。(以下参照)
この場合どのように工夫したら良いかわからず困っています。教えていただきたいです。
要求された 304x720x3x151582 (92.7GB) 配列は、最大配列サイズの基本設定
(8.0GB) を超えています。これにより、MATLAB は反応しなくなる可能性があります。
  댓글 수: 2
Hiroshi Iwamura
Hiroshi Iwamura 2023년 10월 19일
右側の「参考」に
「動画ファイルを画像ファイルに」
が出ていると思いますのでそれを見てみてください。
Dyuman Joshi
Dyuman Joshi 2023년 10월 25일
Can you share the code that generated this error message when you ran it?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jaynik
Jaynik 2023년 10월 23일
Hi 舞美,
私は日本語がネイティブではないので、この質問に英語で答えてみます。 ご理解のほどよろしくお願いいたします。
I understand that you want to convert a video file into ‘jpg’ files and assume that you want to save the individual frames from the videos as images. You can use the “VideoReader” class for performing this task. Following is a sample code that performs the task:
v = VideoReader('your_video_file.mp4');
numberOfFrames = v.NumFrames;
for frame = 1: numberOfFrames
% Extract the frame
thisFrame = read(v, frame);
% Display it
image(thisFrame);
drawnow;
outputBaseFileName = sprintf('Frame %4.4d.jpg', frame);
outputFullFileName = fullfile('./', outputBaseFileName);
frameWithText = getframe(gca);
imwrite(frameWithText.cdata, outputFullFileName, 'jpg');
end
For larger videos, you can consider processing the video in smaller chunks or frames. Additionally, using video compression techniques or converting the video to a lower resolution or different format can help reduce the file size and make it more manageable for processing.
You can read more about the “VideoReader” class here:
Hope this helps!
  댓글 수: 3
Jaynik
Jaynik 2023년 10월 25일
Using "imwrite" after reading the frame would be better for larger files. The given code is just a sample to get frames and should be edited as per the use case.
Dyuman Joshi
Dyuman Joshi 2023년 10월 25일
Yes, and you read the frame using read, so once again, there is no need to use getframe().
And your answer still does not recognize the problem OP is facing, let alone address it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!