Playing mp4v file in Silverlight5 - silverlight-5.0

I have a Silverlight5 based application which works in both In Browser as well as OOB mode.
I need to play video files which are of mp4 extension and encoding as shown by VLC media player:
Stream 0
Type: Video
Codec: MPEG-4 Video (mp4v)
Resolution: 320*240
Frame Rate: 10
Decoded Format: Planar 4:2:0 YUV.
I have tried using the Media Element provided by Silverlight framework and also tried using the Azure media services to display the video, but did not have any success. It says that the file format is not supported.
Will really appreciate your inputs.
Alpee

Windows does support MPEG4 video decoder. See below links
http://msdn.microsoft.com/en-us/library/windows/desktop/ff819502(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ff819503(v=vs.85).aspx
You can use MediaInfo a free tool to check the codec info in each stream inside a media container.
Without examining files it is hard to tell what's wrong.

Related

Can I use a video file as video source for WebRTC native code?

I have downloaded latest webrtc native code and tested the peerconnection example. In this example video can only come from devices configured on the system (it looks for devices in /dev/videoX).
I am wondering if it is possible to get the video from a video file at my local machine and pass its frames to VideoFrame in WebRTC so peerA, who is the peerconnection_client of the example. Then this video would be passed to peerB, who is a web client on browser.
Basically: My video source should be a video file.
If you accept to get away from Google's reference implementation, the streamer example of libdatachannel shows how to stream a video file to a browser.

ffmpeg questions

I have a problem with ffmpeg and I don't know how to continue. I have 2 computers:
Client :
Run Ubuntu 14.04
FFmpeg installed
Use c++ language
Features: use ffmpeg to encode h264 video data from webcam of client laptop, then real time streaming to server
Server:
Running Windows 7
FFmpeg installed
Use c++ language (MFC)
Features: Get real time data from client and show it on screen.
I've just connected client to server and they can chat text data together, and I don't have any idea to make real time video work.
And my questions are:
[Client] How to get video from webcam on laptop (using ffmpeg code), save it to buffer (raw data), encode it and send to server?
I use ffmpeg to get video from wc but it save to file. I really don't want it. Code is:
ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv
[Client] How to get raw data from client, decode it and play it?
I have an idea to play it by using directshow in MFC.
If you must you could implement your own player in c++ using the FFmpeg libraries or the libav libraries. This allows you to support a wide range of codecs and formats.
On Windows you can use the c++ Windows Media Player Control, but it supports only a few formats, and no H.264.
You have the following options on the origin server (your Linux box):
vlc transcode
DivX3 with MP3 in ASF seem to be accepted by WMP:
cvlc input.mp4 --sout="#transcode{vcodec=DIV3,scale=Auto,acodec=mp3,ab=128,channels=2,samplerate=44100}:http{mux=asf,dst=:8080/}" --sout-keep
On the client you can retrieve the stream using http://server_address:8080.
ffmpeg with ffserver
Read the ffserver Documentation and Streaming media with ffserver in order to set it up.
For WMP you'll be using once again ASF:
# ASF compatible
<Stream test.asf>
Feed feed1.ffm
Format asf
VideoFrameRate 15
VideoSize 352x240
VideoBitRate 256
VideoBufferSize 40
VideoGopSize 30
AudioBitRate 64
StartSendOnKey
</Stream>
Source.
You can retrieve the stream using http://ffserver_address:port/stream_name.asf.

Media Foundation SinkWriter (MP4 FastStart)

I'm using Media Foundation to create an MP4 (H264 + AAC) output file out of an input MP4 after a series of filters. The creation of the video works perfectly and the video is reproduced without issues locally. The problem is that when executed remotely (through a web player or even VLC), the video doesn't start until it's fully downloaded.
I checked and confirmed that the http website hosting the file supports the Accepts-Ranges header field and after a while I figured out that the problem happens because the file hasn't been created with the "fast start" flag that allows for progressive download of the video.
I tried to search online for a solution, but I've been unable to find a way to apply that flag with Media Foundation's Sinkwriter. Any idea? (I can't use any external application to do this as this code is going to run within the Windows Store environment)
Progressive download requires that moov box goes before mdat box in the MPEG-4 file, which typically requires additional effort when the file is generated, and which is not the default behavior with Media Foundation.
Media Foundation introduced MF_MPEG4SINK_MOOV_BEFORE_MDAT attribute to handle this:
The default behavior of the mpeg4 media sink is to write 'moov' after
'mdat' box. Setting this attribute causes the generated file to write
'moov' before 'mdat' box.
In order for the mpeg4 sink to use this attribute, the byte stream
passed in must not be slow seek or remote for .
This feature involves an additional file copying/remuxing.
Note minimal requirements. Or, you need to post-process the file to move the moov box to the beginning.
See also:
How to generate "moov before mdat" MP4 video files with Media Foundation

Write compressed frames to mpeg4 chuncks c++

I'm looking to write already compressed (h264) image data into an MPEG-4 video file. Since this code needs to be optimized to run on an embedded platform the code should be as simple as possible.
Best would be to just give some header information (like height width format fourcc etc.) and a filename and the compressed data and have that transformed into a data chunck and writen to that file.
So what i need either of these:
MPEG-4 header information (what goes where exactly)
Is there a main header or are there just headers for each data chunck
What header information is needed for a single video stream (rectangular)
What header information is needed for adding audio
A simple MPEG-4 file writer that does not have to do the compression itself and also allows to add audio frames. (c/c++)
.MP4 file format is described in MPEG-4 Part 14 specification. It is not just main header and subheaders, it has certain hierarchy and so called boxes in there. Some of your choice to write data into .MP4 file:
FFmpeg (libavcodec, libavformat) - related Q and related code link
In Windows via DirectShow API - GDCL MP4 Multiplexer or numerous commerical similar offerings
In Windows via Media Foundation API - MPEG-4 File Sink

Get MP4 stream lengths

I'm working in an app in wich we use IMediaDet to get stream lengths. Now we're starting to work with MP4 containers. The problem is, when I try an IMediaDet::put_fileName() with the MP4 file, I get HRESULT = -2147024770 (ERROR_MOD_NOT_FOUND). Using a comercial mp4 demuxer, I see the video stream uses mpg2 encoding.
My questions: How to get the stream length of a stream inside a MP4 container? Is there a way to make IMediaDet accept these files? Is there a way to point what demuxer IMediaDet should use?
Any help would be much appreciated.
Thanks.
Unfortunately, DirectShow does not contain an MP4 parser, even in Windows 7. In Win7, the MP4 functionality was added to media foundation.
So you have a few options. You can buy or build a directshow filter that implements an MP4 demux and associate it with the "mp4" file extension, which should allow IMediaDet to properly demux the file. Or you can use Media Foundation, which should be able to return this info. Or you could use a separate library entirely for MP4 files, like MP4v2. (note you could also implement an MP4 demux filter with MP4v2, if you want to use DirectShow instead of MP4v2 directly)