PDA

View Full Version : سوال: بدست آوردن زمان فایل صوتی



group45
سه شنبه 20 مهر 1389, 12:28 عصر
با سلام
چطور میشه زمان یه فایل صوتی مثلا ویو رو بدست آورد؟
میخوام ازش تو تراکر بار استفاده کنم.

با تشکرات عدیده..................................

behzadk
سه شنبه 20 مهر 1389, 12:52 عصر
تابع api به نام mcisendstring وجود داره که با اون می تونید هم به طول و هم ویرایش و ... با فایل صوتی انجام دهید

group45
سه شنبه 20 مهر 1389, 13:34 عصر
ممنون از شما
میشه یه مثالی بزنید چون تا حالا با api کار نکردم.

ad.davachi
سه شنبه 20 مهر 1389, 13:35 عصر
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;
ffmpeg.StartInfo.RedirectStandardError = true;


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


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);
}

group45
سه شنبه 20 مهر 1389, 16:23 عصر
ببخشید
این کدهایی رو که زحمت کشیدید گذاشتید واسه هر نوع فایلی صدق میکنن؟؟؟؟؟؟؟

ad.davachi
سه شنبه 20 مهر 1389, 16:54 عصر
این لینکش خودتون توضیحاتش رو بخونید.
http://www.dreamincode.net/forums/topic/58502-how-to-get-video-file-durationtime-using-c%23/
ولی چون از System.Diagnostics استفاده کرده فکر می کنم آره برای هر فرمتی میشه