本文整理汇总了C#中MediaInfoLib.MediaInfo类的典型用法代码示例。如果您正苦于以下问题:C# MediaInfo类的具体用法?C# MediaInfo怎么用?C# MediaInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaInfo类属于MediaInfoLib命名空间,在下文中一共展示了MediaInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportVideo
internal static bool PopulateMediaSection
(FileInfo file, IMLSection moviesSection,
IMLSection tvSection, IMLSection musicSection,
IEnumerable<string> videoexts, int audioDuration,
string filesize, MediaInfo mi, DirectoryInfo parent,
string filecodec, bool isVideo, bool isAudio,
int videoDuration, string fileName, string parentName,
IEnumerable<string> combinedSceneTags)
{
if (String.IsNullOrEmpty(filecodec) && !isVideo && !isAudio)
return true;
//Debugger.LogMessageToFile(Environment.NewLine + "The file " + file.Name +
//" has been detected as a valid media file." + Environment.NewLine +
//" Proceeding to media type recognition...");
if (Helpers.UserCancels(MainImportingEngine.SpecialStatus, null))
return false;
ImportVideo(file, moviesSection, tvSection, videoexts, filesize, mi, parent,
filecodec, isVideo, videoDuration, fileName, parentName, combinedSceneTags);
if (Helpers.UserCancels(MainImportingEngine.SpecialStatus, null))
return false;
ImportAudio(file, musicSection, audioDuration, filesize, mi, filecodec, isAudio, fileName);
return true;
}
示例2: DetectAndImportMultipartMovie
internal static bool DetectAndImportMultipartMovie(IMLSection moviesSection, MediaInfo mediaInfo, bool isUNC,
FileSystemInfo dir, string externalID, ArrayList filesInDir,
string[] videoexts, int videosCount)
{
videosCount = CountVideosInDirectory(videoexts, videosCount, filesInDir);
if (!Settings.EnableMediaDetection || videosCount <= 1 || videosCount >= 4) return false;
MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress, "Detecting film parts...");
int parts = 0;
string locationTag = String.Empty;
int count = 1;
foreach (FileInfo file in filesInDir)
{
var fileIsVideo = DetermineIfFileIsVideoByExtensionMatching(videoexts, file);
parts = DetectMoviePart(parts, mediaInfo, videosCount, fileIsVideo, file, isUNC, ref count, ref locationTag,
ref externalID);
}
return OnMultiplePartsDetectionAddToMoviesSection(moviesSection, locationTag, externalID, parts, dir);
}
示例3: File
public File()
{
_mediaInfo = new MediaInfo();
VideoCodecs = new List<string>();
AudioCodecs = new List<string>();
AudioLanguages = new List<string>();
}
示例4: MediaViewModel
public MediaViewModel(string Name = "",
string ArtistName = "",
string AlbumName = "",
Uri Path = null,
String Length = "00:00:00")
{
Dictionary<String, String> tmp = new Dictionary<string, string>();
if (Path != null)
{
try
{
MediaInfo lol = new MediaInfo();
if (lol.Open(Uri.UnescapeDataString(Path.AbsolutePath)) == 1)
{
foreach (string entry in lol.Inform().Split('\n'))
{
var tokens = entry.Split(':');
if (tokens.Length == 2)
tmp[tokens[0].Trim()] = tokens[1].Trim();
}
lol.Close();
}
}
catch (Exception e)
{
MessageBox.Show("MediaInfo: "+ e.Message);
}
}
Song = new Media(tmp.ContainsKey("Track name") ? tmp["Track name"] : "",
tmp.ContainsKey("Performer") ? tmp["Performer"] : "",
tmp.ContainsKey("Album") ? tmp["Album"] : "",
Path, tmp.ContainsKey("Duration") ? getLength(tmp["Duration"]) : "");
}
示例5:
internal static bool ScanConstructedArrayAndImportMediaFiles
(IMLSection moviesSection,
IMLSection tvSection,
IMLSection musicSection,
ref IList<string> extensionsToIgnore,
string[] filmLocations,
string[] tvShowsLocations,
string[] musicLocations,
string[] videoExtensions,
string[] audioExtensions,
IEnumerable<string> combinedSceneTags,
ICollection<FileInfo> filesToImport, MediaInfo mediaInfo,
string pluginPath, IEnumerable<string> videoExtensionsCommon)
{
if (!Settings.UpdateMediaSectionOnEachImportedItem)
ImportingEngineHelpers.BeginUpdatingSections();
if ( !ImportFilesInArray(moviesSection, tvSection,
musicSection, ref extensionsToIgnore, filmLocations,
tvShowsLocations, musicLocations, videoExtensions, audioExtensions,
combinedSceneTags, filesToImport, mediaInfo, pluginPath, videoExtensionsCommon)
) return false;
if (!Settings.UpdateMediaSectionOnEachImportedItem)
ImportingEngineHelpers.EndUpdatingSections();
return true;
}
示例6: 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;
}
示例7: 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;
}
示例8: GetCodecs
private static void GetCodecs(MediaInfo mediaInfo, out string videoCodec, out string audioCodec, out string filecodec)
{
filecodec = GetFileCodec(mediaInfo);
videoCodec = GetVideoCodec(mediaInfo);
audioCodec = GetAudioCodec(mediaInfo);
}
示例9: 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 ";
}
示例10: Main
public static void Main()
{
MediaInfo MI = new MediaInfo();
//change the files accordingly, tested with .avi, .mpg, .mpeg - these should be enough
MI.Open("1.flv");
string display = "";
display += "FileName: " + MI.Get(0, 0, "FileName") + "\n";
display += "FileExtension: " + MI.Get(0, 0, "FileExtension") + "\n";
display += "Title: " + MI.Get(0, 0, "Title") + "\n";
display += "Subtitle: " + MI.Get(0, 0, "Title/More") + "\n";
display += "Tags: " + MI.Get(0, 0, "WM/Category") + "\n";
display += "Comments: " + MI.Get(0, 0, "Comment") + "\n";
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);
display += "Size: " + sizeInMBStr + " MB" + "\n";
display += "Date created: " + 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) + "\n";
display += "Date modified: " + MI.Get(0, 0, "File_Modified_Date").Substring(MI.Get(0, 0, "File_Modified_Date").IndexOf(" ") + 1, MI.Get(0, 0, "File_Modified_Date").LastIndexOf(".")-4) + "\n";
display += "\nVIDEO\n";
display += "Length: " + MI.Get(0, 0, "Duration/String3").Substring(0, MI.Get(0, 0, "Duration/String3").LastIndexOf(".")) + "\n";
display += "Frame width: " + MI.Get(StreamKind.Video, 0, "Width/String") + "\n";
display += "Frame height: " + MI.Get(StreamKind.Video, 0, "Height/String") + "\n";
if (MI.Get(StreamKind.Video, 0, "BitRate/String") != "")
display += "Data rate: " + MI.Get(StreamKind.Video, 0, "BitRate/String").Substring(0, MI.Get(StreamKind.Video, 0, "BitRate/String").LastIndexOf(" ")).Replace(" ", "") + " kbps" + "\n";
else
display += "Data rate:\n";
string frameRateOriStr = MI.Get(StreamKind.Video, 0, "FrameRate/String").Substring(0, MI.Get(StreamKind.Video, 0, "FrameRate/String").LastIndexOf(" ")).Replace(" ", "");
double frameRate = Double.Parse(frameRateOriStr);
string frameRateStr = String.Format("{0:0}", frameRate);
display += "Frame rate: " + frameRateStr + " fps" + "\n";
display += "\nAUDIO\n";
string bitrateOriStr = MI.Get(StreamKind.Audio, 0, "BitRate/String").Substring(0, MI.Get(StreamKind.Audio, 0, "BitRate/String").LastIndexOf(" ")).Replace(" ", "");
double bitrateRate = Double.Parse(bitrateOriStr);
string bitrateRateStr = String.Format("{0:0}", bitrateRate);
display += "Bitrate: " + bitrateRateStr + " kbps" + "\n";
display += "Channels: " + MI.Get(StreamKind.Audio, 0, "Channel(s)/String") + "\n";
string audioSampleRateOriStr = MI.Get(StreamKind.Audio, 0, "SamplingRate/String").Substring(0, MI.Get(StreamKind.Audio, 0, "SamplingRate/String").LastIndexOf(" ")).Replace(" ", "");
double audioSampleRate = Double.Parse(audioSampleRateOriStr);
string audioSampleRateStr = String.Format("{0:0}", audioSampleRate);
display += "Audio sample rate: " + audioSampleRateStr + " kHz" + "\n";
display += "\nMEDIA\n";
display += "Artist: " + MI.Get(0, 0, "Performer") + "\n";
display += "Year: " + MI.Get(0, 0, "Recorded_Date") + "\n";
display += "Genre: " + MI.Get(0, 0, "Genre") + "\n";
MI.Close();
Console.WriteLine(display);
}
示例11: ImportAudio
private static void ImportAudio(FileInfo file, IMLSection musicSection, int audioDuration, string filesize, MediaInfo mi,
string filecodec, bool isAudio, string fileName)
{
if (!MediaSectionPopulatorHelpers.ProceedToImportAudioTrack(file, isAudio))
return;
AddToMusicSection_ImportMediaInfo(file, musicSection, audioDuration, filesize, mi, filecodec, fileName);
}
示例12: 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");
}
示例13: 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();
}
示例14: 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);
}
示例15: AnalyzeMediaFileGetMediaInformation
internal static void AnalyzeMediaFileGetMediaInformation(FileSystemInfo file, MediaInfo mediaInfo, out int videoDuration,
out string videoCodec, out string audioCodec, out int audioDuration,
out string filesize, out string filecodec)
{
OpenMediaFileForProcessing(file, mediaInfo);
filesize = GetFileSize(mediaInfo);
GetCodecs(mediaInfo, out videoCodec, out audioCodec, out filecodec);
GetDurations(mediaInfo, out videoDuration, out audioDuration);
}