Dumping h264 stream into a mp4 container - ffmpeg

I would like to know how can I dump the h264 raw stream from a network camera into a mp4 container file. I need to do it with C++, any library? can I do it by myself?
Thanks in advance,

Windows 7 and later has API that can write video containers. Search MSDN for Sink Writer and Microsoft Media Foundation. It is the successor to DirectShow. There is specific mention for support of MP4 file sink and H.264 video encoding/decoding. This is one option.

Check out libmp4v2 # https://code.google.com/p/mp4v2/
It is pretty straight forward to use.
HandBrake uses it. You can download source from # https://handbrake.fr/downloads.php for reference

Related

How can I stream camera using ffmpeg and send over network using live555

I am making a application for streaming webcam. I would like to use ffmpeg to capture camera, ffmpeg as encoder and live555 as server. I know I must implement DeviceSource.cpp in live555 to encapsulate the encoder to receive frame from ffmpeg.So can anyone provide me some tutorial or example about implementing.Thanks in advanced.
Here is a good example of what you are after here:
https://www.imc-store.com.au/Articles.asp?ID=278
It is a c++ VS2010 project showing how to encode a raw RGB frame using FFMPEG, and then sending that discrete frame onto Live555 to be streamed.
The VS2010 project includes all the library and include files so it should simply be a case of unzipping, running the .sln file in VS2010, compile and run!
Also the VLC source code implements both FFMPEG and Live555, you could take a look at their code for some extra pointers!
Good luck!

Media Foundation Encoder MF_E_TRANSCODE_NO_MATCHING_ENCODER

I am trying to convert from wmv to mp4.
First of do I need to implement my IMFTransform to do this ?
Do i need to convert the video to MFVideoFormat_I420 ?
As far as I know if you create the topology correctly this should be handled automatically.
So I created my profile showed in the
http://msdn.microsoft.com/en-us/library/windows/desktop/ff819476%28v=vs.85%29.aspx
but i get a MF_E_TRANSCODE_NO_MATCHING_ENCODER.
I have windows 7 so, i should have the encoder.
Also Does anyone know where the source code for that tutorial is. It is not under SDK samples.
Thanks.
You don't show code - noone knows what is wrong.
Take a look at this transcoding sample, which comes with source code and does exactly what you are trying to do: transcoding from ASF into MP4.
http://blogs.msdn.com/b/mf/archive/2009/12/02/mfsimpleencode.aspx
MFSimpleEncode.exe - This is a command line tool that transcodes files
from one media format to another. The source code is provided to use
as a reference if you write your own transcode application. This tool
uses the Media Foundation transcode API, which was introduced in
Windows 7.
Examples:
Transcode ASF to MPEG-4:
MFSimpleencode.exe –i Input.wmv –o output.mp4 –p TranscodeProfileMPEG4.xml

Is it possible to use the h264 and aac encoders that ship with windows 7 from directshow?

I see that windows 7 ships with an aac encoder and an h264 encoder. I'm writing a directshow application that needs to do video encoding. I think: "Great! Now I don't have to license a video encoder!", but then I read on to discover that these encoders use the new MFT api which seems to be incompatible with directshow, and there doesn't seem to be a wrapper filter like there is with DMO. Is there a way for me to use these filters in directshow? Maybe there's a wrapper I didn't find? Maybe I can access these filters as DMO's?
As far as I know the H264 and AAC encoders are only available using the Media Foundation APIs. See the Supported Media Formats in Media Foundation on MSDN. So if you want to make use of these you'll need to use WMF instead of or in addition to DirectShow. As far as I know there is now wrapper or adapter to get a MF graph into DirectShow.
The good news is that MF is much improved compared to DirectShow and offers very nice higher level APIs for video like the SinkWriter which make it much easier to write video to a file.

Using Microsoft DTV-DVD Video Decoder to play H264 video

I am trying to play an H264 video with graphedit on Windows 7 32bit.
Graphedit is unable to render the file.
I tried to mount the graph manually using the Microsoft DTV-DVD Video Decoder (also know as Microsoft MPEG-2 Video Encoder) but I could not connected the filters.
Here is the pipeline I tried :
File Source >> Microsoft DTV-DVD Video Decoder >> Video Renderer (or VMR9)
I also tried this :
File Source >> MPEG-2 Demultiplexer >> Microsoft DTV-DVD Video Decoder >> Video Renderer (or VMR9)
In either case, I could not connect anything to the file source filter.
The H264 video I am trying to play is the Serenity trailer I downloaded from here : http://www.h264info.com/clips.html
Do you have any idea how I could play the h264 video file with graph edit?
Thank you
For starters. That file is an mp4, so you need an mpeg4 demuxer filter, which Microsoft does not provide for DirectShow. MediaFoundation supports it natively, but that functionality is not exposed to DirectShow. There are commercial DirectShow filters available or the open-source "ffdshow" plus "Haali Media Splitter" will do it. If your project can use the open source products, that will also provide a decoder with wide-ranging compatibility.
Assuming you don't want to use ffdshow and instead get a demuxer from elsewhere, it may or may not work with the Microsoft DTV-DVD Video Decoder. I've seen erratic results with it. A lot of content it just doesn't want to play.
One other thing is that you will likely want to use the Enhanced Video Renderer in Win7 instead of VMR9. VMR9 is neutered in Win7 (compared to XP). It's no longer compatible with dxva hardware acceleration, and the scaling is limited to the ugliest mode.
Use the File source but connect it to Geraint Davies' free mpeg4 demux available at http://www.gdcl.co.uk/mpeg4/
If you then render the output pins of the demux, the video decoder will automatically be inserted. I just tried it with the video you mentioned and it works fine.

How can I playback an audio stream from a Icecast on WP7

How can I playback an audio stream from a Icecast on WP7
I have tried SMF, SmoothStreaming Client and the MediaElement.
None of these have worked. The formats are either asx or and wma.
Edit:
Recently I found a new stream. this stream works when I'm in the designer. But it does not work on the device. On the device the stream is opened and closed immediately.
this stream is from an IceCast server in MP3 format. with a ?.mp3 extention. or without.
When you are streaming live radio, the stream may be encoded by an IceCast server or ShoutCast server. To read these streams, you will need to decode the stream in memomry and pass it to the MediaElement once it has been decoded.
have a look at Mp3MediaStreamSource
and Audio output from Silverlight
I lost tons of time on this, and this is the best solution I found so far.
Having had a quick look at the Icecast web site (I'm not familiar with their service) it seems that most of what they offer for streamed audio is offered in MP3 format, but that they provide this as playlists in either M3U or XSPF format. You can't provide this to any of the built-in controls or classes in the WP7 framework, but you can parse the contents of the file and pass that to a MediaElement to play individual files.
The M3U file is a simple list of the consituent URLs, so is the simplest to deal with, but the XSPF format (which is an XML format) provides more information, such as the title. You can easily use the XDocument class to parse the XSPF file and then use LINQ to query the contents.
You're not adding the ?.mp3 to the pls file right, to the embedded URL? IF you are using the URL you get from the PLS/M3U file, you might need to append a file extension to it. You can often do this by adding ?ext=.mp3 or ?file.mp3 to the URL and it should play with MediaElement, as I read on the MS dev boards that people had been getting that to work with Shoutcast streams.
Does your stream work on the device when you unplug it from the computer? Media playing doesn't work while you're plugged into the Zune sync center.
Chris

Resources