本文整理汇总了C#中Nikse.SubtitleEdit.Core.ContainerFormats.Matroska.MatroskaFile.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# MatroskaFile.Dispose方法的具体用法?C# MatroskaFile.Dispose怎么用?C# MatroskaFile.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Core.ContainerFormats.Matroska.MatroskaFile
的用法示例。
在下文中一共展示了MatroskaFile.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryReadVideoInfoViaMatroskaHeader
public static VideoInfo TryReadVideoInfoViaMatroskaHeader(string fileName)
{
var info = new VideoInfo { Success = false };
MatroskaFile matroska = null;
try
{
matroska = new MatroskaFile(fileName);
if (matroska.IsValid)
{
double frameRate;
int width;
int height;
double milliseconds;
string videoCodec;
matroska.GetInfo(out frameRate, out width, out height, out milliseconds, out videoCodec);
info.Width = width;
info.Height = height;
info.FramesPerSecond = frameRate;
info.Success = true;
info.TotalMilliseconds = milliseconds;
info.TotalSeconds = milliseconds / TimeCode.BaseUnit;
info.TotalFrames = info.TotalSeconds * frameRate;
info.VideoCodec = videoCodec;
}
}
catch (Exception)
{
throw;
}
finally
{
if (matroska != null)
{
matroska.Dispose();
}
}
return info;
}
示例2: buttonRipWave_Click
private void buttonRipWave_Click(object sender, EventArgs e)
{
if (listViewInputFiles.Items.Count == 0)
{
MessageBox.Show(Configuration.Settings.Language.BatchConvert.NothingToConvert);
return;
}
_converting = true;
buttonRipWave.Enabled = false;
progressBar1.Style = ProgressBarStyle.Blocks;
progressBar1.Maximum = listViewInputFiles.Items.Count;
progressBar1.Value = 0;
progressBar1.Visible = progressBar1.Maximum > 2;
buttonInputBrowse.Enabled = false;
buttonSearchFolder.Enabled = false;
_abort = false;
listViewInputFiles.BeginUpdate();
foreach (ListViewItem item in listViewInputFiles.Items)
item.SubItems[3].Text = "-";
listViewInputFiles.EndUpdate();
Refresh();
int index = 0;
while (index < listViewInputFiles.Items.Count && _abort == false)
{
var item = listViewInputFiles.Items[index];
Action<string> updateStatus = status =>
{
item.SubItems[3].Text = status;
Refresh();
};
updateStatus(Configuration.Settings.Language.AddWaveformBatch.ExtractingAudio);
string fileName = item.Text;
try
{
string targetFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".wav");
Process process;
try
{
string encoderName;
process = AddWaveform.GetCommandLineProcess(fileName, -1, targetFile, Configuration.Settings.General.VlcWaveTranscodeSettings, out encoderName);
labelInfo.Text = encoderName;
}
catch (DllNotFoundException)
{
if (MessageBox.Show(Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFound + Environment.NewLine +
Environment.NewLine + Configuration.Settings.Language.AddWaveform.GoToVlcMediaPlayerHomePage,
Configuration.Settings.Language.AddWaveform.VlcMediaPlayerNotFoundTitle,
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Process.Start("http://www.videolan.org/");
}
buttonRipWave.Enabled = true;
return;
}
process.Start();
while (!process.HasExited && !_abort)
{
Application.DoEvents();
}
// check for delay in matroska files
var audioTrackNames = new List<string>();
var mkvAudioTrackNumbers = new Dictionary<int, int>();
if (fileName.ToLower().EndsWith(".mkv", StringComparison.OrdinalIgnoreCase))
{
MatroskaFile matroska = null;
try
{
matroska = new MatroskaFile(fileName);
if (matroska.IsValid)
{
foreach (var track in matroska.GetTracks())
{
if (track.IsAudio)
{
if (track.CodecId != null && track.Language != null)
audioTrackNames.Add("#" + track.TrackNumber + ": " + track.CodecId.Replace("\0", string.Empty) + " - " + track.Language.Replace("\0", string.Empty));
else
audioTrackNames.Add("#" + track.TrackNumber);
mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, track.TrackNumber);
}
}
if (mkvAudioTrackNumbers.Count > 0)
{
_delayInMilliseconds = (int)matroska.GetTrackStartTime(mkvAudioTrackNumbers[0]);
}
}
}
catch
{
_delayInMilliseconds = 0;
}
finally
{
if (matroska != null)
{
matroska.Dispose();
}
//.........这里部分代码省略.........
示例3: AddWaveform_Shown
private void AddWaveform_Shown(object sender, EventArgs e)
{
Refresh();
var audioTrackNames = new List<string>();
var mkvAudioTrackNumbers = new Dictionary<int, int>();
int numberOfAudioTracks = 0;
if (labelVideoFileName.Text.Length > 1 && File.Exists(labelVideoFileName.Text))
{
if (labelVideoFileName.Text.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase))
{ // Choose for number of audio tracks in matroska files
MatroskaFile matroska = null;
try
{
matroska = new MatroskaFile(labelVideoFileName.Text);
if (matroska.IsValid)
{
foreach (var track in matroska.GetTracks())
{
if (track.IsAudio)
{
numberOfAudioTracks++;
if (track.CodecId != null && track.Language != null)
audioTrackNames.Add("#" + track.TrackNumber + ": " + track.CodecId.Replace("\0", string.Empty) + " - " + track.Language.Replace("\0", string.Empty));
else
audioTrackNames.Add("#" + track.TrackNumber);
mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, track.TrackNumber);
}
}
}
}
finally
{
if (matroska != null)
{
matroska.Dispose();
}
}
}
else if (labelVideoFileName.Text.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) || labelVideoFileName.Text.EndsWith(".m4v", StringComparison.OrdinalIgnoreCase))
{ // Choose for number of audio tracks in mp4 files
try
{
var mp4 = new MP4Parser(labelVideoFileName.Text);
var tracks = mp4.GetAudioTracks();
int i = 0;
foreach (var track in tracks)
{
i++;
if (track.Name != null && track.Mdia != null && track.Mdia.Mdhd != null && track.Mdia.Mdhd.LanguageString != null)
audioTrackNames.Add(i + ": " + track.Name + " - " + track.Mdia.Mdhd.LanguageString);
else if (track.Name != null)
audioTrackNames.Add(i + ": " + track.Name);
else
audioTrackNames.Add(i.ToString(CultureInfo.InvariantCulture));
}
numberOfAudioTracks = tracks.Count;
}
catch
{
}
}
// Choose audio track
if (numberOfAudioTracks > 1)
{
using (var form = new ChooseAudioTrack(audioTrackNames, _audioTrackNumber))
{
if (form.ShowDialog(this) == DialogResult.OK)
{
_audioTrackNumber = form.SelectedTrack;
}
else
{
DialogResult = DialogResult.Cancel;
return;
}
}
}
// check for delay in matroska files
if (labelVideoFileName.Text.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase))
{
MatroskaFile matroska = null;
try
{
matroska = new MatroskaFile(labelVideoFileName.Text);
if (matroska.IsValid)
{
_delayInMilliseconds = (int)matroska.GetTrackStartTime(mkvAudioTrackNumbers[_audioTrackNumber]);
}
}
catch
{
_delayInMilliseconds = 0;
}
finally
{
if (matroska != null)
{
matroska.Dispose();
//.........这里部分代码省略.........