void VideoControls::loadVideoFile(void) { QString filename = QFileDialog::getOpenFileName(parentWidget(), QObject::tr("Open a video..."), ".", "*.mp4 *.avi *.mov *.flv *.webm"); if (!filename.isEmpty()) { pause(); try { std::string stdFilename = filename.toStdString(); VideoStream* tmp = new VideoStream(stdFilename, numFrameBuffered, minFilter, magFilter, sWrapping, tWrapping, maxMipmapLevel); if(stream!=NULL) delete stream; stream = tmp; timeSlider.setRange(0, stream->getVideoDurationSec()); QFileInfo pathInfo( filename ); QString strippedFilename( pathInfo.fileName() ); updateInfoTool(strippedFilename); emit newVideoLoaded(); play(); } catch(Exception& e) { QMessageBox::information(parentWidget(), tr("VideoControls::loadVideoFile - Error while loading the video : "), e.what()); } } }
string modulenameFromFilename(const string &filename) { // blank filename is an error string strippedFilename(trimRight(trimLeft(filename, "\t "), "\t ")); if (strippedFilename == "") { THROW(ArgExc, "Expected non-blank filename"); } vector<string> filenameComponents(split(strippedFilename, '.')); return filenameComponents[0]; }
void VideoRecorderControls::startRecording(unsigned int portID, const std::string& portName, const HdlAbstractTextureFormat& fmt) { if(!isRecording()) { QString filename = QFileDialog::getSaveFileName(parentWidget()); if (!filename.isEmpty()) { try { // Create recorder : std::string filenameStd = filename.toStdString(); recorder = new VideoRecorder(filenameStd, fmt, frameRate, bitRate_bitPerSec, pixFmt); QFileInfo pathInfo( filename ); QString strippedFilename( pathInfo.fileName() ); // Save info : recordedPort = portID; // Show the info box : recordingDialog.updateFilename(strippedFilename.toStdString()); recordingDialog.updatePortName(portName); recordingDialog.updateFormat(fmt); recordingDialog.updateStatus(true); recordingDialog.updateFrameRate(frameRate); recordingDialog.updatePixelFormat(pixFmt); recordingDialog.updateBitRate(bitRate_bitPerSec); recordingDialog.updateFrameCount(0); recordingDialog.updateDuration(0.0f); recordingDialog.show(); } catch(Exception& e) { QMessageBox::information(parentWidget(), "VideoRecorderControls::startRecording - Error : ", e.what()); } } } else QMessageBox::information(parentWidget(), "VideoRecorderControls::startRecording", "A recording session is already in place."); }