Exemplo n.º 1
0
    def RecordVideo(self, value):
        ''' Cut Video '''
        currentTime = _seconds_to_time(self.currentInfo)

        if value is False:
            self.endRecord = currentTime
            _, file_extension = os.path.splitext(self.fileName)

            out, _ = askForFiles(self,
                                 QCoreApplication.translate(
                                     "QgsFmvPlayer", "Save video record"),
                                 isSave=True,
                                 exts=file_extension[1:])

            if not out:
                self.StopRecordAnimation()
                return

            p = _spawn([
                '-i', self.fileName, '-ss', self.startRecord, '-to',
                self.endRecord, '-preset', 'ultrafast', '-c', 'copy', out
            ])
            p.communicate()
            qgsu.showUserAndLogMessage(
                QCoreApplication.translate("QgsFmvPlayer",
                                           "Save file succesfully!"))

            self.StopRecordAnimation()
        else:
            self.startRecord = currentTime
            self.RecGIF.frameChanged.connect(self.ReciconUpdate)
            self.RecGIF.start()
        return
Exemplo n.º 2
0
    def RecordVideo(self, value):
        ''' Cut Video '''
        currentTime = _seconds_to_time(self.currentInfo)

        if value is False:
            self.endRecord = currentTime
            _, file_extension = os.path.splitext(self.fileName)

            out, _ = askForFiles(self,
                                 QCoreApplication.translate(
                                     "QgsFmvPlayer", "Save video record"),
                                 isSave=True,
                                 exts=file_extension[1:])

            if not out:
                self.StopRecordAnimation()
                return

            taskRecordVideo = QgsTask.fromFunction(
                'Record Video Task',
                self.RecordVideoTask,
                infile=self.fileName,
                startRecord=self.startRecord,
                endRecord=self.endRecord,
                out=out,
                on_finished=self.finishedTask,
                flags=QgsTask.CanCancel)

            QgsApplication.taskManager().addTask(taskRecordVideo)

        else:
            self.startRecord = currentTime
            self.RecGIF.frameChanged.connect(self.ReciconUpdate)
            self.RecGIF.start()
        return
Exemplo n.º 3
0
 def OpenVideoFile(self):
     ''' Open Video File '''
     filename, _ = askForFiles(self, QCoreApplication.translate(
         "Multiplexor", "Open file"),
         exts=self.Exts)
     if filename:
         self.video_file = filename
         self.ln_inputVideo.setText(self.video_file)
     return
Exemplo n.º 4
0
 def OpenCsvFile(self):
     ''' Open Csv File '''
     filename, _ = askForFiles(self, QCoreApplication.translate(
         "Multiplexor", "Open file"),
         exts="csv")
     if filename:
         self.csv_file = filename
         self.ln_inputMeta.setText(self.csv_file)
     return
Exemplo n.º 5
0
    def openVideoFileDialog(self):
        ''' Open video file dialog '''
        filename, _ = askForFiles(
            self,
            QCoreApplication.translate("ManagerDock", "Open video"),
            exts='*.mpeg4 *.mp4 *.ts *.avi *.mpg *.H264 *.mov')
        if filename:
            _, name = os.path.split(filename)
            self.AddFileRowToManager(name, filename)

        return
Exemplo n.º 6
0
    def SaveAsPDF(self):
        """ Save Table as pdf """
        timestamp = str(self.player.player.position()) + " seconds"
        frame = self.player.videoWidget.GetCurrentFrame()
        data = self.player.GetPacketData()
        rows = self.VManager.rowCount()
        columns = self.VManager.columnCount()
        fileName = self.player.fileName

        out, _ = askForFiles(self,
                             QCoreApplication.translate(
                                 "QgsFmvMetadata", "Save PDF"),
                             isSave=True,
                             exts='pdf')
        if out == "":
            return

        def finished(e):
            QApplication.restoreOverrideCursor()
            if e is None:
                qgsu.showUserAndLogMessage(
                    QCoreApplication.translate("QgsFmvMetadata",
                                               "Succesfully creating PDF"))
            else:
                qgsu.showUserAndLogMessage(QCoreApplication.translate(
                    "QgsFmvMetadata", "Failed creating PDF : "),
                                           str(e),
                                           level=QGis.Warning)
            return

        task = QgsTask.fromFunction('Save PDF Report Task',
                                    QgsFmvMetadata.CreatePDF,
                                    out=out,
                                    timestamp=timestamp,
                                    data=data,
                                    frame=frame,
                                    rows=rows,
                                    columns=columns,
                                    fileName=fileName,
                                    VManager=self.VManager,
                                    on_finished=finished,
                                    flags=QgsTask.CanCancel)

        QCoreApplication.processEvents()
        tm.addTask(task)
        QCoreApplication.processEvents()
        while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
            QCoreApplication.processEvents()
            pass
        while QgsApplication.taskManager().countActiveTasks() > 0:
            QCoreApplication.processEvents()
        return
Exemplo n.º 7
0
    def openVideoFileDialog(self):
        ''' Open video file dialog '''
        Exts = ast.literal_eval(parser.get("FILES", "Exts"))
        filename, _ = askForFiles(self,
                                  QCoreApplication.translate(
                                      "ManagerDock", "Open video"),
                                  exts=Exts)

        if filename:
            _, name = os.path.split(filename)
            self.AddFileRowToManager(name, filename)

        return
Exemplo n.º 8
0
    def openVideoFileDialog(self):
        ''' Open video file dialog '''
        self.isStreaming = False
        filename, _ = askForFiles(self,
                                  QCoreApplication.translate(
                                      "ManagerDock", "Open video"),
                                  exts=Exts)

        if filename:
            _, name = os.path.split(filename)
            self.AddFileRowToManager(name, filename)

        return
Exemplo n.º 9
0
    def SaveAsPDF(self):
        """Save Table as pdf
        The drawings are saved by default
        """
        timestamp = qgsu._seconds_to_time(self.player.currentInfo)

        # Frame save drawings
        frame = BurnDrawingsImage(
            self.player.videoWidget.currentFrame(),
            self.player.videoWidget.grab(
                self.player.videoWidget.surface.videoRect()).toImage(),
        )

        data = self.player.GetPacketData()
        rows = self.VManager.rowCount()
        columns = self.VManager.columnCount()
        fileName = self.player.fileName

        out, _ = askForFiles(
            self,
            QCoreApplication.translate("QgsFmvMetadata", "Save PDF"),
            isSave=True,
            exts="pdf",
        )
        if not out:
            return

        task = QgsTask.fromFunction(
            "Save PDF Report Task",
            self.CreatePDF,
            out=out,
            timestamp=timestamp,
            data=data,
            frame=frame,
            rows=rows,
            columns=columns,
            fileName=fileName,
            VManager=self.VManager,
            on_finished=self.finishedTask,
            flags=QgsTask.CanCancel,
        )

        QgsApplication.taskManager().addTask(task)
        return
Exemplo n.º 10
0
    def SaveACSV(self):
        """ Save Table as CSV  """
        data = self.player.GetPacketData()
        out, _ = askForFiles(self, QCoreApplication.translate(
            "QgsFmvMetadata", "Save CSV"),
            isSave=True,
            exts='csv')
        if not out:
            return

        task = QgsTask.fromFunction('Save CSV Report Task',
                                    self.CreateCSV,
                                    out=out,
                                    data=data,
                                    VManager=self.VManager,
                                    on_finished=self.finishedTask,
                                    flags=QgsTask.CanCancel)

        QgsApplication.taskManager().addTask(task)
        return
Exemplo n.º 11
0
    def SaveACSV(self):
        """ Save Table as CSV  """
        data = self.player.GetPacketData()
        out, _ = askForFiles(self,
                             QCoreApplication.translate(
                                 "QgsFmvMetadata", "Save CSV"),
                             isSave=True,
                             exts='csv')
        if out == "":
            return

        def finished(e):
            QApplication.restoreOverrideCursor()
            if e is None:
                qgsu.showUserAndLogMessage(
                    QCoreApplication.translate("QgsFmvMetadata",
                                               "Succesfully creating CSV"))
            else:
                qgsu.showUserAndLogMessage(QCoreApplication.translate(
                    "QgsFmvMetadata", "Failed creating CSV : "),
                                           str(e),
                                           level=QGis.Warning)
            return

        task = QgsTask.fromFunction('Save CSV Report Task',
                                    QgsFmvMetadata.CreateCSV,
                                    out=out,
                                    data=data,
                                    VManager=self.VManager,
                                    on_finished=finished,
                                    flags=QgsTask.CanCancel)

        QCoreApplication.processEvents()
        tm.addTask(task)
        QCoreApplication.processEvents()
        while task.status() not in [QgsTask.Complete, QgsTask.Terminated]:
            QCoreApplication.processEvents()
            pass
        while QgsApplication.taskManager().countActiveTasks() > 0:
            QCoreApplication.processEvents()
        return
Exemplo n.º 12
0
    def ExtractCurrentFrame(self):
        """ Extract Current Frame Task """
        image = self.videoWidget.GetCurrentFrame()
        output, _ = askForFiles(self,
                                QCoreApplication.translate(
                                    "QgsFmvPlayer", "Save Current Frame"),
                                isSave=True,
                                exts=["png", "jpg", "bmp", "tiff"])

        if not output:
            return

        taskCurrentFrame = QgsTask.fromFunction('Save Current Frame Task',
                                                self.SaveCapture,
                                                image=image,
                                                output=output,
                                                on_finished=self.finishedTask,
                                                flags=QgsTask.CanCancel)

        QgsApplication.taskManager().addTask(taskCurrentFrame)
        return
Exemplo n.º 13
0
    def saveInfoToJson(self):
        """ Save video Info to json """
        out_json, _ = askForFiles(self,
                                  QCoreApplication.translate(
                                      "QgsFmvPlayer", "Save Json"),
                                  isSave=True,
                                  exts="json")

        if not out_json:
            return

        taskSaveInfoToJson = QgsTask.fromFunction(
            'Save Video Info to Json Task',
            self.converter.probeToJson,
            fname=self.fileName,
            output=out_json,
            on_finished=self.finishedTask,
            flags=QgsTask.CanCancel)

        QgsApplication.taskManager().addTask(taskSaveInfoToJson)
        return
Exemplo n.º 14
0
    def openVideoFileDialog(self):
        ''' Open video file dialog '''
        if self.loading:
            return

        Exts = ast.literal_eval(parser.get("FILES", "Exts"))

        filename, _ = askForFiles(self,
                                  QCoreApplication.translate(
                                      "ManagerDock", "Open video"),
                                  exts=Exts)

        if filename:
            if not self.isFileInPlaylist(filename):
                _, name = os.path.split(filename)
                self.AddFileRowToManager(name, filename)
            else:
                qgsu.showUserAndLogMessage(
                    QCoreApplication.translate(
                        "ManagerDock",
                        "File is already loaded in playlist: " + filename))

        return
Exemplo n.º 15
0
    def convertVideo(self):
        '''Convert Video To Other Format '''
        out, _ = askForFiles(self,
                             QCoreApplication.translate(
                                 "QgsFmvPlayer", "Save Video as..."),
                             isSave=True,
                             exts=[
                                 "mp4", "ogg", "avi", "mkv", "webm", "flv",
                                 "mov", "mpg", "mp3"
                             ])

        if not out:
            return

        # TODO : Make Correct format Conversion and embebed metadata
        info = self.converter.probeInfo(self.fileName)
        if info is not None:
            if self.HasFileAudio:
                audio_codec = info.audio.codec
                audio_samplerate = info.audio.audio_samplerate
                audio_channels = info.audio.audio_channels

            video_codec = info.video.codec
            video_width = info.video.video_width
            video_height = info.video.video_height
            video_fps = info.video.video_fps

        _, out_ext = os.path.splitext(out)

        if self.HasFileAudio:
            options = {
                'format': out_ext[1:],
                'audio': {
                    'codec': audio_codec,
                    'samplerate': audio_samplerate,
                    'channels': audio_channels
                },
                'video': {
                    'codec': video_codec,
                    'width': video_width,
                    'height': video_height,
                    'fps': video_fps
                }
            }
        else:
            options = {
                'format': out_ext[1:],
                'video': {
                    'codec': video_codec,
                    'width': video_width,
                    'height': video_height,
                    'fps': video_fps
                }
            }

        taskConvertVideo = QgsTask.fromFunction('Converting Video Task',
                                                self.converter.convert,
                                                infile=self.fileName,
                                                outfile=out,
                                                options=options,
                                                twopass=False,
                                                on_finished=self.finishedTask,
                                                flags=QgsTask.CanCancel)

        QgsApplication.taskManager().addTask(taskConvertVideo)
Exemplo n.º 16
0
 def openMetadataFileDialog(self):
     '''Open metadata file dialog'''
     dataname, _ = askForFiles(self, exts="txt", textFile=True)
     return dataname
Exemplo n.º 17
0
    def CreateBitratePlot(self):
        ''' Create video Plot Bitrate Thread '''
        sender = self.sender().objectName()

        if sender == "actionAudio":
            taskactionAudio = QgsTask.fromFunction(
                'Show Audio Bitrate',
                self.BitratePlot.CreatePlot,
                fileName=self.fileName,
                output=None,
                t='audio',
                on_finished=self.finishedTask,
                flags=QgsTask.CanCancel)

            QgsApplication.taskManager().addTask(taskactionAudio)

        elif sender == "actionVideo":
            taskactionVideo = QgsTask.fromFunction(
                'Show Video Bitrate',
                self.BitratePlot.CreatePlot,
                fileName=self.fileName,
                output=None,
                t='video',
                on_finished=self.finishedTask,
                flags=QgsTask.CanCancel)

            QgsApplication.taskManager().addTask(taskactionVideo)

        elif sender == "actionSave_Audio":
            fileaudio, _ = askForFiles(self,
                                       QCoreApplication.translate(
                                           "QgsFmvPlayer",
                                           "Save Audio Bitrate Plot"),
                                       isSave=True,
                                       exts=[
                                           "png", "pdf", "pgf", "eps", "ps",
                                           "raw", "rgba", "svg", "svgz"
                                       ])

            if not fileaudio:
                return

            taskactionSave_Audio = QgsTask.fromFunction(
                'Save Action Audio Bitrate',
                self.BitratePlot.CreatePlot,
                fileName=self.fileName,
                output=fileaudio,
                t='audio',
                on_finished=self.finishedTask,
                flags=QgsTask.CanCancel)

            QgsApplication.taskManager().addTask(taskactionSave_Audio)

        elif sender == "actionSave_Video":
            filevideo, _ = askForFiles(self,
                                       QCoreApplication.translate(
                                           "QgsFmvPlayer",
                                           "Save Video Bitrate Plot"),
                                       isSave=True,
                                       exts=[
                                           "png", "pdf", "pgf", "eps", "ps",
                                           "raw", "rgba", "svg", "svgz"
                                       ])

            if not filevideo:
                return

            taskactionSave_Video = QgsTask.fromFunction(
                'Save Action Video Bitrate',
                self.BitratePlot.CreatePlot,
                fileName=self.fileName,
                output=filevideo,
                t='video',
                on_finished=self.finishedTask,
                flags=QgsTask.CanCancel)

            QgsApplication.taskManager().addTask(taskactionSave_Video)