How can one play a FLV file from Youtube in a C++ application? - c++

I'm using C++ to get Youtube video links, but now I would like to be able to play a stream in my application.
Using C++ wxWidgets, what cross platform options do I have?

Look at existing video players like mplayer or vlc that can both play flv files.
It you want a something a a somewhat lower level, Qt::media supports Gstream that supports flv. However this might go against what you want as you use wxwidgets.
Then, you can directly look into integrating GStreamer in your app.

The wxMediaCtrl class in wxWidgets is used to play video:
http://docs.wxwidgets.org/stable/wx_wxmediactrl.html
http://docs.wxwidgets.org/trunk/classwx_media_ctrl.html
On MacOS X and Windows wxMediaCtrl uses the native backend, and on Linux GStreamer. I don't know if the native backends on the first two support flv.

FFMPEG supports demuxing and decoding of the FLV format (among others), and is the best implementation I know of besides Flash itself. It's relatively easy to use, and it's used by all of the software others have suggested for decoding of Flash Video.

After some searching in google I believe there isn't something pre-made in C++ that will match WxWidgets but you should be able to find a decoder and use it's API.

Related

WebCam Preview and Capture to File (Windows)

What are the available options for creating applications that allow preview of a webcam and exporting the current webcam image to file?
EDIT: I've since found that MS Media Foundation offers similar features to DirectShow that work from Vista upwards. However, while apparently possible, the documentation, samples, and forums don't suggest an easy way to perform the above. On the other hand, with DirectShow you can fairly easily merge two of the sample apps to achieve it.
EDIT: Researching available camera APIs I've also found the MS MediaCapture API looks useful but this seems to be only available on windows 8 (and may be limited to managed C++/.net/javascript).
EDIT: DirectShow is supported on the Windows 8 standard desktop (For Metro style applications the video platform is Media Foundation).
Consider using directshow. You may have a look here
You basically found the answers yourself. DirectShow and Media Foundation are the APIs. Neither of the two cover all Microsoft environments: Metro supports a subset of MF, and MF is not available in legacy OSes. DirectShow is presumably easier, more flexible, with more sample code around.

Any cross-platform video playback library for c++?

I mainly code using the Qt library, which is cross-platform enough for my need. However, I found out that if I'd like to play a video file there are no good options for cross-platform video playback. The Phonon module doesn't seem to work on my machine and I am not sure if it is supported on the major platforms (Windows, OSX, Linux).
Are their any light-weight alternatives for simple video playback? I would be okay to change my video to any format as long as its playable cross-platform.
I am considering libVLC as one option. Someone have already made a wrapper but it only supports Windows and Linux.
I found the Theora playback library to be very useful and only depends on the original theora library. Here is a simple Qt project I made that encapsulate everything needed to play (only video) theora media. You just type 'qmake' and you are good to go.
According to the documentation is appears Phonon needs third party libraries to work correctly. Have you installed the appropriate backend to the platform you're on?
From the documentation:
Backends
The multimedia functionality is not implemented by Phonon itself, but
by a back end - often also referred to as an engine. This includes
connecting to, managing, and driving the underlying hardware or
intermediate technology. For the programmer, this implies that the
media nodes, e.g., media objects, processors, and sinks, are produced
by the back end. Also, it is responsible for building the graph, i.e.,
connecting the nodes. The backends of Qt use the media systems
DirectShow (which requires DirectX) on Windows, QuickTime on Mac, and
GStreamer on Linux. The functionality provided on the different
platforms are dependent on these underlying systems and may vary
somewhat, e.g., in the media formats supported.
Backends expose
information about the underlying system. It can tell which media
formats are supported, e.g., AVI, mp3, or OGG.
A user can often add
support for new formats and filters to the underlying system, by, for
instance, installing the DivX codex. We can therefore not give an
exact overview of which formats are available with the Qt backends.
QtWebKit 2.2 has support for HTML5 media. It should (at least eventually) be pretty cross-platform, but probably has the same backend issues as Phonon. But a Q(Graphics)WebView with a <video> element could do the trick for a truly play-and-forget solution.

How does one stream and play Youtube/FLV videos in a C++ application?

I would like to stream and play Youtube videos, or FLV files in general, in a C++ application. How can it be done? (I'm using QT as a GUI)
You have two problems to tackle.
First one you need the player technology. For that you can use ffmpeg but bear in mind that it is licensed under GPL (older version in LGPL).
The second thing is that you need access to the FLV video urls. For this you either scrape the website or used the YouTube GData APIs. If you decide to go for the latter you need to know that you'll need a special deal with YouTube/Google to be granted access to the high quality streams. Usually you don't get access to the FLV ones.
How about Qt with Phonon plus a backend that can decode flv streams?

if i want to play mp3's what is the difference between lame and MCI(VFW32)?

basic question , i need to play mp3's in my application in windows
when goggling i got allot of tutorials about VFW32.lib to play mp3's
and i know lame , what is the best option for playing mp3's in c++?
VfW is an API that predates DirectShow on Windows, and was the original API that provided access to the system's video codecs. I'd wager that today, it's extremely non-portable, and shouldn't be used. Instead, prefer either the DirectShow API or a separate library like either Lame or libmad or a framework like ffmpeg.

Playing sounds with C++?

How would i make it so in my program there is a button when that button is clicked i want it to play a .wma file without opening and media player?
The C++ standard does not include this functionality. That means it depends on what your system offers.
For Windows, you can try something like PlaySound.
However, you best bet is to use a pre-existing library, like:
OpenAL
BASS
FMOD
SDL's: Sound.
Searching for C++ Sound Library brings up a lot of information.
Also, check out these three other SO topics:
What Is The Best C++ Sound API For Windows?
How to play MP3 files in C?
Learning to work with audio in C++
Although the above answer mentions it (and everything else, it doesn't give any recommendations so...), FMOD is the king of C++ sound (the most used) and works great so I'd recommend FMOD in particular.
Gstreamer is a free, cross-platform multimedia framework written in C (using GObject) that allows encoding/decoding for many types of media, including wma. Very easy to use and well documented.
KDE's Phonon is a cross-platform(!) C++ multimedia library. It supports native sound systems as backends. Worth a look if you haven't seen it before, and a simple video player can be written in a mere 83 lines of code.
For Windows, in all honesty your best bet is DirectShow. The RenderFile API allows you to play most audio file types with just a few lines of code.
The best part about DirectShow is that it's a part of the Windows platform so you don't need to bundle an external component.