I try to read a .avi file on MacOS X with Phonon and Qt. But I can't. Even in QtDemo, the "Media Player" is not able to display those kind of file. Is there a way to make it work ?
Try installing the right codecs to the system. "avi" is actually just a container file format that can contain media encoded with many possible audio and video codecs, that might not be supported/installed by default in OS-X. Phonon itself doesn't provide media decoding capabilities, it uses whatever is available on the system or separately configured as it's back end.
Related
I need to write a (portable) program that, amongst other things, is able to play a video file. The QMediaPlayer in Qt5 seems to be the obvious choice, but apparently it only uses codecs that are installed on the executing machine.
All I need for the video player is being able to play at least one video format on all (windows) machines without installing anything, and communicate the current status to the main program (currrent time in ms, playing/paused).
Specific question: Can someone give me some hints where I have to look? How can I implement a video codec into my program so that QMediaPlayer can reliably play videos on all machines? Alternatively (but less prefered): How to (easily) implement another video player into the program that is capable of doing the task?
I've already tried my luck with libVLC and one or two other options but it never worked so far and it seems to make my program way more complex than it has to be.
QMediaPlayer can play any format that the platform's media service supports. You should install the right codecs for a video type to be played successfully. So you have to install GStreamer codecs on Linux or if you are on Windows you should install something KLite Codecs.
May be it is good to consider using libraries like QtAV. It will work for most platforms and no additional codecs and plugins are required to install.
QtAV uses FFmpeg and has some interesting features like multiple renderers for 1 player, region of interest(video crop), custom filters, ... It also works fine for both Qt4 and Qt5.
QMediaPlayer uses the underlaying video framework of whatever machine you use, that means there's no way to portable write a player using such class. Your only solution, in my opinion, is switching to FFMpeg playback library, that uses native codecs instead.
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
How to save an IPLImage of OpenCV as a Flash file? Maybe there is a library that does that?
If you mean storing your output as a flash video (.flv) just use ffmpeg (libavcodec/libavformat). It is cross platform and supports the .flv format (besides a massive amout of others) and should be quite easy to do. You can embed audio too.
As a note: ffmpeg is partially included in opencv (depending on your build) as a video coder/decoder, i don't know though if you can force it to write as .flv (by choosing the right codec string) from within opencv. Anyways it's not too hard to convert IplImage to a ffmpeg buffer and store from there.
A problem you might have is that latest opencv (2.1) has trouble to build with ffmpeg support or is build against some ffmpeg version you don't want. But as mentioned above you don't need to use ffmpeg via the opencv 2.1 api, since you can use it directly by using the ffmpeg api.
Look for the examples in libavcodec on how to write a video, and check the opencv source on how to convert from IplImage to AVPacket/AVFrame. I've done this before and it was quite
easy to do.
I don't know Flash much, but you can manipulate the data pointer of an IplImage (named char *imageData). Data is accessible as between 1 and 4 bit plans, in a format you surely know. Try writing your Flash file from this data pointer.
lital , Well to my knowledge openCV doesn't support creating flash .
My solution for such a problem is Red5 Server
and as their page says
Red5 is an Open Source Flash Server
written in Java that supports:
Streaming Video (FLV, F4V, MP4)
....
You could dump your images in a sequence of files, say img00000.ppm, img00001.ppm, ..., and then delegate the video encoding to MEncoder, which, according to docs, supports flv.
That's what we usually do in order to prepare videos such as this one.
My application is transforming an AVI video file into another AVI file. I use
the OpenCV library. Unfortunately videos created with OpenCV have no sound as the library does not support audio.
Is there any easy way to copy the audio track from one video file to another? Maybe FFmpeg?
My application is written in Visual C++.
You can use FFmpeg. The easiest way would be to just use the command line tool to extract/reassemble. If you need your application to do it itself, looking into the sources for how they do it should help.
Alternatively, as you mention VC++, why not use DirectShow? It should not be too difficult to sink the audio into a file for extraction and later sink the video/audio mix into a file for composition.
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.