Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# XamarinAndroidFFmpeg (Xamarin.FFmpeg)
FFmpeg library to run ffmeg commands over Xamarin.Android.
FFmpeg library to run ffmeg commands over Xamarin.Forms

## About
<ul>
<li>Created to support a solution that needed ffmpeg to control camera devices.</li>
</ul>
* Created to support a solution that needed ffmpeg to control camera devices.
* Edited to allow usage on Xamarin.Forms

## Big thanks
<ul>
<li>FFmpeg library adapted from https://github.com/neurospeech/xamarin-android-ffmpeg</li>
<li>Original library in java https://github.com/WritingMinds/ffmpeg-android-java</li>
</ul>
* FFmpeg library adapted from https://github.com/neurospeech/xamarin-android-ffmpeg
* Original library in java https://github.com/WritingMinds/ffmpeg-android-java

## License
<ul>
<li>MIT</li>
<li>Besides that, to use this library you must accept the licensing terms mentioned in the source project at https://github.com/WritingMinds/ffmpeg-android-java</li>
</ul>
* MIT
* Besides that, to use this library you must accept the licensing terms mentioned in the source project at https://github.com/WritingMinds/ffmpeg-android-java

## Nuget package
You can download Xamarin.FFmpeg package from Nuget Package Manager or run following command in Nuget Package Console.
```
Install-Package Xamarin.FFmpeg -Version 1.0.4
Install-Package Xamarin.FFmpeg
```
## Usage
On the way...

### Android

In MainActivity.cs before ``Forms.Init(this, bundle)``:
```cs
Xamarin.FFmpeg.Android.Init.Initialize(this.BaseContext);
```
51 changes: 51 additions & 0 deletions Xamarin.FFmpeg.Android/FFMpegSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;

namespace Xamarin.FFmpeg.Android
{
public class FFmpegSource : IFFmpegSource
{
public string FFmpegVersion { get; } = "3.0.1.1";
public string Url { get; set; }
public string Arch { get; }
public string Hash { get; }
public Func<string, bool> IsArch { get; }

public FFmpegSource(string arch, Func<string, bool> isArch, string hash)
{
Arch = arch;
IsArch = isArch;
Hash = hash;
Url = $"https://raw.githubusercontent.com/gperozzo/XamarinAndroidFFmpeg/master/binary/{FFmpegVersion}/{Arch}/ffmpeg";
}

public static FFmpegSource[] Sources = new FFmpegSource[] {
new FFmpegSource("arm", x=> !x.EndsWith("86"), "yRVoeaZATQdZIR/lZxMsIa/io9U="),
new FFmpegSource("x86", x=> x.EndsWith("86"), "mU4QKhrLEO0aROb9N7JOCJ/rVTA==")
};

internal static FFmpegSource Get()
{
string osArchitecture = Java.Lang.JavaSystem.GetProperty("os.arch");

foreach (var source in Sources)
{
if (source.IsArch(osArchitecture))
return source;
}

return null;
}

public void SetUrl(string url)
{
Url = url;
}

public bool IsHashMatch(byte[] data)
{
var sha = System.Security.Cryptography.SHA1.Create();
string h = Convert.ToBase64String(sha.ComputeHash(data));
return h == Hash;
}
}
}
Loading