FFmpeg autogen in combination with openh264 - c#

I'm using FFmpeg autogen to stream images captured from the PC in realtime (60 or 30 fps) to an Android application. Everything is working perfectly as I used the h.264 encoding example provided by FFmpeg autogen.
As far as I have understood FFmpeg autogen is under the LGPL licence and if you are using custom FFmpeg libs compiled under LGPL licence like for example ffmpeg-win32 you can dynamically link to the FFmpeg autogen library without violating the LGPL licence if your project is for example closed source.
So I thought everything would be okay but then I figured out the the h.264 coded is patented in the US and MPEG LA represents the patent holders of AVC/H.264 technologies. If you are using it for free videos you can use h.264 codecs without paying royalties. Nevertheless, my Windows program which is using the encoder is free but my Android application is not free so I guess I have to pay royalties.
I have a few questions regarding this issue:
Which encoder does the FFmpeg autogen use, because as far as I know x264 is under GPL licence. I assume that it will use some internal FFmpeg software encoder?
You can't use any built in standard encoder from FFmpeg (x264 etc.) in projects which don't offer their encoded video stream for free without the need of paying royalties, right?
After some researches I found openh264. This library is built by cisco and they will pay all the royalties but you are not allowed to bundle it with your application, it must be downloaded during the installation process. It also works with FFmpeg but how to I get it to work with FFmpeg autogen? Do I need a custom FFmpeg build which are using the openh264 lib from cisco?
I know this is not a lawyer forum but maybe someone has already dealt with all this issues or could at least answer the questions about FFmpeg autogen. I've searched a while now on the internet but unfortunately it seems that the licencing mechanism with h.264 is not so easy to understand.

I almost forgot about this question but I think I've understood everything now so I will answer it by myself. Maybe it is helpful for someone. In case something is not correct please feel free to correct me.
As far as I have understood FFmpeg autogen is under the LGPL licence
and if you are using custom FFmpeg libs compiled under LGPL licence
like for example ffmpeg-win32 you can dynamically link to the FFmpeg
autogen library without violating the LGPL licence if your project is
for example closed source.
This is indeed correct. FFmpeg autogen is under LGPL licence but if you are just using the provided FFmpeg libraries from zeranoe you are out of luck because all this builds are under GPL licence. This means even if FFmpeg autogen is under LGPL your project still has to be published under GPL as well because of the FFmpeg GPL libraries.
Luckily you can just compile your own custom version of FFmpeg under LGPL but you will miss some features like x264 (basically all features which are not appropriate for LGPL). Compiling a custom version of FFmpeg could be pretty complex, however I found a nice project on github which is called media-autobuild_suite. These scripts basically compile FFmpeg for you and offer many customization features for all kind of FFmpeg features like openh264 and many more. I posted some more details here.
So I thought everything would be okay but then I figured out the the
h.264 coded is patented in the US and MPEG LA represents the patent
holders of AVC/H.264 technologies. If you are using it for free videos
you can use h.264 codecs without paying royalties. Nevertheless, my
Windows program which is using the encoder is free but my Android
application is not free so I guess I have to pay royalties.
I contacted MPEG LA and it doesn't matter if your program is free if you want to be covered by the licence you have to contact MPEG LA and request a licence for your product. You don't have to pay anything though as long as your program will not be downloaded more than 100 000 times per year. You have to provide some reports once a year to MPEG LA which should contain all the information about the downloads. In case you have some questions just contact MPEG LA they are usually very responsive and will reply very fast.
Which encoder does the FFmpeg autogen use, because as far as I know x264 is under GPL licence. I assume that it will use some internal
FFmpeg software encoder?
FFmpeg autogen will use the x264 encoder if you are just using the zeranoe FFmpeg builds. But in general it depends how you have compiled FFmpeg. I compiled FFmpeg with openh264 in order to use openh264 encoder with FFmpeg autogen just load the encoder like this
ffmpeg.avcodec_find_encoder_by_name("libopenh264");
You can't use any built in standard encoder from FFmpeg (x264 etc.) in projects which don't offer their encoded video stream for free
without the need of paying royalties, right?
I don't know if this is correct for any other built in encoder in FFmpeg but you can't use x264 without requesting a licence from MPEG LA. Except openh264 because cisco will pay the royalties for you. Keep in mind that you can't bundle openh264 with your application because otherwise you are responsible to pay the royalties to MPEG LA and not cisco. You have to download openh264 during the installation process of your program or you can provide some download possibilities during the runtime of your program.
After some researches I found openh264. This library is built by cisco and they will pay all the royalties but you are not allowed to
bundle it with your application, it must be downloaded during the
installation process. It also works with FFmpeg but how to I get it to
work with FFmpeg autogen? Do I need a custom FFmpeg build which are
using the openh264 lib from cisco?
Yes, you have to download it during the installation process or during the runtime of your program and yes, you need a custom FFmpeg LGPL build with openh264. You can easily compile your own version of FFmpeg with media-autobuild_suite.
Just one more thing, if you are using FFmpeg under LGPL keep in mind that there are some conditions that you have to consider, you can find them here. That's all for now. I hope these are some useful information.

Related

Windows Phone 8 Video to MP3 converter

I did some research on converting video's to audio (MP3) on Windows Phone, but I can't find any converter or even basic functionality on the Windows Phone core to do this. Is this even possible?
You have a NuGet package named: MediaToolkit which is available with the NuGet package manager and also here: https://www.nuget.org/packages/MediaToolkit/
The library exposes features which convert video files into various other video formats. Grab images from videos. Perform a range of other audio / video transcoding tasks, even cutting / splitting videos.
To find the source code / code examples, visit GitHub: https://github.com/AydinAdn/MediaToolkit
To download it straight in to your project, use the Project Manager Console for NuGet: PM> Install-Package MediaToolkit.
There are no classes inside the Windows Phone 8 framework, the best thing to do is to go with an external library (like the one #Gaurav Deochakke) posted.
I've looked at the supported Win32 and COM APIs inside the WP8 framework, there are lots of API's that can help you (dis)playing media files, but none of them will help you either capture the desired audio or convert the video file to an audio file.
Although you might want to look at IAudioCaptureClient and IAudioClient (less documented), they might be able to help you with capturing the output of a file that has audio (a video for example). The only downside of this will be that you will have to loop through the video per second.
As stated above I'd go with a simple library to complete your task, but if you have time and you are interested in creating the solution yourself, I'd go with the links I posted.

Playing media from byte stream in .net

I am developing application that receives media content(.mp3/.mp4/.avi) in form of bytes.
However, as WPF doesn't support playing media from stream, So I started with WMP.dll.
I am creating class library that receives media in form of bytes and media format and play media accordingly.
Referring Creating the WMP Programmatically, however, I didn't find method to pass bytes stream.
So My question is how do I play media from bytes using wmp.dll?
Edit: I am using WMP.dll using COM located at C:\WINDOWS\system32\wmp.dll
I've been through this process a long time ago ...
Basically I would advise you NOT to go down the WMP route at all. It's heavy, cumbersome and not very nice to work with. I encountered lots of issues along the way basically. Least of all it being feature rich (which it isn't).
The best solution I found and the one I'm still using now is a library called BASS from Un4SeenDevelopments.
This library is tiny < 100k and basically it's awesome. Never had a problem with it and it has it's own .NET wrapper that is a free download from the site.
The support is amazing and the compatibility via a massive selection of plugins and additional libraries is staggering.
Highly recommended for what you want to do.
"BASS is an audio library for use in software on several platforms. Its purpose is to provide developers with powerful and efficient sample, stream (MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via OS codecs and add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions. All in a compact DLL that won't bloat your distribution."

.NET: How can I convert an mp3 or a wav file to .flac

I need to write a utility in c# that uses Google Speech Api to convert speech from an audio file into text. As far as I know, Google only accepts .flac format for this api. Unfortunately, I have .wav and .mp3 audio files. So I am trying to find out if there is a way for me to convert mp3 to flac in .NET. I looked at NAudio, but it doesn't seem to be working with flac files.
I ended up using Gregory S. Chudov's C# implementation of FLAKE encoder. You can find more information at
http://www.hydrogenaudio.org/forums/index.php?showtopic=74242
There is another project on BitBucket that uses CUETools FLAKE in its Google Speech Api wrapper. It is a good starting point for implementing speech to text using Google speech api. You can find it at
https://bitbucket.org/josephcooney/cloudspeech
I was able to convert wav to flac without much difficulty using the FLAKE encoder. Hope this helps you.
Take a look at http://naudio.codeplex.com/
NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET. It has been in development since 2002 and has grown to include a wide variety of features. While some parts of the library are relatively new and incomplete, the more mature features have undergone extensive testing and can be quickly used to add audio capabilities to an existing .NET application. NAudio can be quickly added to your .NET application using NuGet.
Edit
Sadly FLAC is not supported there, as i see in the overview. Try it yourself.

Create video from still images

I am developing an application that I can get series of Images from IP camera.
Now I want make video from those image. Can anyone help me in creating a video of any format from still images using C#?
You could just use ffmpeg behind the scenes to do so.
Use ffmpeg, http://ffmpeg.org/
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video.
Also...
FFmpeg is free software licensed under the LGPL or GPL depending on your choice of configuration options. If you use FFmpeg or its constituent libraries, you must adhere to the terms of the license in question. You can find basic compliance information and get licensing help on our license and legal considerations page.
From the documentation:
For creating a video from many images:
ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi

Using the Windows MP3 decoder with Un4Seen Bass.NET

I'm writing a media player that uses the Bass.Net wrapper for Un4Seen's Bass native audio API.
The library is all free for non-commercial use and I have the free license, but in the documentation it says that unless you tell Bass to use the MP3 decoder built into Windows, it requires that you to also get a separate license from the MP3 licensing organization.
However, I cannot find anywhere how to get Bass.Net to tell it to use the Windows decoder instead of the one built into Bass (that requires the license).
This is going to be an open source application and I don't want to have to get a license for something that's free.
Any ideas how to do this?
According to some forums:
With version 2.3.0.1 there are now two versions of the bass.dll available:
a) the standard on in the main directory based on the BASS internal MP3 decoder
b) the on the 'mp3-free' directory which is using the Windows based MP3 decoder
Source
So, you should be able to simply replace the bass.dll with the version in the mp3-free directory, and it will use the windows mp3 decoder automatically.
The information below the line is outdated. Apparently, they got rid of the BASS_CONFIG_MP3_CODEC config in an earlier version of Bass.NET
If you have the .NET API help chm (/help), you can look at the BASS_SetConfig method in the Bass class for more information on setting up configurations.
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_MP3_CODEC, 1);
Interestingly enough, the BASS_CONFIG_MP3_CODEC value (supposedly of the BASSConfig enumeration), is listed in the Get/SetConfig methods, but not in the actual documentation of the enum.

Categories