Detect if video has no audio in C++, preferable using Qt Phonon - c++

I am creating a video player if Phonon and Qt. everything is working fine, but when I have a video in my playlist that does not have audio I wish to play another audio.
how can I do that? I mean, how can I detect that the video has no audio?
EDIT: By no audio I meant "no audio channel"

Qt 5 might help you out. Check out Phonon::Gstreamer::MediaObject. The API is similar to the ordinary MediaObject, but with some additional functions. The one you want is audioAvailable().

Related

libVLC creates two audio streams

I'm using libVLC to play a video file. If I use my code in as standalone video player, I am having no issues. The video plays very well. I can pause and play the video as I like.
When I use the same code, without modifications, in a plugin, and then play the same file, something unique happens: VLC creates two audio streams for the same video file. Now if I pause the video using libvlc_media_player_pause(...), it pauses the video and one audio stream. The other audio stream continues playing.
Any suggestions as to why this could be happening?
The application itself is written in Qt5. I have tested this issue with both audio and video files.
LibVLC version is 3.0.0
Header file and Source file are pastebin links
The mistake I did was in the code for plugin. Two instances of NBAVPlayer were created in the plugin code leading to two audio streams, one visible video stream and one hidden video stream. I have fixed the issue with the plugin, and now everything works properly.

Audiooutput problem in Qt using qmultimedia low level API

I'm trying to get mpg123 audio decoder to work with QT on windows. How do i play the decoded audio data at the right speed with Qmultimedia module in push mode. Currently i'm using simple timer to get it to play audio but it's not very efficient way to do it, if I do anything else at the same time audio get all distorted. Is there any better way to send the decoded data to audio output? It would be nice if anyone could point me to any nice examples using Qmultimedia module and Qaudiooutput class. I've tried to figure out QT example project "audiooutput" but it seems that it's also using timer to send audio to output in push mode.. Hope that I'm not too confusing.
I also had to figure that out and I would also suggest using the Phonon framework to do this.
It uses Windows Media Player as host on Windows, QuickTime on Mac and some KDE stuff on Linux.
So it's pretty platform independent.
If you need more low-level functionality, you should take a look into an open-source project called portaudio. It's very easy to use and you can manipulate or even fill buffers from code.
I used it to build an oscillator.
Hope that helps!
Best,
guitarflow

Display streaming video in desktop app

I have a Windows native desktop app (C++/Delphi), and I'm successfully using Directshow to display live video in it from a 'local' video capture device.
The next thing I want to do is display video from a 'remote' capture device, streamed over the LAN.
To stream the video, I guess I can use something like Expression Encoder or VLC, but I'm not sure what's the easiest way to receive/decode the streamed video. Inserting an ActiveX VLC or Flash player might be one option (although the licensing may be an issue then), but I was wondering if there's any way to achieve this with Directshow...
Application needs to run on XP, and the video decoding should ideally be royalty free.
Suggestions, please!
Using Directshow for receiving and displaying your video can work, but the simplicity, "openness" and performances will depend on the video format and streaming method you'll be using.
A lot of open/free source filters exist for RTSP (e.g. based on live555), but you may also find that creating your own source filter is a better fit.
The best solution won't be the same for H264 diffusion through RTP/RTSP and for MJPEG diffusion through simple UDP.

video player with qt phonon (using python)

I am working on Windows xp and am trying to get a simple video player running.
I am trying to use Phonon::VideoPlayer module for this. I am connecting the signal as
connect(self.player,SIGNAL("finished()"),self.player.deleteLater)
and then , when the Play button is pressed, it makes the following call:
self.player.play(Phonon.MediaSource("C:\\vid.mp4"))
But, this doesn't display the video in the video player widget. Neither can I hear audio. Can anyone help??
I tried using different video file formats but no luck.
Try writing
self.player.play(Phonon.MediaSource("C:\\vid.mp4"))
to escape the \
Phonon::MediaSource mediaSource= Phonon::MediaSource("C:\\vid.mp4");
Try creating media sources like this and also other Phonon objects..

Play RTP video stream using Qt?

I want to create a Qt widget that can play incoming RTP streams where the video is encoded as H264 and contains no audio.
My basic plan for implementation is this:
Create a Phonon MediaSource object (Stream type).
Connect it with a QIODevice subclass that provides the data
Obtain the video data using either:
The JRTPLIB client library
The GStreamer gstrtpbin plugin. This plugin takes care depayloading the packages and decoding the video. Maybe this improves the chances that Phonon will recognize the data.
My environment:
Ubuntu 9.10
Qt 4.6
My questions:
Is my approach a good one? Perhaps I'm overlooking a more obvious or simple solution?
I'm currently experiencing this issue: when trying to play the video stream the state of the MediaObject turns to ErrorState with errorType FatalError. Can anyone tell me what I'm doing wrong?
Edit
One solution I found is using libVLC in combination with Qt, which I learned about in this thread. Here's a code sample for the interested.
I'm still looking for a Phonon-based solution.
Ideally I would only need to provide an SDP file and job is done.
I was able to get it to work using the libVLC solution. I can't garantuee that this is the best solution though as I simply stopped looking after that.
Here's a link to the libVLC sample.
The way I understand Phonon works at least in Windows is that QT provides a phonon backend plugin for DirectShow (\plugins\phonon_backend\phonon_ds94.dll) and GStreamer in your case. Then you would either obtain or write your own DirectShow filter which can accept RTP streams as a source. DirectShow takes care of the decoding, and Phonon will take care of the rendering.
So if the backend works, the application code is as simple as:
Phonon::MediaObject *media = new Phonon::MediaObject();
Phonon::VideoWidget *video = new Phonon::VideoWidget();
Phonon::createPath(media, video);
media->setCurrentSource(source);
media->play();
Seems that the problem lies with the GStreamer backend accepting RTP as a source. Can you playback that source in standalone GStreamer without any problems?