الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

استفسار هل الماتلاب يتعامل مع مقطع فيديو

بدأه برمجة حاسب في 22 أكتوبر 2009 · 1 رد · 688 مشاهدة · في الرياضيات والخوارزميات
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتــه ،،

سؤال هل يستطيع المات لاب التعامل مع مقطع فيديو بحيث يقوم بتحويله الى عدة صور

:D

#2

جرب التالي :


for i=1:length(Vid)
imwrite(Vid(i).cdata,[numrstr(i) '.jpeg']) % Check the format & options
end
Vid=aviread('filename.avi');

او التالي:

function video2pic( videoFile, outputPath, picFormat )
 %VIDEO2PIC converts viedo frames into pictures.
 %   This function uses mmreader to read videos. Thus video format supported
 %   by system can be converted to pictures. Output file name follows the
 %   format: VideoName_FrameNumber.PicSuffix.
 %
 %   VIDEO2PIC input parameters interactively.
 %   VIDEO2PIC( VIDEOFILE, OUTPUTPATH, PICFORMAT ) runs as a
 %   function.
 %
 %   videoFile: full path of video to convert.
 %   outputPath: pictures will be saved under outputPath/videoname/.
 %   picFormat: check 'help imwrite'
 %
 %	Shiquan Wang @ CASIA
 %	sqwang@nlpr.ia.ac.cn
 %   http://www.cbsr.ia.ac.cn/users/sqwang/
 %	revised on 2009/10/19


 %% Initialization
 if nargin < 1
	 videoFile = input('Input full video path:', 's');
	 outputPath = input('Input video output path[Default is under the video path]:', 's');
	 if isempty(outputPath)
		 outputPath = videoFile(1, 1:find(videoFile=='\', 1, 'last')-1);
	 end
	 picFormat = input('Input output pic format[JPG by default]:');
	 if isempty(picFormat)
		 picFormat = 'JPG';
	 end
 end

 %% Main part
 videoObject = mmreader(videoFile);
 numFrames = get(videoObject, 'numberOfFrames');
 fileName = get(videoObject, 'Name');
 % bitsPerPix = get(videoObject, 'BitsPerPixel');
 % H = get(videoObject, 'Height');
 % W = get(videoObject, 'Width');
 % bytesPerFrame = bitsPerPix*H*W/8;
 outputPath = fullfile(outputPath, fileName(1, 1:find(fileName=='.', 1, 'last')-1));
 numOrder = max(4, size(int2str(numFrames), 2));
 mkdir(outputPath);

 indexFrame = [1 1];
 frameLimit = 100; % This can be set a larger value with enough memory.
 while indexFrame(1, 1) <= numFrames
 %	 memorynow = memory;
 %	 memoryMax = memorynow.MaxPossibleArrayBytes;
 %	 frameLimit = floor(memoryMax/bytesPerFrame*0.8);
	 indexFrame(1, 2) = min(numFrames, indexFrame(1, 1) + frameLimit);
	 frameAll = read(videoObject, indexFrame);

	 for i = indexFrame(1, 1):1:indexFrame(1, 2)	%save frames to pic		
		 imgFrame = frameAll(:,:,:,i - indexFrame(1, 1) + 1);
		 saveFormat = strcat('%s\\%s_%0', int2str(numOrder), 'd.%s');
		 picName = sprintf(saveFormat, outputPath, fileName, i, picFormat);
		 imwrite(imgFrame, picName);
		 disp(picName); % This output can be turned off.
	 end
	 indexFrame(1, 1) = indexFrame(1, 2) + 1;
 end
 end

بالنسبة لي استخدم هذا البرنامج المجاني لامور الفيديو:

VirtualDub

تم تعديل هذه المشاركة بواسطة ibr_exn في 23 أكتوبر 2009 في 03:56

الحمد لله الذي هدانا لهذا وماكنا لنهتدي لولا ان هدانا الله

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…