private ArrayList GetSubtitleTrackID(string fname) { ArrayList bleh = new ArrayList(); MediaInfo mi = new MediaInfo(fname); if (mi.TextCount > 0) { foreach (TextTrack tt in mi.Text) { switch (tt.CodecString.ToLower()) { case "ass": case "utf-8": bleh.Add(tt); break; } } } if (bleh.Count > 0) return bleh; return null; }
/* public static bool MediaInfoExist() { string dll = Configuration.Config.GetFolder(Configuration.Config.Dir.Base) + "\\MediaInfo.dll"; bool enable = File.Exists(dll); if (!enable) { Log.Error("MediaInfoWrapper: disabled because \"{0}\" is missing", dll); } return enable; }*/ public MediaInfoWrapper(string strFile) { /*if (!MediaInfoExist()) { return; }*/ try { _mI = new MediaInfo(); _mI.Open(strFile); if (_videoDuration == 0) { int.TryParse(_mI.Get(StreamKind.Video, 0, "Duration"), out _videoDuration); } Log.Debug("MediaInfoWrapper.MediaInfoWrapper: Inspecting media : {0}", strFile); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: VideoDuration : {0}", _videoDuration); } catch (Exception) { Log.Error( "MediaInfoWrapper.MediaInfoWrapper: Error occurred while scanning media: '{0}'", strFile); } finally { if (_mI != null) { _mI.Close(); } } }
private void generateMetaFile() { metaFile = Path.ChangeExtension(job.Output, ".meta"); MuxSettings settings = job.Settings; CultureInfo ci = new CultureInfo("en-us"); using (StreamWriter sw = new StreamWriter(metaFile, false, Encoding.Default)) { string vcodecID = ""; string extra = ""; sw.Write("MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr --vbv-len=500"); // mux options if (settings.SplitSize.HasValue) sw.Write(" --split-size " + settings.SplitSize.Value.MB + "MB"); if (!string.IsNullOrEmpty(settings.DeviceType) && settings.DeviceType != "Standard") { switch (settings.DeviceType) { case "Blu-ray": sw.Write(" --blu-ray"); break; case "AVCHD": sw.Write(" --avchd"); break; } if (!string.IsNullOrEmpty(settings.ChapterFile)) // a chapter file is defined { string chapterTimeLine = VideoUtil.getChapterTimeLine(settings.ChapterFile); sw.Write(" --custom-chapters" + chapterTimeLine); } job.Output = Path.ChangeExtension(job.Output, ""); // remove m2ts file extension - use folder name only with this mode } if (!string.IsNullOrEmpty(settings.VideoInput)) { if (VideoUtil.detecAVCStreamFromFile(settings.VideoInput) == true) { vcodecID = "V_MPEG4/ISO/AVC"; extra = " insertSEI, contSPS"; if (settings.VideoInput.ToLower().EndsWith(".mp4")) extra += " , track=1"; } else if (settings.VideoInput.ToLower().EndsWith(".m2v")) vcodecID = "V_MPEG2"; else vcodecID = "V_MS/VFW/WVC1"; sw.Write("\n" + vcodecID + ", "); sw.Write("\"" + settings.VideoInput + "\""); } if (!string.IsNullOrEmpty(settings.MuxedInput)) { if (VideoUtil.detecAVCStreamFromFile(settings.MuxedInput) == true) { vcodecID = "V_MPEG4/ISO/AVC"; extra = " insertSEI, contSPS"; if (settings.MuxedInput.ToLower().EndsWith(".mp4")) extra += " , track=1"; } else if (settings.MuxedInput.ToLower().EndsWith(".m2v")) vcodecID = "V_MPEG2"; else vcodecID = "V_MS/VFW/WVC1"; sw.Write(vcodecID + ", "); sw.Write("\"" + settings.MuxedInput + "\""); } if (settings.Framerate.HasValue) { string fpsString = settings.Framerate.Value.ToString(ci); sw.Write(", fps=" + fpsString); } if (extra != "") sw.Write(" ," + extra); foreach (object o in settings.AudioStreams) { MuxStream stream = (MuxStream)o; string acodecID = ""; if (stream.path.ToLower().EndsWith(".ac3")) acodecID = "A_AC3"; else if (stream.path.ToLower().EndsWith(".aac")) acodecID = "A_AAC"; else if (stream.path.ToLower().EndsWith(".dts")) acodecID = "A_DTS"; sw.Write("\n" + acodecID + ", "); sw.Write("\"" + stream.path + "\""); if (stream.delay != 0) sw.Write(", timeshift={0}ms", stream.delay); if (!string.IsNullOrEmpty(stream.language)) { foreach (KeyValuePair<string, string> strLanguage in LanguageSelectionContainer.Languages) { if (stream.language.ToLower().Equals(strLanguage.Key.ToLower())) { sw.Write(", lang=" + strLanguage.Value); break; } } } } foreach (object o in settings.SubtitleStreams) { MuxStream stream = (MuxStream)o; string scodecID = ""; if (stream.path.ToLower().EndsWith(".srt")) scodecID = "S_TEXT/UTF8"; else scodecID = "S_HDMV/PGS"; // sup files sw.Write("\n" + scodecID + ", "); sw.Write("\"" + stream.path + "\""); if (stream.delay != 0) sw.Write(", timeshift={0}ms", stream.delay); if (stream.path.ToLower().EndsWith(".srt")) { MediaInfo info = new MediaInfo(settings.VideoInput); sw.Write(", video-width={0}, video-height={1}, fps={2}", info.Video[0].Width, info.Video[0].Height, settings.Framerate.Value.ToString(ci)); } if (!string.IsNullOrEmpty(stream.language)) { foreach (KeyValuePair<string, string> strLanguage in LanguageSelectionContainer.Languages) { if (stream.language.ToLower().Equals(strLanguage.Key.ToLower())) { sw.Write(", lang=" + strLanguage.Value); break; } } } } job.FilesToDelete.Add(metaFile); } }
private void RetrieveMediaFileInfo(string fname) { setStatus("Cargando información de MediaInfo.dll ..."); MediaInfo mi = new MediaInfo(fname); setStatus("Información actualizada."); TreeNode nodo; int idx = 1; treeView1.Nodes.Clear(); if (mi.VideoCount > 0) { TreeNode vidNode; nodo = vidNode = treeView1.Nodes.Add("Vídeo"); foreach (VideoTrack vi in mi.Video) { nodo = vidNode.Nodes.Add("Stream "+(idx++)); nodo.Nodes.Add("Códec : "+vi.Codec+" ("+vi.CodecInfo+")"); nodo.Nodes.Add("Resolución : " + vi.Width+"x"+vi.Height); nodo.Nodes.Add("Frames : " + vi.FrameCount); nodo.Nodes.Add("Fps : " + vi.FrameRateString); nodo.Nodes.Add("Bitrate : " + vi.BitRateString); nodo.Nodes.Add("Duración : " + vi.DurationString); nodo.Nodes.Add("Idioma : " + vi.LanguageString); nodo.Nodes.Add("Título : " + vi.Title); nodo.Nodes.Add("ID : " + vi.ID); } } idx = 1; if (mi.AudioCount > 0) { TreeNode audNode; nodo = audNode = treeView1.Nodes.Add("Audio"); foreach (AudioTrack au in mi.Audio) { nodo = audNode.Nodes.Add("Stream "+(idx++)); nodo.Nodes.Add("Códec : " + au.CodecID + " (" + au.CodecIDInfo + ")"); nodo.Nodes.Add("Canales : "+au.ChannelsString); nodo.Nodes.Add("Bitrate : " + au.BitRateString + " (" + au.BitRateMode + ")"); nodo.Nodes.Add("Samples : " + au.SamplingCount); nodo.Nodes.Add("Sample rate : " + au.SamplingRateString); nodo.Nodes.Add("Duración : "+au.DurationString); nodo.Nodes.Add("Idioma : " + au.LanguageString); nodo.Nodes.Add("Retraso : "+au.Delay); nodo.Nodes.Add("ID : " + au.ID); } } idx = 1; if (mi.TextCount > 0) { TreeNode subNode; nodo = subNode = treeView1.Nodes.Add("Texto"); foreach (TextTrack tt in mi.Text) { nodo = subNode.Nodes.Add("Stream " + (idx++)); nodo.Nodes.Add("Formato : " + tt.Codec + " (" + tt.CodecString + ")"); nodo.Nodes.Add("Idioma : " + tt.LanguageString); nodo.Nodes.Add("Retraso : " + tt.Delay); nodo.Nodes.Add("ID : " + tt.ID); } } treeView1.ExpandAll(); }
private bool HasVideo(string fname) { MediaInfo mi = new MediaInfo(fname); return (mi.VideoCount > 0); }
private bool HasAudio(string fname) { MediaInfo mi = new MediaInfo(fname); return (mi.AudioCount > 0); }