Extracting video sequences into a new file
Hello,
I am trying to make a video/music player which let the user extract small sequences into a new file. First I am trying to understand how qt mutimedia works and how I could extract small sequences into a new file.
For instance I have a video inVideo.mp3 that last 200 secondes.
I want to extract the following intervals [4,10], [12,32] and [150,171] into a new video outVideo.mp2.
Anyeone know how I could do that?
Right now I tried that:
Here is my MainWindow.cpp.
[CODE]#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <iostream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
this->ui->setupUi(this);
QUrl urlInFile = QUrl::fromLocalFile("/home/cedric/VEG849.wmv");
this->playlist.addMedia(urlInFile);
this->player.setPlaylist(&playlist);
this->recorder = new QMediaRecorder(&player);
QVideoEncoderSettings videoEncoderSettings;
QAudioEncoderSettings audioEncoderSettings;
videoEncoderSettings.setCodec("video/mpeg2");
videoEncoderSettings.setResolution(640, 480);
audioEncoderSettings.setCodec("audio/vorbis");
audioEncoderSettings.setQuality(QtMultimediaKit::HighQuality);
this->recorder->setEncodingSettings(audioEncoderSettings, videoEncoderSettings);
QUrl urlOutFile = QUrl::fromLocalFile("/home/cedric/cuttedVideo.mp2");
this->recorder->setOutputLocation(urlOutFile);
this->connect(this->ui->startButton, SIGNAL(clicked()), this, SLOT(start()));
this->connect(this->ui->stopButton, SIGNAL(clicked()), this, SLOT(stop()));
//*/
}
MainWindow::~MainWindow()
{
delete ui;
delete this->recorder;
}
void MainWindow::start()
{
recorder->record();
player.play();
std::cout << "start" << std::endl;
//player.setPosition(2000);
}
void MainWindow::stop()
{
player.stop();
recorder->stop();
std::cout << "stop" << std::endl;
}
[/CODE]
I considere the other files not important but you can find them there:
[URL="http://code.google.com/p/testqtmobility/source/browse/#svn%2Ftrunk%2F04cutAudio"]http://code.google.com/p/testqtmobility/source/browse/#svn%2Ftrunk%2F04cutAudio[/URL]
The problem with that code is that the movie is playing and I can heard the sound. Also no new file is created.
Thanks in advance,
Cédric
Re: Extracting video sequences into a new file
Hi
According to the documentation setOutputLocation will work with QRadioTuner or QAudioCaptureSource. QMediaPlayer seems does not support recording
check this quite fresh discussion thread they came to the conclusion to use [URL="http://qt-project.org/forums/viewthread/14995"]Qt Phonon wrapper over Gstreamer[/URL]. Phonon library was used in Qt before QMobility. Not sure but the both provide different API from the same backend.
Regards,
Igor