FFMPEG - информация о файле - C#
Формулировка задачи:
Здравствуйте!
Подскажите пожалуйста как получить и сохранить информацию о видеофайле: продолжительность, битрейт и др. в текстовый файл с помощью ffmpeg. Через командную строку, например, эти команды исправно работают: ffmpeg.exe -i file.mov 1> log.txt 2>&1 , ffmpeg.exe -i file.mov 2>logff.txt , а в c# - нет. Будьте добры наведите на правильный путь).
Решение задачи: «FFMPEG - информация о файле»
textual
Листинг программы
public VideoFile GetVideoInfo(string inputPath) { VideoFile vf = null; try { vf = new VideoFile(inputPath); } catch (Exception ex) { throw ex; } GetVideoInfo(vf); return vf; } public void GetVideoInfo(VideoFile input) { //set up the parameters for video info string Params = string.Format("-i {0}", input.Path); string output = RunProcess(Params); input.RawInfo = output; //get duration Regex re = new Regex("[D|d]uration:.((\\d|:|\\.)*)"); Match m = re.Match(input.RawInfo); if (m.Success) { string duration = m.Groups[1].Value; string[] timepieces = duration.Split(new char[] { ':', '.' }); if (timepieces.Length == 4) { input.Duration = new TimeSpan(0, Convert.ToInt16(timepieces[0]), Convert.ToInt16(timepieces[1]), Convert.ToInt16(timepieces[2]), Convert.ToInt16(timepieces[3])); } } }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д