2014-01-05 03:50:29 +00:00
|
|
|
|
using System;
|
2014-01-12 01:01:27 +00:00
|
|
|
|
#if __MonoCS__
|
2014-01-22 10:26:51 +00:00
|
|
|
|
using Mono.Unix.Native;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.IO;
|
2014-01-12 01:01:27 +00:00
|
|
|
|
#endif
|
2014-01-05 03:50:29 +00:00
|
|
|
|
|
2013-10-13 03:39:22 +00:00
|
|
|
|
namespace MediaBrowser.ServerApplication.FFMpeg
|
|
|
|
|
{
|
|
|
|
|
public static class FFMpegDownloadInfo
|
|
|
|
|
{
|
2014-01-05 03:50:29 +00:00
|
|
|
|
// Windows builds: http://ffmpeg.zeranoe.com/builds/
|
|
|
|
|
// Linux builds: http://ffmpeg.gusari.org/static/
|
|
|
|
|
|
|
|
|
|
public static string Version = ffmpegOsType("Version");
|
|
|
|
|
|
|
|
|
|
public static string[] FfMpegUrls = GetDownloadUrls();
|
|
|
|
|
|
|
|
|
|
public static string FFMpegFilename = ffmpegOsType("FFMpegFilename");
|
|
|
|
|
public static string FFProbeFilename = ffmpegOsType("FFProbeFilename");
|
|
|
|
|
|
|
|
|
|
public static string ArchiveType = ffmpegOsType("ArchiveType");
|
2013-10-13 03:39:22 +00:00
|
|
|
|
|
2014-01-05 03:50:29 +00:00
|
|
|
|
private static string ffmpegOsType(string arg)
|
|
|
|
|
{
|
|
|
|
|
OperatingSystem os = Environment.OSVersion;
|
|
|
|
|
PlatformID pid = os.Platform;
|
|
|
|
|
switch (pid)
|
|
|
|
|
{
|
|
|
|
|
case PlatformID.Win32NT:
|
|
|
|
|
switch (arg)
|
|
|
|
|
{
|
|
|
|
|
case "Version":
|
|
|
|
|
return "20140105";
|
|
|
|
|
case "FFMpegFilename":
|
|
|
|
|
return "ffmpeg.exe";
|
|
|
|
|
case "FFProbeFilename":
|
|
|
|
|
return "ffprobe.exe";
|
|
|
|
|
case "ArchiveType":
|
|
|
|
|
return "7z";
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-01-12 01:01:27 +00:00
|
|
|
|
|
2014-01-22 10:26:51 +00:00
|
|
|
|
#if __MonoCS__
|
2014-01-05 03:50:29 +00:00
|
|
|
|
case PlatformID.Unix:
|
2014-01-22 10:26:51 +00:00
|
|
|
|
if (PlatformDetection.IsMac)
|
2014-01-05 03:50:29 +00:00
|
|
|
|
{
|
2014-01-22 10:26:51 +00:00
|
|
|
|
if (PlatformDetection.IsX86_64)
|
2014-01-12 01:01:27 +00:00
|
|
|
|
{
|
2014-01-22 10:26:51 +00:00
|
|
|
|
switch (arg)
|
|
|
|
|
{
|
|
|
|
|
case "Version":
|
|
|
|
|
return "20131121";
|
|
|
|
|
case "FFMpegFilename":
|
|
|
|
|
return "ffmpeg";
|
|
|
|
|
case "FFProbeFilename":
|
|
|
|
|
return "ffprobe";
|
|
|
|
|
case "ArchiveType":
|
|
|
|
|
return "gz";
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-01-12 01:01:27 +00:00
|
|
|
|
}
|
2014-01-05 03:50:29 +00:00
|
|
|
|
}
|
2014-01-22 10:26:51 +00:00
|
|
|
|
if (PlatformDetection.IsLinux)
|
2014-01-12 01:01:27 +00:00
|
|
|
|
{
|
2014-01-22 10:26:51 +00:00
|
|
|
|
if (PlatformDetection.IsX86)
|
|
|
|
|
{
|
|
|
|
|
switch (arg)
|
|
|
|
|
{
|
|
|
|
|
case "Version":
|
|
|
|
|
return "linux_x86_20140118";
|
|
|
|
|
case "FFMpegFilename":
|
|
|
|
|
return "ffmpeg";
|
|
|
|
|
case "FFProbeFilename":
|
|
|
|
|
return "ffprobe";
|
|
|
|
|
case "ArchiveType":
|
|
|
|
|
return "gz";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (PlatformDetection.IsX86_64)
|
2014-01-12 01:01:27 +00:00
|
|
|
|
{
|
2014-01-22 10:26:51 +00:00
|
|
|
|
// Linux on x86 or x86_64
|
|
|
|
|
switch (arg)
|
|
|
|
|
{
|
|
|
|
|
case "Version":
|
|
|
|
|
return "linux_x86_64_20140118";
|
|
|
|
|
case "FFMpegFilename":
|
|
|
|
|
return "ffmpeg";
|
|
|
|
|
case "FFProbeFilename":
|
|
|
|
|
return "ffprobe";
|
|
|
|
|
case "ArchiveType":
|
|
|
|
|
return "gz";
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-01-12 01:01:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-22 10:26:51 +00:00
|
|
|
|
// Unsupported Unix platform
|
|
|
|
|
return "";
|
|
|
|
|
#endif
|
2014-01-05 03:50:29 +00:00
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2013-10-13 03:39:22 +00:00
|
|
|
|
|
2014-01-05 03:50:29 +00:00
|
|
|
|
private static string[] GetDownloadUrls()
|
|
|
|
|
{
|
|
|
|
|
var pid = Environment.OSVersion.Platform;
|
|
|
|
|
|
|
|
|
|
switch (pid)
|
|
|
|
|
{
|
|
|
|
|
case PlatformID.Win32NT:
|
|
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
"http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20140105-git-70937d9-win32-static.7z",
|
|
|
|
|
"https://www.dropbox.com/s/oghurnp5zh292ry/ffmpeg-20140105-git-70937d9-win32-static.7z?dl=1"
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-12 01:01:27 +00:00
|
|
|
|
#if __MonoCS__
|
2014-01-22 10:26:51 +00:00
|
|
|
|
case PlatformID.Unix:
|
|
|
|
|
if (PlatformDetection.IsMac && PlatformDetection.IsX86_64)
|
2014-01-05 03:50:29 +00:00
|
|
|
|
{
|
2014-01-12 01:01:27 +00:00
|
|
|
|
return new[]
|
|
|
|
|
{
|
2014-03-04 04:53:48 +00:00
|
|
|
|
"https://www.dropbox.com/s/n188rxbulqem8ry/ffmpeg-osx-20131121.gz?dl=1"
|
2014-01-12 01:01:27 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2014-01-22 10:26:51 +00:00
|
|
|
|
|
|
|
|
|
if (PlatformDetection.IsLinux)
|
2014-01-12 01:01:27 +00:00
|
|
|
|
{
|
2014-01-22 10:26:51 +00:00
|
|
|
|
if (PlatformDetection.IsX86)
|
2014-01-12 01:01:27 +00:00
|
|
|
|
{
|
2014-01-22 10:26:51 +00:00
|
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
"http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.2014-01-18.tar.gz",
|
|
|
|
|
"https://www.dropbox.com/s/b7nkg71sil812hp/ffmpeg.static.32bit.2014-01-04.tar.gz?dl=1"
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PlatformDetection.IsX86_64)
|
|
|
|
|
{
|
|
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
"http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.2014-01-18.tar.gz"
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-12 01:01:27 +00:00
|
|
|
|
}
|
2014-01-22 10:26:51 +00:00
|
|
|
|
|
|
|
|
|
//No Unix version available
|
|
|
|
|
return new string[] {};
|
2014-03-04 04:53:48 +00:00
|
|
|
|
#endif
|
2014-01-05 03:50:29 +00:00
|
|
|
|
}
|
|
|
|
|
return new string[] {};
|
|
|
|
|
}
|
2014-01-22 10:26:51 +00:00
|
|
|
|
}
|
2014-01-12 01:01:27 +00:00
|
|
|
|
|
2014-01-22 10:26:51 +00:00
|
|
|
|
#if __MonoCS__
|
|
|
|
|
public static class PlatformDetection
|
|
|
|
|
{
|
|
|
|
|
public readonly static bool IsWindows;
|
|
|
|
|
public readonly static bool IsMac;
|
|
|
|
|
public readonly static bool IsLinux;
|
|
|
|
|
public readonly static bool IsX86;
|
|
|
|
|
public readonly static bool IsX86_64;
|
|
|
|
|
public readonly static bool IsArm;
|
2014-01-12 01:01:27 +00:00
|
|
|
|
|
2014-01-22 10:26:51 +00:00
|
|
|
|
static PlatformDetection ()
|
2014-01-12 01:01:27 +00:00
|
|
|
|
{
|
2014-01-22 10:26:51 +00:00
|
|
|
|
IsWindows = Path.DirectorySeparatorChar == '\\';
|
|
|
|
|
|
|
|
|
|
//Don't call uname on windows
|
|
|
|
|
if (!IsWindows)
|
|
|
|
|
{
|
|
|
|
|
Utsname uname;
|
|
|
|
|
var callResult = Syscall.uname(out uname);
|
|
|
|
|
if (callResult == 0)
|
|
|
|
|
{
|
|
|
|
|
IsMac = uname.sysname == "Darwin";
|
|
|
|
|
IsLinux = !IsMac && uname.sysname == "Linux";
|
|
|
|
|
|
|
|
|
|
Regex archX86 = new Regex("(i|I)[3-6]86");
|
|
|
|
|
IsX86 = archX86.IsMatch(uname.machine);
|
|
|
|
|
IsX86_64 = !IsX86 && uname.machine == "x86_64";
|
|
|
|
|
IsArm = !IsX86 && !IsX86 && uname.machine.StartsWith("arm");
|
2014-01-12 01:01:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-22 10:26:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (System.Environment.Is64BitOperatingSystem)
|
|
|
|
|
IsX86_64 = true;
|
|
|
|
|
else
|
|
|
|
|
IsX86 = true;
|
|
|
|
|
}
|
2014-01-12 01:01:27 +00:00
|
|
|
|
}
|
2013-10-13 03:39:22 +00:00
|
|
|
|
}
|
2014-01-22 10:26:51 +00:00
|
|
|
|
#endif
|
2013-10-13 03:39:22 +00:00
|
|
|
|
}
|