مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

افشین ایمانی زاده

عضویت از 1393/12/24

بدست آوردن زمان ویدئو

  • پنجشنبه 16 مهر 1394
  • 09:17
تشکر میکنم

سلام 

دوستان چطوری میشه زمان فایل ویدئو رو بعد از آپلود شدن بدست آورد؟ 

اگر راهنمایی بفرمایید ممنون میشم

پاسخ های این پرسش

تعداد پاسخ ها : 2 پاسخ
کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • پنجشنبه 16 مهر 1394
  • 09:25
using(Process ffmpeg = new Process())
{
	 String duration;  // soon will hold our video's duration in the form "HH:MM:SS.UU"
	 String result;  // temp variable holding a string representation of our video's duration
	 StreamReader errorreader;  // StringWriter to hold output from ffmpeg

	 // we want to execute the process without opening a shell
	 ffmpeg.StartInfo.UseShellExecute = false;
	 ffmpeg.StartInfo.ErrorDialog = false;

	 // redirect StandardError so we can parse it
	 // for some reason the output comes through over StandardError
	 ffmpeg.StartInfo.RedirectStandardError = true;

	 // set the file name of our process, including the full path
	 // (as well as quotes, as if you were calling it from the command-line)
	 ffmpeg.StartInfo.FileName = "[directory of ffmpeg.exe]\ffmpeg.exe";

	 // set the command-line arguments of our process, including full paths of any files
	 // (as well as quotes, as if you were passing these arguments on the command-line)
	 ffmpeg.StartInfo.Arguments = "-i [directory of video file]\video_file";

	 // start the process
	 ffmpeg.Start();

	 // now that the process is started, we can redirect output to the StreamReader we defined
	 errorreader = ffmpeg.StandardError;

	 // wait until ffmpeg comes back
	 ffmpeg.WaitForExit([time_to_wait_in_milliseconds]);

	 // read the output from ffmpeg, which for some reason is found in Process.StandardError
	 result = errorreader.ReadToEnd();

	 // a little convoluded, this string manipulation...
	 // working from the inside out, it:
	 // takes a substring of result, starting from the end of the "Duration: " label contained within,
	 // (execute "ffmpeg.exe -i somevideofile" on the command-line to verify for yourself that it is there)
	 // and going the full length of the timestamp.
	 // The resulting substring is of the form "HH:MM:SS.UU"

	 duration = result.Substring(result.IndexOf("Duration: ") + ("Duration: ").Length, ("00:00:00.00").Length);
}

 

کاربر سایت

افشین ایمانی زاده

عضویت از 1393/12/24

  • پنجشنبه 16 مهر 1394
  • 10:30

جناب مدائنی توی این خط error دارد

 ffmpeg.StartInfo.FileName = "[directory of ffmpeg.exe]\ffmpeg.exe";

میشه راهنمایی بفرمایید

 

 

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)