PJY-609 / simple-video-encoder

a simple H.264 video encoder by PyQt5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple-video-encoder

a simple H.264 video encoder by PyQt5

requirements:

  1. python 3.6
  2. ffmpeg-python
  3. ffmpeg (see the question in stackoverflow)
  4. PyQt5
  5. LAVFilters (see the question in stackoverflow)

run main.py

cd .\video_encoder
python main.py

user guide

  1. File->Open->select the input video file

2. Settings->Set H264 Parameters

3. Encode->Begin Encode->type output filename

4. Result (CRF=40)


MVC pattern in Python

It is my first time to use MVC pattern to write a GUI. tutorial gives a neat mini-example to explain what MVC pattern is.
Download these three .py files and run them can give a clear sense of MVC pattern

  1. basics_backend.py
  2. model_view_controller.py
  3. mvc_exceptions.py.

A PyQt example of video player

see tutorial


Exceptions handling

I also learn something of exceptions handling in python. Thanks to the contributors in stackoverflow, my problem could be tackled properly. Here is my final solution,

def updateFilename(self):
    self.model.updateFilename(self.fileName)

def updateOutput(self):
    self.model.updateOutput(self.encodeDialog.output)

def encodeVideo(self):
    try:
        self.updateFilename()
        self.updateOutput()
        flag = True
    except (type_exc.PathIsEmpty, type_exc.FileAlreadyExists, type_exc.PathNotExists) as e:
        flag = False
        self.errorDialog.errorTypeChanged(e)
        self.errorDialog.exec_()

    if flag:
        self.model.encodeVideo()

About

a simple H.264 video encoder by PyQt5


Languages

Language:Python 100.0%