How to receive H264 stream via RTP and store to file? - 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.

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.

Simple file transfer

I want to create an application in C that allows two users to share a file. I'll call the person sending the file the server and the receiver the client. There are a few requirements:
The users need no identification, no "login". You could say they are unknown for my application.
The server selects a file for transfer and gets returned a simple ~10 character ID string/hash that the client can use to retrieve the file.
The same application is used for both serving and receiving.
My application must not need dedicated software running on a remote server, unless it's freely available (e.g. bittorrent trackers).
Now this sounds a lot like bittorrent and I am seriously thinking of doing this through bittorrent. I'm not sure how I would do this. Are there any good libraries for torrent creation / seeding / downloading?
Please answer this question by either:
Posing a viable alternative for bittorrent / other ideas.
Posting good libraries / snippets / implementations of the bittorrent protocol in C.
This does indeed sound like something best done with BitTorrent. Have you had a look at libbt? It's not very well documented but does include a sample client, which is btget.c in /src/.
I have now found this library: rasterbar libtorrent. It's in C++ but I don't mind (I don't know either that well anyway).
Sharing here for future reference if other people are looking for the same thing as me.
And an other solution, send the file through an IRC server (like Freenode). I came up with this solution after I had trouble with opening ports with bittorrent.

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

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

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?

redirect file to an url for streaming

I am setting up my hi-fi to stream music from my PC. The hi-fi can see all of the files in my music folder, but I want to be able to stream across the audio I am currently playing. The hi-fi however does not have support for this.
So I've found a .dll that wraps directsound and offers it streaming as a continuous mp3 file on my PC from localhost:8124
I want to make a file in my music folder that will point to this (i.e. audio.mp3). So when my hi-fi streams audio.mp3 and plays it, it will actually receive the contents from localhost:8124.
I've tried using symbolic links, but they don't seem to allow me to do this.
Finally I am running Windows 7.
Can I do this? and if so how?
You can't do that. You can't create something that looks like a file, but actually streams the content from some other location.
If your hi-fi doesn't support streaming, there's no solution. If it does support streaming, you'll need to find a way to support the streaming protocol it does handle.

Resources