本文整理汇总了C#中MediaInfoLib.MediaInfo.Get方法的典型用法代码示例。如果您正苦于以下问题:C# MediaInfo.Get方法的具体用法?C# MediaInfo.Get怎么用?C# MediaInfo.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaInfoLib.MediaInfo
的用法示例。
在下文中一共展示了MediaInfo.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVideoFileTakenDate
public static DateTime? GetVideoFileTakenDate(string filePath)
{
MediaInfo mediaInfo = null;
try
{
mediaInfo = new MediaInfo();
mediaInfo.Open(filePath);
DateTime? result = null;
string recordedDate = mediaInfo.Get(StreamKind.General, 0, "Recorded_Date");
if (!string.IsNullOrWhiteSpace(recordedDate))
{
result = DateTime.Parse(recordedDate, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
}
if (result == null)
{
recordedDate = mediaInfo.Get(StreamKind.General, 0, "Encoded_Date");
if (string.IsNullOrWhiteSpace(recordedDate))
{
recordedDate = mediaInfo.Get(StreamKind.General, 0, "Tagged_Date");
}
if (!string.IsNullOrWhiteSpace(recordedDate))
{
var dateTimeStyles = DateTimeStyles.AssumeUniversal;
// Canon records local time as UTC
var canonCameraIdentifier = mediaInfo.Get(StreamKind.General, 0, "CodecID/String");
if (canonCameraIdentifier.Contains("/CAEP"))
{
dateTimeStyles = DateTimeStyles.AssumeLocal;
}
result = DateTime.ParseExact(recordedDate, "\"UTC\" yyyy-MM-dd HH:mm:ss",
CultureInfo.InvariantCulture, dateTimeStyles);
}
}
if (result == null)
{
recordedDate = mediaInfo.Get(StreamKind.General, 0, "Mastered_Date");
if (!string.IsNullOrWhiteSpace(recordedDate))
{
result = DateTime.ParseExact(recordedDate, "ddd MMM dd HH:mm:ss yyyy",
CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
}
}
return result;
}
catch (Exception)
{
}
finally
{
if (mediaInfo != null)
{
mediaInfo.Close();
}
}
return null;
}
示例2: FileInput
public FileInput(string filename)
{
this.filename = filename;
MediaInfo MI = new MediaInfo();
if (MI.Open(this.GetFileName()) > 0)
{
string s = MI.Option("Info_Parameters");
int width = int.Parse(MI.Get(StreamKind.Video, 0, "Width"));
int height = int.Parse(MI.Get(StreamKind.Video, 0, "Height"));
decimal aspect = (decimal)width / (decimal)height;
bool resize = false;
if (width > 1280)
{
width = 1280;
height = (int)(width / aspect);
resize = true;
}
if (height > 720)
{
height = 720;
width = (int)(height * aspect);
resize = true;
}
if (resize)
{
if (width % 2 > 0)
width -= 1;
if (height % 2 > 0)
height -= 1;
this._size = " -s " + width + "x" + height;
}
Log.WriteLine("resize=" + resize + ",size=" + width + "x" + height);
int videobitrate = int.Parse(MI.Get(StreamKind.Video, 0, "BitRate"));
if (videobitrate > 7 * 1024 * 1024 || resize)
{
this._parameter = " libx264 -coder 0 -flags -loop -cmp +chroma -partitions -parti8x8-parti4x4-partp8x8-partb8x8 -me_method dia -subq 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 0 -i_qfactor 0.71 -b_strategy 0 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -bf 0 -refs 1 -directpred 1 -trellis 0 -flags2 -bpyramid-mixed_refs-wpred-dct8x8+fastpskip-mbtree -wpredp 0 -b 4096k ";
}
else
{
this._parameter = " copy";
}
this._parameter = " -vcodec " + this._parameter;
//Log.WriteLine("media info supported :" + s);
MI.Close();
}
if (this.GetFileName().ToLower().EndsWith(".mp4") || this.GetFileName().ToLower().EndsWith(".mkv"))
{
this._parameter += " -vbsf h264_mp4toannexb ";
}
this._parameter += " -acodec libfaac -ac 2 -ab 192k ";
}
示例3: ExtractInfo
public static string[] ExtractInfo(string path)
{
MediaInfo MI = new MediaInfo();
MI.Open(path);
string[] returnInfo = new string[5];
//File name 0
returnInfo[0] = MI.Get(0, 0, "FileName");
//Size 1
string sizeInKBStr = MI.Get(0, 0, "FileSize/String").Substring(
0, MI.Get(0, 0, "FileSize/String").LastIndexOf(" ")).Replace(" ", "");
double sizeInKB = Double.Parse(sizeInKBStr);
double sizeInMB = (double)(sizeInKB / 1024);
string sizeInMBStr = String.Format("{0:0.00}", sizeInMB);
returnInfo[1] = sizeInMBStr + " MB";
//Date created 2
returnInfo[2] = MI.Get(0, 0, "File_Created_Date").Substring(
MI.Get(0, 0, "File_Created_Date").IndexOf(" ") + 1, MI.Get(0, 0, "File_Created_Date").LastIndexOf(".") - 4);
//Performer 3
returnInfo[3] = MI.Get(0, 0, "Performer");
//Length 4
returnInfo[4] = MI.Get(0, 0, "Duration/String3").Substring(0, MI.Get(0, 0, "Duration/String3").LastIndexOf("."));
return returnInfo;
}
示例4: Main
public static void Main(string[] args)
{
String ToDisplay = "";
MediaInfo MI = new MediaInfo();
//An example of how to use the library
ToDisplay += "\r\n\r\nOpen\r\n";
MI.Open(args[0]);
ToDisplay += "\r\n\r\nInform with Complete=false\r\n";
MI.Option("Complete");
ToDisplay += MI.Inform();
ToDisplay += "\r\n\r\nInform with Complete=true\r\n";
MI.Option("Complete", "1");
ToDisplay += MI.Inform();
ToDisplay += "\r\n\r\nCustom Inform\r\n";
MI.Option("Inform", "General;File size is %FileSize% bytes");
ToDisplay += MI.Inform();
ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='FileSize'\r\n";
ToDisplay += MI.Get(0, 0, "FileSize");
ToDisplay += "\r\n\r\nGet with Stream=General and Parameter=46\r\n";
ToDisplay += MI.Get(0, 0, 46);
ToDisplay += "\r\n\r\nCount_Get with StreamKind=Stream_Audio\r\n";
ToDisplay += MI.Count_Get(StreamKind.Audio);
ToDisplay += "\r\n\r\nGet with Stream=General and Parameter='AudioCount'\r\n";
ToDisplay += MI.Get(StreamKind.General, 0, "AudioCount");
ToDisplay += "\r\n\r\nGet with Stream=Audio and Parameter='StreamCount'\r\n";
ToDisplay += MI.Get(StreamKind.Audio, 0, "StreamCount");
ToDisplay += "\r\n\r\nClose\r\n";
MI.Close();
Console.WriteLine(ToDisplay);
}
示例5: Musiikki
public Musiikki(string nimi, string filePath)
{
FilePath = filePath;
MediaInfo MI = new MediaInfo();
MI.Open(FilePath);
Nimi = MI.Get(StreamKind.General, 0, "FileName");
Pituus = MI.Get(StreamKind.General, 0, "Duration/String");
SoundEncoding = MI.Get(StreamKind.Audio, 0, "Language/String") + "," + MI.Get(StreamKind.Audio, 0, "SamplingRate/String") + "," + MI.Get(StreamKind.Audio, 0, "Channel(s)/String") + "," + MI.Get(StreamKind.General, 0, "Audio_Format_List");
TiedostonKoko = MI.Get(StreamKind.General, 0, "FileSize/String");
MI.Close();
}
示例6: Audio
public Audio(MediaInfo MI, int i)
{
this.codec = MI.Get(StreamKind.Audio, i, "Codec/String");
//this.profile = MI.Get(StreamKind.Audio, i, "Codec_Profile");
this.bitrate_mode = MI.Get(StreamKind.Audio, i, "BitRate_Mode/String");
this.bitrate = MI.Get(StreamKind.Audio, i, "BitRate/String");
this.sampling_frequency = MI.Get(StreamKind.Audio, i, "SamplingRate");
this.channels = MI.Get(StreamKind.Audio, i, "Channel(s)");
this.delay = MI.Get(StreamKind.Audio, i, "Video_Delay");
}
示例7: GetAudioCodec
private static string GetAudioCodec(MediaInfo mediaInfo)
{
Application.DoEvents();
string audioCodec;
Debugger.LogMessageToFile("Getting audio codec...");
try
{
audioCodec = mediaInfo.Get(StreamKind.Audio, 0, "Codec");
}
catch
{
audioCodec = string.Empty;
}
return audioCodec;
}
示例8: AudioMetadata
public AudioMetadata(string Filename)
{
var MI = new MediaInfo();
MI.Open(Filename);
Title = MI.Get(StreamKind.General, 0, "Title");
Album = MI.Get(StreamKind.General, 0, "Album");
Artist = MI.Get(StreamKind.General, 0, "Performer");
Genre = MI.Get(StreamKind.General, 0, "Genre");
RecordDate = MI.Get(StreamKind.General, 0, "Recorded_Date");
var duration = MI.Get(StreamKind.General, 0, "Duration");
Duration = new TimeSpan(Convert.ToInt64(duration) * 10000);
}
示例9: ExampleWithStream
public static String ExampleWithStream()
{
//Initilaizing MediaInfo
MediaInfo MI = new MediaInfo();
//From: preparing an example file for reading
FileStream From = new FileStream(FilePath, FileMode.Open, FileAccess.Read);
//From: preparing a memory buffer for reading
byte[] From_Buffer = new byte[64 * 1024];
int From_Buffer_Size; //The size of the read file buffer
//Preparing to fill MediaInfo with a buffer
MI.Open_Buffer_Init(From.Length, 0);
//The parsing loop
do
{
//Reading data somewhere, do what you want for this.
From_Buffer_Size = From.Read(From_Buffer, 0, 64 * 1024);
//Sending the buffer to MediaInfo
System.Runtime.InteropServices.GCHandle GC = System.Runtime.InteropServices.GCHandle.Alloc(From_Buffer, System.Runtime.InteropServices.GCHandleType.Pinned);
IntPtr From_Buffer_IntPtr = GC.AddrOfPinnedObject();
Status Result = (Status)MI.Open_Buffer_Continue(From_Buffer_IntPtr, (IntPtr)From_Buffer_Size);
GC.Free();
if ((Result & Status.Finalized) == Status.Finalized)
break;
//Testing if MediaInfo request to go elsewhere
if (MI.Open_Buffer_Continue_GoTo_Get() != -1)
{
Int64 Position = From.Seek(MI.Open_Buffer_Continue_GoTo_Get(), SeekOrigin.Begin); //Position the file
MI.Open_Buffer_Init(From.Length, Position); //Informing MediaInfo we have seek
}
}
while (From_Buffer_Size > 0);
//Finalizing
MI.Open_Buffer_Finalize(); //This is the end of the stream, MediaInfo must finnish some work
//Get() example
return "Container format is " + MI.Get(StreamKind.General, 0, "Format");
}
示例10: GetAudioDuration
private static int GetAudioDuration(MediaInfo mediaInfo)
{
Application.DoEvents();
int audioDuration = 0;
string audioDurationStr;
Debugger.LogMessageToFile("Getting audio duration...");
try
{
audioDurationStr = mediaInfo.Get(StreamKind.Audio, 0, "Duration");
}
catch (Exception e)
{
Debugger.LogMessageToFile("[Media File Analyzer] An unexpected error occured while" +
" the Media Analyzer was trying to obtain a media file's Audio Duration." +
" The error was: " + e);
audioDurationStr = string.Empty;
}
try
{
if (!String.IsNullOrEmpty(audioDurationStr))
{
Debugger.LogMessageToFile("Converting audio duration...");
audioDuration = Convert.ToInt32(audioDurationStr);
audioDuration = audioDuration/60/1000;
Debugger.LogMessageToFile("Audio duration: " + audioDuration);
}
}
catch (Exception e)
{
Debugger.LogMessageToFile("");
}
return audioDuration;
}
示例11: x264StartBtn_Click
private void x264StartBtn_Click(object sender, EventArgs e)
{
#region validation
if (string.IsNullOrEmpty(namevideo2))
{
ShowErrorMessage("请选择视频文件");
return;
}
if (!string.IsNullOrEmpty(namesub2) && !File.Exists(namesub2))
{
ShowErrorMessage("字幕文件不存在,请重新选择");
return;
}
if (string.IsNullOrEmpty(nameout2))
{
ShowErrorMessage("请选择输出文件");
return;
}
if (x264ExeComboBox.SelectedIndex == -1)
{
ShowErrorMessage("请选择X264程序");
return;
}
if (AudioEncoderComboBox.SelectedIndex != 0 && AudioEncoderComboBox.SelectedIndex != 1 && AudioEncoderComboBox.SelectedIndex != 5)
{
ShowWarningMessage("音频页面中的编码器未采用AAC将可能导致压制失败,建议将编码器改为QAAC、NeroAAC或FDKAAC。");
}
//防止未选择 x264 thread
if (x264ThreadsComboBox.SelectedIndex == -1)
{
x264ThreadsComboBox.SelectedIndex = 0;
}
//目标文件已经存在提示是否覆盖
if (File.Exists(x264OutTextBox.Text.Trim()))
{
DialogResult dgs = ShowQuestion("目标文件:\r\n\r\n" + x264OutTextBox.Text.Trim() + "\r\n\r\n已经存在,是否覆盖继续压制?", "目标文件已经存在");
if (dgs == DialogResult.No) return;
}
//如果是AVS复制到C盘根目录
if (Path.GetExtension(x264VideoTextBox.Text) == ".avs")
{
if (string.IsNullOrEmpty(Util.CheckAviSynth()) && string.IsNullOrEmpty(Util.CheckinternalAviSynth()))
{
if (ShowQuestion("检测到本机未安装avisynth无法继续压制,是否去下载安装", "avisynth未安装") == DialogResult.Yes)
Process.Start("http://sourceforge.net/projects/avisynth2/");
return;
}
//if (File.Exists(tempavspath)) File.Delete(tempavspath);
File.Copy(x264VideoTextBox.Text, tempavspath, true);
namevideo2 = tempavspath;
x264DemuxerComboBox.SelectedIndex = 0; //压制AVS始终使用分离器为auto
}
#endregion validation
string ext = Path.GetExtension(nameout2).ToLower();
bool hasAudio = false;
string inputName = Path.GetFileNameWithoutExtension(namevideo2);
string tempVideo = Path.Combine(tempfilepath, inputName + "_vtemp.mp4");
string tempAudio = Path.Combine(tempfilepath, inputName + "_atemp" + getAudioExt());
Util.ensureDirectoryExists(tempfilepath);
#region Audio
//检测是否含有音频
MediaInfo MI = new MediaInfo();
MI.Open(namevideo2);
string audio = MI.Get(StreamKind.Audio, 0, "Format");
if (!string.IsNullOrEmpty(audio))
hasAudio = true;
int audioMode = x264AudioModeComboBox.SelectedIndex;
if (!hasAudio && x264AudioModeComboBox.SelectedIndex != 1)
{
DialogResult r = ShowQuestion("原视频不包含音频流,音频模式是否改为无音频流?", "提示");
if (r == DialogResult.Yes)
audioMode = 1;
}
switch (audioMode)
{
case 0:
aextract = audiobat(namevideo2, tempAudio);
break;
case 1:
aextract = string.Empty;
break;
case 2:
if (audio.ToLower() == "aac")
{
tempAudio = Path.Combine(tempfilepath, inputName + "_atemp.aac");
aextract = ExtractAudio(namevideo2, tempAudio);
}
else
//.........这里部分代码省略.........
示例12: x264bat
public string x264bat(string input, string output, int pass = 1, string sub = "")
{
StringBuilder sb = new StringBuilder();
//keyint设为fps的10倍
MediaInfo MI = new MediaInfo();
MI.Open(input);
string frameRate = MI.Get(StreamKind.Video, 0, "FrameRate");
double fps;
string keyint = "-1";
if (double.TryParse(frameRate, out fps))
{
fps = Math.Round(fps);
keyint = (fps * 10).ToString();
}
if (Path.GetExtension(input) == ".avs")
sb.Append("\"" + workPath + "\\avs4x26x.exe\"" + " -L ");
sb.Append("\"" + Path.Combine(workPath, x264ExeComboBox.SelectedItem.ToString()) + "\"");
// 编码模式
switch (x264mode)
{
case 0: // 自定义
sb.Append(" " + x264CustomParameterTextBox.Text);
break;
case 1: // crf
sb.Append(" --crf " + x264CRFNum.Value);
break;
case 2: // 2pass
sb.Append(" --pass " + pass + " --bitrate " + x264BitrateNum.Value + " --stats \"" + Path.Combine(tempfilepath, Path.GetFileNameWithoutExtension(output)) + ".stats\"");
break;
}
if (x264mode != 0)
{
if (x264DemuxerComboBox.Text != "auto" && x264DemuxerComboBox.Text != string.Empty)
sb.Append(" --demuxer " + x264DemuxerComboBox.Text);
if (x264ThreadsComboBox.SelectedItem.ToString() != "auto" && x264ThreadsComboBox.SelectedItem.ToString() != string.Empty)
sb.Append(" --threads " + x264ThreadsComboBox.SelectedItem.ToString());
if (x264extraLine.Text != string.Empty)
sb.Append(" " + x264extraLine.Text);
else
sb.Append(" --preset 8 " + " -I " + keyint + " -r 4 -b 3 --me umh -i 1 --scenecut 60 -f 1:1 --qcomp 0.5 --psy-rd 0.3:0 --aq-mode 2 --aq-strength 0.8");
if (x264HeightNum.Value != 0 && x264WidthNum.Value != 0 && !MaintainResolutionCheckBox.Checked)
sb.Append(" --vf resize:" + x264WidthNum.Value + "," + x264HeightNum.Value + ",,,,lanczos");
}
if (!string.IsNullOrEmpty(sub))
{
string x264tmpline = sb.ToString();
if (x264tmpline.IndexOf("--vf") == -1)
sb.Append(" --vf subtitles --sub \"" + sub + "\"");
else
{
Regex r = new Regex("--vf\\s\\S*");
Match m = r.Match(x264tmpline);
sb.Insert(m.Index + 5, "subtitles/").Append(" --sub \"" + sub + "\"");
}
}
if (x264SeekNumericUpDown.Value != 0)
sb.Append(" --seek " + x264SeekNumericUpDown.Value.ToString());
if (x264FramesNumericUpDown.Value != 0)
sb.Append(" --frames " + x264FramesNumericUpDown.Value.ToString());
if (x264mode == 2 && pass == 1)
sb.Append(" -o NUL");
else if (!string.IsNullOrEmpty(output))
sb.Append(" -o " + "\"" + output + "\"");
if (!string.IsNullOrEmpty(input))
sb.Append(" \"" + input + "\"");
return sb.ToString();
}
示例13: btnAVS9_Click
private void btnAVS9_Click(object sender, EventArgs e)
{
x264DemuxerComboBox.SelectedIndex = 0; //压制AVS始终使用分离器为auto
if (string.IsNullOrEmpty(nameout9))
{
ShowErrorMessage("请选择输出文件");
return;
}
if (Path.GetExtension(nameout9).ToLower() != ".mp4")
{
ShowErrorMessage("仅支持MP4输出", "不支持的输出格式");
return;
}
if (File.Exists(txtout9.Text.Trim()))
{
DialogResult dgs = ShowQuestion("目标文件:\r\n\r\n" + txtout9.Text.Trim() + "\r\n\r\n已经存在,是否覆盖继续压制?", "目标文件已经存在");
if (dgs == DialogResult.No) return;
}
if (string.IsNullOrEmpty(Util.CheckAviSynth()) && string.IsNullOrEmpty(Util.CheckinternalAviSynth()))
{
if (ShowQuestion("检测到本机未安装avisynth无法继续压制,是否去下载安装", "avisynth未安装") == DialogResult.Yes)
Process.Start("http://sourceforge.net/projects/avisynth2/");
return;
}
string inputName = Path.GetFileNameWithoutExtension(namevideo9);
string tempVideo = Path.Combine(tempfilepath, inputName + "_vtemp.mp4");
string tempAudio = Path.Combine(tempfilepath, inputName + "_atemp" + getAudioExt());
Util.ensureDirectoryExists(tempfilepath);
string filepath = tempavspath;
//string filepath = workpath + "\\temp.avs";
File.WriteAllText(filepath, AVSScriptTextBox.Text, Encoding.Default);
//检测是否含有音频
bool hasAudio = false;
MediaInfo MI = new MediaInfo();
MI.Open(namevideo9);
string audio = MI.Get(StreamKind.Audio, 0, "Format");
if (!string.IsNullOrEmpty(audio)) { hasAudio = true; }
//audio
if (AVSwithAudioCheckBox.Checked && hasAudio)
{
if (!File.Exists(txtvideo9.Text))
{
ShowErrorMessage("请选择视频文件");
return;
}
aextract = audiobat(namevideo9, tempAudio);
}
else
aextract = string.Empty;
//video
if (x264ExeComboBox.SelectedItem.ToString().ToLower().Contains("x264"))
{
if (x264mode == 2)
x264 = x264bat(filepath, tempVideo, 1) + "\r\n" +
x264bat(filepath, tempVideo, 2);
else x264 = x264bat(filepath, tempVideo);
if (!AVSwithAudioCheckBox.Checked || !hasAudio)
x264 = x264.Replace(tempVideo, nameout9);
}
else if (x264ExeComboBox.SelectedItem.ToString().ToLower().Contains("x265"))
{
tempVideo = Path.Combine(tempfilepath, inputName + "_vtemp.hevc");
if (x264mode == 2)
x264 = x265bat(filepath, tempVideo, 1) + "\r\n" +
x265bat(filepath, tempVideo, 2);
else x264 = x265bat(filepath, tempVideo);
if (!AVSwithAudioCheckBox.Checked || !hasAudio)
{
x264 += "\r\n\"" + workPath + "\\mp4box.exe\" -add \"" + tempVideo + "#trackID=1:name=\" -new \"" + nameout9 + "\" \r\n";
x264 += "del \"" + tempVideo + "\"";
}
}
//mux
if (AVSwithAudioCheckBox.Checked && hasAudio) //如果包含音频
mux = boxmuxbat(tempVideo, tempAudio, nameout9);
else
mux = string.Empty;
auto = aextract + x264 + "\r\n" + mux + " \r\n";
auto += "\r\necho ===== one file is completed! =====\r\n";
LogRecord(auto);
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(GetCultureName());
WorkingForm wf = new WorkingForm(auto);
wf.Owner = this;
wf.Show();
//auto += "\r\ncmd";
//batpath = workPath + "\\x264avs.bat";
//File.WriteAllText(batpath, auto, Encoding.Default);
//Process.Start(batpath);
}
示例14: btnBatchMP4_Click
private void btnBatchMP4_Click(object sender, EventArgs e)
{
if (lbffmpeg.Items.Count != 0)
{
string ext = MuxFormatComboBox.Text;
string mux = "";
for (int i = 0; i < lbffmpeg.Items.Count; i++)
{
string filePath = lbffmpeg.Items[i].ToString();
//如果是源文件的格式和目标格式相同则跳过
if (Path.GetExtension(filePath).Contains(ext))
continue;
string finish = Path.ChangeExtension(filePath, ext);
aextract = "";
//检测音频是否需要转换为AAC
MediaInfo MI = new MediaInfo();
MI.Open(filePath);
string audio = MI.Get(StreamKind.Audio, 0, "Format");
if (audio.ToLower() != "aac")
{
mux += "\"" + workPath + "\\ffmpeg.exe\" -y -i \"" + lbffmpeg.Items[i].ToString() + "\" -c:v copy -c:a " + MuxAacEncoderComboBox.Text + " -strict -2 \"" + finish + "\" \r\n";
}
else
{
mux += "\"" + workPath + "\\ffmpeg.exe\" -y -i \"" + lbffmpeg.Items[i].ToString() + "\" -c copy \"" + finish + "\" \r\n";
}
}
mux += "\r\ncmd";
batpath = workPath + "\\mux.bat";
File.WriteAllText(batpath, mux, Encoding.Default);
LogRecord(mux);
Process.Start(batpath);
}
else ShowErrorMessage("请输入视频!");
}
示例15: MediaInfo
public string MediaInfo(string VideoName)
{
string info = "无视频信息";
if (File.Exists(VideoName))
{
MediaInfo MI = new MediaInfo();
MI.Open(VideoName);
//全局
string container = MI.Get(StreamKind.General, 0, "Format");
string bitrate = MI.Get(StreamKind.General, 0, "BitRate/String");
string duration = MI.Get(StreamKind.General, 0, "Duration/String1");
string fileSize = MI.Get(StreamKind.General, 0, "FileSize/String");
//视频
string vid = MI.Get(StreamKind.Video, 0, "ID");
string video = MI.Get(StreamKind.Video, 0, "Format");
string vBitRate = MI.Get(StreamKind.Video, 0, "BitRate/String");
string vSize = MI.Get(StreamKind.Video, 0, "StreamSize/String");
string width = MI.Get(StreamKind.Video, 0, "Width");
string height = MI.Get(StreamKind.Video, 0, "Height");
string risplayAspectRatio = MI.Get(StreamKind.Video, 0, "DisplayAspectRatio/String");
string risplayAspectRatio2 = MI.Get(StreamKind.Video, 0, "DisplayAspectRatio");
string frameRate = MI.Get(StreamKind.Video, 0, "FrameRate/String");
string bitDepth = MI.Get(StreamKind.Video, 0, "BitDepth/String");
string pixelAspectRatio = MI.Get(StreamKind.Video, 0, "PixelAspectRatio");
string encodedLibrary = MI.Get(StreamKind.Video, 0, "Encoded_Library");
string encodeTime = MI.Get(StreamKind.Video, 0, "Encoded_Date");
string codecProfile = MI.Get(StreamKind.Video, 0, "Codec_Profile");
string frameCount = MI.Get(StreamKind.Video, 0, "FrameCount");
//音频
string aid = MI.Get(StreamKind.Audio, 0, "ID");
string audio = MI.Get(StreamKind.Audio, 0, "Format");
string aBitRate = MI.Get(StreamKind.Audio, 0, "BitRate/String");
string samplingRate = MI.Get(StreamKind.Audio, 0, "SamplingRate/String");
string channel = MI.Get(StreamKind.Audio, 0, "Channel(s)");
string aSize = MI.Get(StreamKind.Audio, 0, "StreamSize/String");
string audioInfo = MI.Get(StreamKind.Audio, 0, "Inform") + MI.Get(StreamKind.Audio, 1, "Inform") + MI.Get(StreamKind.Audio, 2, "Inform") + MI.Get(StreamKind.Audio, 3, "Inform");
string videoInfo = MI.Get(StreamKind.Video, 0, "Inform");
info = Path.GetFileName(VideoName) + "\r\n" +
"容器:" + container + "\r\n" +
"总码率:" + bitrate + "\r\n" +
"大小:" + fileSize + "\r\n" +
"时长:" + duration + "\r\n" +
"\r\n" +
"视频(" + vid + "):" + video + "\r\n" +
"码率:" + vBitRate + "\r\n" +
"大小:" + vSize + "\r\n" +
"分辨率:" + width + "x" + height + "\r\n" +
"宽高比:" + risplayAspectRatio + "(" + risplayAspectRatio2 + ")" + "\r\n" +
"帧率:" + frameRate + "\r\n" +
"位深度:" + bitDepth + "\r\n" +
"像素宽高比:" + pixelAspectRatio + "\r\n" +
"编码库:" + encodedLibrary + "\r\n" +
"Profile:" + codecProfile + "\r\n" +
"编码时间:" + encodeTime + "\r\n" +
"总帧数:" + frameCount + "\r\n" +
"\r\n" +
"音频(" + aid + "):" + audio + "\r\n" +
"大小:" + aSize + "\r\n" +
"码率:" + aBitRate + "\r\n" +
"采样率:" + samplingRate + "\r\n" +
"声道数:" + channel + "\r\n" +
"\r\n====详细信息====\r\n" +
videoInfo + "\r\n" +
audioInfo + "\r\n"
;
MI.Close();
}
return info;
}