Skip to content

Commit

Permalink
Multiple enhancements, improved build process better perfromance Rele…
Browse files Browse the repository at this point in the history
…ase 2.90 ready! (#364)

* starting with UWP implementation using Shared code project.

* continued work on migrating to UWP using shared code. Still WIP

* continued UWP initial migration

* first successful build of UWP class library

* very early version of UWP renderers

* BUMP -- CUstom marchallers not supported in UWP -- PAIN

* exploring direct compilation using shared project code. Looking very good!

* minor change to position dependency property

* More reorganization, fixing ruleset

* upgrading to latest version of analyzers

* restoring stylecop ruleset

* continued reorganization of code and APIs

* continued code reorganization

* Portable property mapper

* removing region

* adding GuiTimer TODO

* COntinued portable refactoring

* continued refactoring and improved API access.. still missing GUI context stuff

* More library refactoring. still thinking on how to por GuiContext

* continued migration to portable IGuiContext. Still missing GuiTimer portability

* refactoring Media namespace to Common

* improved design-time detection

* finished cleaning up project structure and API

* Toasty!

* Minor change in notification

* implementing option to disable fluid seeking. See issue #360

* adding is at end of stream media state property

* taskbar item info effects.

* partial class decalaration fixes.

* fixing issue #361. Reorganizing events, adding Loaded and unloaded handlers. Removing the need for application context in design time support and other fringe scenarios. See issue #326. Loaded and Unloaded events also fix issue #287 to implement predictable behavior.

* streamlinign generation of nuget packages

* updating README

* updating screenshot

* getting ready for 2.90 release
  • Loading branch information
mariodivece authored Mar 31, 2019
1 parent e66028d commit c17fca9
Show file tree
Hide file tree
Showing 258 changed files with 4,504 additions and 6,712 deletions.
21 changes: 10 additions & 11 deletions StyleCop.Analyzers.ruleset → Analyzers.ruleset
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for StyleCop.Analyzers" Description="Code analysis rules for StyleCop.Analyzers.csproj." ToolsVersion="15.0">
<RuleSet Name="Rules for StyleCop.Analyzers" Description="StyleCop Rules" ToolsVersion="16.0">
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
<Rule Id="UseConfigureAwait" Action="Warning" />
</Rules>
Expand Down Expand Up @@ -79,7 +79,7 @@
<Rule Id="IDE0002" Action="Info" />
<Rule Id="IDE0003" Action="Info" />
<Rule Id="IDE0004" Action="Info" />
<Rule Id="IDE0005" Action="Info" />
<Rule Id="IDE0005" Action="Error" />
<Rule Id="IDE0007" Action="Info" />
<Rule Id="IDE0007WithoutSuggestion" Action="Info" />
<Rule Id="IDE0008" Action="None" />
Expand Down Expand Up @@ -142,33 +142,32 @@
<Rule Id="IDE0033" Action="Warning" />
<Rule Id="IDE0033WithoutSuggestion" Action="Warning" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
<Rule Id="CA1031" Action="None" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1000" Action="None" />
<Rule Id="SA1001" Action="Hidden" />
<Rule Id="SA1001" Action="None" />
<Rule Id="SA1011" Action="None" />
<Rule Id="SA1021" Action="Hidden" />
<Rule Id="SA1028" Action="Info" />
<Rule Id="SA1021" Action="None" />
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1116" Action="None" />
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1123" Action="None" />
<Rule Id="SA1124" Action="None" />
<Rule Id="SA1135" Action="None" />
<Rule Id="SA1208" Action="None" />
<Rule Id="SA1305" Action="Warning" />
<Rule Id="SA1306" Action="None" />
<Rule Id="SA1308" Action="None" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1402" Action="None" />
<Rule Id="SA1412" Action="Warning" />
<Rule Id="SA1413" Action="None" />
<Rule Id="SA1501" Action="None" />
<Rule Id="SA1502" Action="Hidden" />
<Rule Id="SA1502" Action="None" />
<Rule Id="SA1503" Action="None" />
<Rule Id="SA1507" Action="Error" />
<Rule Id="SA1516" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1601" Action="None" />
<Rule Id="SA1623" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SX1101" Action="Warning" />
</Rules>
</RuleSet>
7 changes: 4 additions & 3 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
=================================================================================================
NAudio (Unosquare.FFME.Renderers.Wave)
=================================================================================================
Files under the Unosquare.FFME.Rendering.Wave namespace are derived from the NAudio Library
Commit URL (May 13, 2017):
Files under the Unosquare.FFME.Rendering.Wave namespace are derived and heavily modified from the
NAudio Library. Commit URL (May 13, 2017):
https://github.com/naudio/NAudio/commit/17c8ca2ff8c64ce1f5e6b00f74e54d7e9bccaa03

Microsoft Public License (Ms-PL)
Expand Down Expand Up @@ -118,7 +118,8 @@ and non-infringement.
SoundTouch audio processing library (SoundTouch.cs)
=================================================================================================
File SoundTouch.cs was modified to include comments, remove notices and set a more
concise namespace.
concise namespace. The file was supplied to the auther as an enhancement and now are part of the
wrapper offered in the SoundTouch website.

Copyright (c) Olli Parviainen
http://www.surina.net/soundtouch
Expand Down
76 changes: 22 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,57 @@

## Current NuGet Release Status
- If you would like to support this project, you can show your appreciation via [PayPal.Me](https://www.paypal.me/mariodivece/50usd)
- Current Status: (2019-03-16) - Release 4.1.280 is now available, (see the <a href="https://github.com/unosquare/ffmediaelement/releases">Releases</a>)
- Current Status: (2019-03-31) - Release 4.1.290 is now available, (see the <a href="https://github.com/unosquare/ffmediaelement/releases">Releases</a>)
- NuGet Package available here: https://www.nuget.org/packages/FFME.Windows/
- FFmpeg Version: 4.1 <a href="https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.1.1-win32-shared.zip">32-bit</a> or <a href="https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.1.1-win64-shared.zip">64-bit</a>
- FFmpeg Version: 4.1.1 <a href="https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.1.1-win32-shared.zip">32-bit</a> or <a href="https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.1.1-win64-shared.zip">64-bit</a>

*Please note the current NuGet realease might require a different version of the FFmpeg binaries than the ones of the current state of the source code.*

## Quick Usage Guide for WPF Apps

Here is a quick guide on how to get started.
1. Open Visual Studio (v2017 or v2019 recommended), and create a new WPF Application. Target Framework must be 4.6.1 or above.
1. Open Visual Studio (v2019 recommended), and create a new WPF Application. Target Framework must be 4.6.1 or above.
2. Install the NuGet Package from your Package Manager Console: `PM> Install-Package FFME.Windows`
3. You need FFmpeg shared binaries (64 or 32 bit, depending on your app's target architecture). Build your own or download a compatible build from [Zeranoe FFmpeg Builds site](https://ffmpeg.zeranoe.com/builds/).
3. You need FFmpeg **shared** binaries (64 or 32 bit, depending on your app's target architecture). Build your own or download a compatible build from [Zeranoe FFmpeg Builds site](https://ffmpeg.zeranoe.com/builds/).
4. Your FFmpeg build should have a `bin` folder with 3 exe files and some dll files. Copy all those files to a folder such as `c:\ffmpeg`
5. Within you application's startup code (`Main` method), set `Unosquare.FFME.MediaElement.FFmpegDirectory = @"c:\ffmpeg";`.
5. Within you application's startup code (`Main` method), set `Unosquare.FFME.Library.FFmpegDirectory = @"c:\ffmpeg";`.
6. Use the FFME `MediaElement` control as any other WPF control.
For example: In your `MainForm.xaml`, add the namespace: `xmlns:ffme="clr-namespace:Unosquare.FFME;assembly=ffme.win"` and then add the FFME control your window's XAML: `<ffme:MediaElement x:Name="Media" Background="Gray" LoadedBehavior="Play" UnloadedBehavior="Manual" />`
7. To play files or streams, simply set the `Source` property: `Media.Source = new Uri(@"c:\your-file-here");`. Since `Source` is a dependency property, it need to be set from the GUI thread.

Note: To build your own FFmpeg binaries, I recommend the [Media Autobuild Suite](https://github.com/jb-alvarado/media-autobuild_suite) but please don't ask for help on it here.

### Additional Usage Notes
- Remember: The `Unosquare.FFME.Windows.Sample` provides plenty of usage examples
- Remember: The `Unosquare.FFME.Windows.Sample` provides usage examples for plenty of features. Use it as your main reference.
- The generated API documentation is available [here](http://unosquare.github.io/ffmediaelement/api/Unosquare.FFME.html)

## Features Overview
FFME is a close (and I'd like to think better) drop-in replacement for <a href="https://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement(v=vs.110).aspx">Microsoft's WPF MediaElement Control</a>. While the standard MediaElement uses DirectX (DirectShow) for media playback, FFME uses <a href="http://ffmpeg.org/">FFmpeg</a> to read and decode audio and video. This means that for those of you who want to support stuff like HLS playback, or just don't want to go through the hassle of installing codecs on client machines, using FFME *might* just be the answer.
FFME is an advanced and close drop-in replacement for <a href="https://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement(v=vs.110).aspx">Microsoft's WPF MediaElement Control</a>. While the standard MediaElement uses DirectX (DirectShow) for media playback, FFME uses <a href="http://ffmpeg.org/">FFmpeg</a> to read and decode audio and video. This means that for those of you who want to support stuff like HLS playback, or just don't want to go through the hassle of installing codecs on client machines, using FFME *might* just be the answer.

FFME provides multiple improvements over the standard MediaElement such as:
- Fast media seeking and frame-by-frame seeking
- Properties such as Position, Balance, SpeedRatio, IsMuted, and Volume are all Dependency Properties!
- Properties such as Position, Balance, SpeedRatio, IsMuted, and Volume are all Dependency Properties.
- Additional and extended media events. Extracting (and modifying) video, audio and subtitle frames is very easy.
- Ability to easily apply FFmpeg video and audio filtergraphs.
- Ability to extract media metadata and tech specs of a media stream (title, album, bit rate, codecs, FPS, etc).
- Ability to apply volume, balance and speed ratio to media playback.
- Easily apply FFmpeg video and audio filtergraphs.
- Extract media metadata and tech specs of a media stream (title, album, bit rate, codecs, FPS, etc).
- Apply volume, balance and speed ratio to media playback.
- MediaState actually works on this control. The standard WPF MediaElement severely lacks in this area.
- Ability to pick media streams contained in a file or a URL.
- Ability to pass input and codec parameters.
- Ability to introduce hardware decoding acceleration via devices or via codecs.
- Ability to capture stream packets, audio, video and subtitle frames
- Ability to record streams
- Specify input and codec parameters.
- Opt-in hardware decoding acceleration via devices or via codecs.
- Capture stream packets, audio, video and subtitle frames
- Perform custom stream reading and stream recording

*... all in a single MediaElement control*

FFME also supports opening capture devices. See example Source URLs below and [issue #48](https://github.com/unosquare/ffmediaelement/issues/48)
```
device://dshow/?audio=Microphone (Vengeance 2100)
device://dshow/?audio=Microphone (Vengeance 2100):video=MS Webcam 4000
device://gdigrab?title=Command Prompt
device://gdigrab?desktop
```

If you'd like audio to not change pitch while changing the SpeedRatio property, you'll need the `SoundTouch.dll` library available on the same directory as your application. You can get the [SoundTouch library here](https://www.surina.net/soundtouch/).
If you'd like audio to not change pitch while changing the SpeedRatio property, you'll need the `SoundTouch.dll` library v2.1.1 available on the same directory as the FFmpeg binaries. You can get the [SoundTouch library here](https://www.surina.net/soundtouch/).

### About how it works

Expand Down Expand Up @@ -94,47 +94,15 @@ A high-level diagram is provided as additional reference below.
*Please note that I am unable to distribute FFmpeg's binaries because I don't know if I am allowed to do so. Follow the instructions below to compile, run and test FFME.*

1. Clone this repository.
2. Download the FFmpeg win32-shared binaries from <a href="https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.1-win32-shared.zip">Zeranoe FFmpeg Builds</a>.
2. Download the FFmpeg **shared** binaries for your target architecture: <a href="https://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-4.1.1-win32-shared.zip">32-bit</a> or <a href="https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-4.1.1-win64-shared.zip">64-bit</a>.
3. Extract the contents of the <code>zip</code> file you just downloaded and go to the <code>bin</code> folder that got extracted. You should see 3 <code>exe</code> files and multiple <code>dll</code> files. Select and copy all of them.
4. Now paste all 11 files from the prior step onto a well-known folder. Take note of the full path. (I used `c:\ffmpeg\`)
5. Open the solution and set the <code>Unosquare.FFME.Windows.Sample</code> project as the startup project. You can do this by right clicking on the project and selecting <code>Set as startup project</code>
6. Under the <code>Unosquare.FFME.Windows.Sample</code> project, find the file `App.xaml.cs` and under the constructor, locate the line <code>MediaElement.FFmpegDirectory = @"c:\ffmpeg";</code> and replace the path so that it points to the folder where you extracted your FFmpeg binaries (dll files).
4. Now paste all files from the prior step onto a well-known folder. Take note of the full path. (I used `c:\ffmpeg\`)
5. Open the solution and set the <code>Unosquare.FFME.Windows.Sample</code> project as the startup project. You can do this by right clicking on the project and selecting <code>Set as startup project</code>. Please note that you will need Visual Studio 2019 with dotnet Core 3.0 SDK for your target architecture installed.
6. Under the <code>Unosquare.FFME.Windows.Sample</code> project, find the file `App.xaml.cs` and under the constructor, locate the line <code>Library.FFmpegDirectory = @"c:\ffmpeg";</code> and replace the path so that it points to the folder where you extracted your FFmpeg binaries (dll files).
7. Click on <code>Start</code> to run the project.
8. You should see a sample media player. Click on the <code>Open</code> icon located at the bottom right and enter a URL or path to a media file.
9. The file or URL should play immediately, and all the properties should display to the right of the media display by clicking on the <code>Info</code> icon.
10. You can use the resulting compiled assemblies in your project without further dependencies. Look for both ```ffme.common.dll``` and ```ffme.win.dll```.

### Windows: Troubleshooting

If you get the following error when compiling:
*The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0.*

Simply download and install [.NET Core SDK v2](https://www.microsoft.com/net/download/windows) or later.

## MacOS: Sample Player (in preview, WIP)
Compile FFmpeg for Mac (instructions can be found on [FFmpeg.AutoGen](https://github.com/Ruslan-B/FFmpeg.AutoGen)) and copy the following libraries from `/opt/local/lib` 's to `/Users/{USER}/ffmpeg` (equivalent to `~/ffmpeg`):
- `libavcodec.57.dylib`
- `libavdevice.57.dylib`
- `libavfilter.6.dylib`
- `libavformat.57.dylib`
- `libavutil.55.dylib`
- `libswresample.2.dylib`
- `libswscale.4.dylib`

*Note: when building FFmpeg locally, compiled libraries are named differently than in the list above. E.g. `libavcodec.57.dylib` is actually named `libavcodec.57.89.100.dylib`. To properly load libraries, copy and rename each library to match the format in the list above.*

In the sample MacOS player, the FFmpeg folder is configured to point to `~/ffmpeg` in the following line of code:

```csharp
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "ffmpeg");
```

Note that this can be customized to point to any other folder.

When distributing the player and the associated libraries with your application, dll files should be added to the project as `BundleResource` items. Also, each library should be copied to the output directory on build. Afterwards, change the above configuration to use `Environment.CurrentDirectory` to search for FFmpeg libraries.

### MacOS: Troubleshooting
Make sure you have Xamarin for Visual Studio 2017 installed if you want to open the MacOS projects.
10. You can use the resulting compiled assemblies in your project without further dependencies. Look for ```ffme.win.dll```.

## Thanks
*In no particular order*
Expand Down
Loading

0 comments on commit c17fca9

Please sign in to comment.