PDA

View Full Version : Open customized video file



cass
1st May 2010, 17:26
Hi

I would like to use my own customized QIODevice to open a video file in QT using Phonon. This should theoretically allow me to play specially encrypted video files. I noticed that MediaSource ( QIODevice * ioDevice ) can take an QIODevice and as a test I tried a basic QFile as a source.



VideoPlayer* video = new VideoPlayer(Phonon::VideoCategory);

main->setWidget(video); // My own class that puts the VideoPlayer on the window at the correct position.

QFile* f = new QFile("data/myvideo.MP4");
if (f->open(QIODevice::ReadOnly))
{
video->play(MediaSource(f));
}


When I debug the code, the file opens successfully, but I only get a "black box" with no video or audio.

When I replace MediaSource(f) with MediaSource("data/myvideo.MP4"), it works but I would like to be able to modify (decrypt) the stream before it get send to the VideoPlayer.

Any ideas?

squidge
1st May 2010, 17:41
Which OS?

I'm thinking of the caveat: "Under Windows, we only support QIODevices containing the avi, mp3, or mpg formats"

tbscope
1st May 2010, 17:43
Is this one Windows? If so, the documentation says:


Warning: On Windows, we only support QIODevices containing the avi, mp3, or mpg formats. Use the constructor that takes a file name to open files (the Qt backend does not use a QFile internally).

cass
1st May 2010, 19:43
Yes, I am developing for Windows now. Will probably port to other platforms at a later stage.

If QT does not support QFile internally, are there maybe another way to manipulate the byte stream before passing it to the Phonon Framework without rewriting QT's source code?

squidge
1st May 2010, 22:50
Depending on the size of the video, perhaps QBuffer? It does mean holding the entire content in memory, which isn't ideal and maybe impossible.

Otherwise, difficult, as the player will assume a file and treat as such, so you can't really stream it.

tbscope
2nd May 2010, 08:52
If QT does not support QFile internally, are there maybe another way to manipulate the byte stream before passing it to the Phonon Framework without rewriting QT's source code?

Note that Phonon was only designed to create simple playback of media files.