MPEG is a really nice format, specially because it really compress the file to unimaginable sizes. A 140Mb raw AVI is now only 4Mb and the quality is still very good. With the Animation Control Windows provides I can play only raw AVI but I would really like to play a MPEG instead, due to the the sizes of the video file.
Now, how would I do that with C++ and WINAPI? Do I have to use some ActiveX components? How do I make sure other users can run my application without being harassed about missing plug-ins/codecs/third-party programs? Can I use the Animation Control someway for displaying the MPEG video?
Thanks
I took a look at the MSDN documentation and it looks like you can not use the Animation Control to play MPEG video, you seem to have two choices:
1. DirectShow.
2 The newer Microsoft Media Foundation.
Both choices based on COM (and not ActiveX as I stated earlier).
As for making sure your users can run your application, see this page on Building DirectShow Applications which answers that questions for DirectShow. For Microsoft Media Foundation your users need to be running MS Vista or later.
Related
I need your advice. I'd like to develop the app for audio/video splitting using Metro interface.
Usually I use DirectShow for it using the follow schema: create a grabber, add it to DS graph, capture by it the audio/video streams and pass them to my AVstream drivers for splitting. But in new program I want to use Media Foundation and insert it into UWP.
How I see my new app. It must have Metro interface for common control: choice of sources, adding parameters, changing modes and etc. I'd like to use MediaCapture class for capture of streams and rendering them too. Here I don't see any problems, MSDN has many samples for it. But I have no ideas how to insert a grabber between source and render.
Which operations a grabber will do:
Receive input stream from MediaCapture.
Stream converting : YUV -> RGB, adding effects and etc.
Send output stream for rendering (MediaCapture) and to my AVstream driver for splitting with any apps (Skype, Adobe Flash Player, Edge, ....).
How to make a grabber. In MSDN I found three ways:
Sample Grabber Sink (https://msdn.microsoft.com/en-us/library/windows/desktop/hh184779(v=vs.85).aspx). No problem to receive/control/send stream in MF dll. But I don't know how to link that dll with MediaCapture?
Source Reader (https://msdn.microsoft.com/en-us/library/windows/desktop/dd940436(v=vs.85).aspx). The same problems, plus the Source Reader doesn't work for playback.
Custom MFT? Any case MediaCapture allows to connect to MFT by AddEffectAsync().
My environment: MS Windows 10, MS Visual Studio Community 2015.
Thank you for any ideas.
This question and UWP are not actual for me at all. I found the following:
"Some apps can work intensively in background, for example it maybe video converting, online financial data processing and more.
Now UWP application will suspended when it go offscreen."
https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/9950598-exclude-suspending-in-desktop
So if the user minimizes the program window, then the program stops a video stream.
Simply put, I want my C++/CX XAML Windows 8 app to output continuous synthesized sound (not sound effects). However I've been looking all over the Web and I cannot figure out how to get the system feed it buffers of PCM samples (or better, have it ask me for them through callbacks) for them to be played. I would use the old waveOut* APIs, however they are banned in Store app development.
So, what is the simplest way to do this? Please note that I am not interested in playing media files (.wav, .mp3) or web audio streaming.
Thanks in advance.
You need to use WASAPI which is enabled in Windows Store apps. This article will get you started with how to use the API to render audio. One annoyance is that WASAPI devices generally don't resample for you so you'll have to be willing to go with what the device is using (probably 44.1kHz or 48kHz) or do the resampling yourself (for which you can make use of the Resampler Media Foundation transform).
I need to add webcam video capture to a legacy MFC C++ application. The video needs to be saved as MP4. Did a bit of googling but didn't come across anything that looked promising. Any suggestions on the best approach?
EDIT:
Windows platform.
EDIT:
Must be compatible with XP
There are a few popular options to choose from:
DirectShow API - it does not have stock MPEG-4 compressors for video and audio, neither it has a stock multiplexor for .MP4 format, though there is an excellent free multiplexor from GDCL: http://www.gdcl.co.uk/mpeg4/. Also there is decent documentation, a lot of samples
Media Foundation API - it has everything you need (codecs, multiplexor) but only in Windows 7 (maybe even not all edtions)
FFmpeg and libavcodec/libavformat are definitely relevant, however H.264 encoder is only available under GPL license, not sure about video capture part right there, and you might have hard time looking for documentation and samples.
I'd say look at OpenCV as a library, hook into their video capture for that aspect, it can write out to mp4 but you'll need a couple of other libs for handling the output stream (on Linux I'd say ffmpeg and x264), that should get the buffer into the container with a reasonable amount of hassle.
I'm looking for resources (preferably books, but websites are fine too) for using FFmpeg and/or SDL with C++.
Stuff I'd like to be able to do (eventually):
Decode and play videos in realtime to a QT widget (the QT part isn't a problem)
Overlay text and images on the video (in realtime)
Loop video
Cross-fade from one video to another (in realtime)
Some kind of DVD functionality
LIVE sources? (i.e. webcam, stream, etc.)
So far I've looked at (and consider helpful) the following resources:
FFmpeg and SDL Tutorial by Dranger (extremely helpful)
Stack Overflow: ffmpeg C API documentation/tutorial (not a duplicate, btw)
Sample code bundled with FFMPEG libraries
(I'll try and update this list with anything helpful below)
Thanks for any help...
Also: Operating System is Windows (but maybe one day cross-platform)
Also 2: Resources using alternatives are welcome too... i.e. DirectShow, VFW, etc.
If all you need is to decode and play videos and require overlays I would consider using the Phonon framework, and use QT Graphics View by using a Phonon::VideoWidget inside a QGraphicsProxyWidget. That way you can easily get overlays, cross-fading, animations etc. Phonon in Windows uses DirectShow as a back-end. You can install FFDShow and get the same codecs ffmpeg has to play videos.
There is an FFMPEG C++ wrapper library : FOBS. It is quite simple to use, but what you gain in simplicity you lose in fine grained configuration. It works great but is always a bit outdated.
m2c
Im currently using wxMediaCtrl to play videos in my app. The api is unfortunately a little buggy, and doesn't playback all media types i need to support (e.g. wmv).
I am wondering if there is an alternative c++ api, that will allow me to do this. I am currently just concerned with supporting windows.
What do people normally use to embedd video in their apps? Also i need to be in control, i.e. tell the video, where to play in time, pause/stop, i dont need any shuttle controls, as i have my own.
Thanks in advance.
wxMediaControl uses DirectShow on Windows, it should be able to play wmv files. If you can play a media file with GraphStudio, you should be able to play it with wxMediaControl.
If not, you need to install the proper video codecs. Have you tried installing FFDShow?
You can try Video Control, and here is a sample on how you can play a video file.
If you want something without DirectShow, you can take a look at VLC ActiveX.
As a word of caution regarding the use of GPL plugins (FFDShow or VLC ActiveX) in non-GPL applications you should read this.
Qt uses Phonon for cross-platform media playback. On Windows Phonon utilizes DirectShow, so it can play anything Windows can (.wmv). It has all the capability you mentioned. It's also very easy to implement and use. I recommend highly.