2018-02-24 18:34:00 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Name: FFMPEG Class
|
|
|
|
Author: K4YT3X
|
|
|
|
Date Created: Feb 24, 2018
|
|
|
|
Last Modified: Feb 24, 2018
|
|
|
|
|
|
|
|
Description: This class handles all FFMPEG related
|
|
|
|
operations.
|
|
|
|
|
|
|
|
Version 1.0
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
class FFMPEG:
|
|
|
|
|
2018-02-24 21:13:27 +00:00
|
|
|
def __init__(self, ffmpeg_path, outfile):
|
|
|
|
self.ffmpeg_path = ffmpeg_path
|
|
|
|
self.outfile = outfile
|
2018-02-24 18:34:00 +00:00
|
|
|
|
|
|
|
def strip_frames(self, videoin, outpath):
|
2018-02-24 21:13:27 +00:00
|
|
|
os.system("{} -i {} {}/extracted_%0d.png -y".format(self.ffmpeg_path, videoin, outpath))
|
2018-02-24 18:34:00 +00:00
|
|
|
|
|
|
|
def extract_audio(self, videoin, outpath):
|
2018-02-24 21:13:27 +00:00
|
|
|
os.system("{} -i {} -vn -acodec copy {}/output-audio.aac -y".format(self.ffmpeg_path, videoin, outpath))
|
2018-02-24 18:34:00 +00:00
|
|
|
|
|
|
|
def to_vid(self, framerate, resolution, folder):
|
2018-02-24 21:13:27 +00:00
|
|
|
os.system("{} -r {} -f image2 -s {} -i {}/extracted_%d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p output.mp4 -y".format(self.ffmpeg_path, framerate, resolution, folder))
|
2018-02-24 18:34:00 +00:00
|
|
|
|
2018-02-24 21:13:27 +00:00
|
|
|
def pressin_audio(self, videoin, outpath):
|
|
|
|
os.system("{} -i {} -i {}/output-audio.aac -codec copy -shortest {} -y".format(self.ffmpeg_path, videoin, outpath, self.outfile))
|