Encoding Audio (to AAC) in Silverlight 4 (on the client)? - silverlight

OK so Silverlight 4 is adding support for capturing from microphones (and webcams), however for this facility to be useful (in my case at least) I'd need to upload this captured data to a server to save.
The AudioCaptureDevice will record PCM audio on the client, and as we all know PCM is not the most efficient encoding... the data would be too large to upload uncompressed.
Ideally, I could encode this PCM stream to AAC right on the client, then upload that compressed stream to the server.
Something like this library, may be useful. However it doesn't support AAC.
(I'm choosing AAC because (unlike MP3) it is royalty-free to encode, and is supported by popular PMP devices.)
Any thoughts out there on the best way to accomplish this? All options are on the table: full-trust, Google Gears, etc...
Thanks for any help!

There's an audio codec out there called Speex AND Alden Torres ported the SPEEX algorithm to C#. So you have a full managed audio encoder. Here's the relevant blog post where he shows how to encode the audio from the mic with SPEEX. Read also the comments.

As the answer mentioned above Speex is a voice codec which is not really appropriate if you want to use it for music.
However, if you are still interested in Speex on Silverlight than you should take a look at NSpeex which is a port of an earlier version of Speex to C# and it also offers a Silverlight library.

I need to record a music in Silverlight (e.g. from the line-in) and save it on the server. It must be in a good quality (not like SPEEX). I will try to use a lame encoder on the client. It needs the lame_enc.dll that can be accessed by p-invoke. I will test if it is possible from the silverlight.
Do you know some alternatives? Maybe a good stream server (is it possible with wowza)?

You should know that AAC encoding is patent restricted as well. Check out the Wikipeadia article on it. If you want a free format, you should look into Vorbis or FLAC (or Speex).
If you're on a Windows 7 or Server 2008 R2 box, you might be able to use the SDK to encode AAC (http://msdn.microsoft.com/en-us/library/dd742785(v=VS.85).aspx).
Also, since you're forcing the client to do a bunch of work anyway, why not just zip it before you upload it -- I'm not a Silverlight person, so maybe that's not possible?

Related

Decoding audio from non-file source with Microsoft Media Foundation

My question is basically that I am new to this framework and I am looking at pointers to how to work with non-file sources in media foundation since the documentation in this front seems lacking in my mind. Below is some info on what I am doing and what approach I am working with right now but I have no idea if it is the correct way to use the framework.
I am currently trying to use Microsoft Media Foundation to decode audio that I'm getting over Bluetooth and then send it along as PCM audio. When looking at the documentation for ms media foundation it seems that almost all examples assume the source is a file.
Looking at the tutorial for decoding audio for example they use MFCreateSourceReaderFromURL, which I cannot use since my source is not a file.
As I wanted to follow the tutorial and change as little as possible Im thinking that I need only change how I create the source reader and the rest of the process would be the same. I looked at the other SourceReaders available and MFCreateSourceReaderFromByteStream sounds about right for my purposes.
Is there a chance that I only need to create a bytestream and continuously fill it with data that I get over the air as we go and the media source created by MFCreateSourceReaderFromByteStream handle this well? Or do I need to create a custom media source and do more manual work at the lower parts of the API to get something like this to work?
Or maybe a source reader is the wrong approach altogether when the source is not a file? In the main page about Source Reader here they have the following picture:
And this picture shows the media source within the source reader pointing to a source file only, is this a real limitation or simply and example?
Im writing this in plain c, but pointing to c++ documentation or examples is fine as its usually pretty straightforward to translate c++ to c and there seems to be no documentation for c anyways.
Edit:
Im adding a image on what kind of data Im getting, the red area being the chunks of data I refer to in comments below Source.
Non-file source is not a accurate description. Does it have a file structure, just not a file? Structured differently? Raw stream?
If you look at samples with source reader, they assume presence and usage of stream handler capable to parse incoming stream into elementary streams with known type and properties. Then you or Media Foundation could apply decoder or otherwise transform the data.
As you specified that the data come "in chunks", most likely that you are interested in an alternate option to use AAC Decoder explicitly. You can create an instance of it, initialize input and output types, then feed it with compressed audio and pull decoded PCM on the output. The decoder has MFT interface.

How to receive H264 stream via RTP and store to file?

I'm trying to make a server that receives RTP/H264 video streams from android clients and stores these to file.
Currently I'm using VLC in the server, which works well. However, I am worried that VLC is a heavyweight solution that may not scale well. As I'm not actually playing the video, only saving it to file, I thought there must a be a more efficient solution.
Currently I'm planning on using an Amazon ec2 instances, so the goal is to serve as many clients as possible per instance.
I'm flexible (willing to learn) on the language side, I'd like to choose the right language for the job.
So, does anyone know of a good, scalable way to store these streams to files?
Thanks in advance!
EDIT
FFmpeg or libav look promising. Looking into them now.
Basically you need an library that supports rtp stack server side, so you can extract the payload and just append to a file as it comes. ffmpeg is a great choice, and it does have rtp stack and it also it can generate containers(MP4,...) for you as well; if needed. Actually VLC uses ffmpeg's libav library under the hood.

Editing/Decoding AVI files using system-installed proprietary codecs

I've been searching for this for a few days now, but nothing seems to quite answer or work for me, so please forgive me if I'm asking a stupid question or one that seems to have been answered elsewhere.
I have an AVI file encoded using the GMP4 video codec, currently installed on my computer so I can PLAY the file in Windows Media Player for instance. What I'm trying to do is open/decode the file for editing purposes, in order to be able to stitch two video files together. I do not require it to be output in the same format, but rather only opened for editing, get the frames and then I can output to a more standard format.
The problem I'm getting is that there is no DirectShow filter created for this format, so it won't open using that for me (haven't worked too deeply into it, but all samples fail to load the video file). FFMPEG tries to read the file, states that the header is incorrect but it'll attempt to read it anyway, then dies stating that I need the GMP4 codec. As I'd stated earlier, I have the particular codec installed but FFMPEG doesn't seem to notice or have access to it.
Is there anything that will allow me to use the system-installed codecs to decode the video frames? It seems strange to me that Windows Media Player can do something, but I can't programatically repeat it. I'm not restricted to C++ or C#, though C# would definitely be a preferred language.
Thanks All,
Alex
I spent all day with the same problem. Solution is to install AVISynth, and then you can load with ffmpeg any AVI file for whom the system has a VfW codec. Instead of passing ffmpeg your AVI input file, create an .avs file with a single line containing AviSource("your-avi-filename") and passing ffmpeg the .avs filename.
Suppose you want to convert your input.avi in a proprietary video CODEC into an h263 format (supposing your input.avi has a supported h263 frame size):
echo AviSource("input.avi") > input.avs
ffmpeg -i inputs.avs -vcodec h263 output.avi
Nuno has a great answer, but you want to avoid command line converts, you can use the AForge.Net c# library to access AfW codecs, FFMpeg codecs or even DShow codecs (some CCTV DVRs do encode in DShow).
There is also a way to open Windows Media Player as a c# object and grab frames from it. Email me if you want more information - it sounds like we're working on similar projects.

Which is the best way to encode batch videos on server side?

I am making a general question since I am a developer and I have no advance experience on video elaboration. I have to preparare a web application with the purpose to allow video files upload on our company server and then video elaboration by server, on user command. The purpose of the web application is to allow to the user to make some elaboration on video depending on user action launch from the web app:
(server has to ) convert video in different format(mp4, flv...)
extact keyframes from video and saves them in jpeg format
possibility to extract audio from video
automatic control of quality audio & video (black frames,silences detection)
change scene detection and keyframe extraction
.....
This what's my bosses wanted from the web based application (with the server support obviously), and I understand only the first 3 points of this list, the rest for me was arabic....
My question is: Which is the best and fastest server side application for this works, that can support multiple batch video conversions, from command line (comand line for php-soap-socket interaction or something else..)?
Is suitable Adobe Media Server for batch video conversion?
Which are adobe products that can be used for this purpose?
Note: I have experience with Indesign Server scripting programing (sending xml with php and soap call...), and I am looking to something similiar for video elaboration.
I will appreciate any answers.
THANKS ALL
I suggest you start with the open source project FFmpeg. You can call the program from the command line and via a series of arguments specify the desired output types, thumbnails, etc.
As an aside, when you start looking around at Video related projects (MediaShare for example) you will find they are all using FFmpeg for their video processing.
as Nathan suggested, FFMPEG is the first choice. Also you can check MEncoder
Just to elaborate:
1) (server has to ) convert video in different format(mp4, flv...)
both FFMPEG and mencoder do this well
2) extact keyframes from video and saves them in jpeg format
as I know it's impossible using command-line interface of FFMPEG, not sure about mencoder. However they can save all frames as separate images
3) possibility to extract audio from video
both FFMPEG and mencoder do this well
4) automatic control of quality audio & video (black frames,silences detection)
you need to code this, using FFMPEG libraries or mencoder
5) change scene detection and keyframe extraction
it's not clear what your boss imposes here
I tried lot of videos converting in server side using advance Xuggler API libraries.
Xuggler is a free open-source library for Java developers which can be used to uncompress,
manipulate, and compress recorded or live video in real time. Xuggler uses the very
powerful FFmpeg media handling libraries under the hood, essentially playing the role of a
java wrapper around them. It is the easy way to uncompress, modify, and re-compress any
media file (or stream) from Java.
WebLinks : 1) http://www.xuggle.com/ -official website
2) http://www.javacodegeeks.com/2011/02/introduction-xuggler-video-
manipulation.html - example

Silverlight Live Audio Streaming

How do I stream live audio from the location to over the internet using Silverlight 2.0? What equipment, software etc do I need?
I've written/ported a MP3 decoder to Silverlight 3.
To get around the issue of a seekable stream and MediaStreamSource, I wrote a custom stream, SeekableStream, that wraps around any other Stream and makes it appear seekable by using an internal memory stream.
You can see it in action here where it can play a MP3 files located locally on your machine or on the web.
Source for the library and demo is now up on CodePlex
It depends what you want to stream. If you just want to stream Mp3s over the web the Silverlight 2 MediaElement will do it for you. Just point the Source property to the Uri of the mp3 and you're done. That same technique works for video, too. If you want to stream live content (i.e. a webcam) then you should use the stream services that were linked to by the other commenter.

Resources