switch to LibVlc

This commit is contained in:
Paddy Xu
2017-08-01 21:28:50 +03:00
parent 5ac88dbd1c
commit 94075595de
342 changed files with 5522 additions and 6854 deletions

View File

@@ -22,60 +22,6 @@ using System.Windows.Data;
namespace QuickLook.Plugin.VideoViewer
{
public sealed class DecimalToTimeSpanConverter : DependencyObject, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return "00:00:00";
var time = TimeSpan.FromSeconds((double) (decimal) value);
return time.ToString(@"hh\:mm\:ss");
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public sealed class DoubleToTimeSpanConverter : DependencyObject, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return "00:00:00";
var time = TimeSpan.FromSeconds((double) value);
return time.ToString(@"hh\:mm\:ss");
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public sealed class BooleanToVisibilityVisibleConverter : DependencyObject, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return Visibility.Visible;
var v = (bool) value;
return v ? Visibility.Visible : Visibility.Collapsed;
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public sealed class BooleanToVisibilityHiddenConverter : DependencyObject, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -93,41 +39,4 @@ namespace QuickLook.Plugin.VideoViewer
throw new NotImplementedException();
}
}
public class TimeSpanToSecondsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is TimeSpan) return ((TimeSpan) value).TotalSeconds;
if (value is Duration)
return ((Duration) value).HasTimeSpan ? ((Duration) value).TimeSpan.TotalSeconds : 0d;
return 0d;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var result = TimeSpan.FromTicks((long) Math.Round(TimeSpan.TicksPerSecond * (double) value, 0));
if (targetType == typeof(TimeSpan)) return result;
if (targetType == typeof(Duration)) return new Duration(result);
return Activator.CreateInstance(targetType);
}
}
public class DurationToTimeSpanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var val = (Duration) value;
return val.HasTimeSpan ? val.TimeSpan : TimeSpan.Zero;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,104 +0,0 @@
// Copyright © 2017 Paddy Xu
//
// This file is part of QuickLook program.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Xml.XPath;
namespace QuickLook.Plugin.VideoViewer.FFmpeg
{
internal class FFprobe
{
private static readonly string _probePath =
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FFmpeg\\",
App.Is64Bit ? "x64\\" : "x86\\", "ffprobe.exe");
private XPathNavigator infoNavigator;
public FFprobe(string media)
{
Run(media);
}
private bool Run(string media)
{
var result = string.Empty;
using (var p = new Process())
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = _probePath;
p.StartInfo.Arguments = $"-v quiet -print_format xml -show_streams -show_format \"{media}\"";
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
p.Start();
p.WaitForExit();
result = p.StandardOutput.ReadToEnd();
}
if (string.IsNullOrWhiteSpace(result))
return false;
ParseResult(result);
return true;
}
private void ParseResult(string result)
{
infoNavigator = new XPathDocument(new StringReader(result)).CreateNavigator();
}
public bool CanDecode()
{
var info = infoNavigator.SelectSingleNode("/ffprobe/format[@probe_score>25]");
return info != null;
}
public string GetFormatName()
{
var format = infoNavigator.SelectSingleNode("/ffprobe/format/@format_name")?.Value;
return format ?? string.Empty;
}
public string GetFormatLongName()
{
var format = infoNavigator.SelectSingleNode("/ffprobe/format/@format_long_name")?.Value;
return format ?? string.Empty;
}
public Size GetViewSize()
{
var width = infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_width")
?.Value;
var height = infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_height")
?.Value;
if (width == null || height == null)
return Size.Empty;
return new Size(double.Parse(width), double.Parse(height));
}
}
}

Some files were not shown because too many files have changed in this diff Show More