mirror of
https://github.com/k4yt3x/video2x.git
synced 2026-02-13 00:24:46 +08:00
basic functions online
This commit is contained in:
15
ffmpeg.py
15
ffmpeg.py
@@ -17,17 +17,18 @@ import os
|
||||
|
||||
class FFMPEG:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self, ffmpeg_path, outfile):
|
||||
self.ffmpeg_path = ffmpeg_path
|
||||
self.outfile = outfile
|
||||
|
||||
def strip_frames(self, videoin, outpath):
|
||||
os.system("ffmpeg -i {} -r 1/1 {}/extracted_%0d.png".format(videoin, outpath))
|
||||
os.system("{} -i {} {}/extracted_%0d.png -y".format(self.ffmpeg_path, videoin, outpath))
|
||||
|
||||
def extract_audio(self, videoin, outpath):
|
||||
os.system("ffmpeg -i {} -vn -acodec copy {}/output-audio.aac".format(videoin, outpath))
|
||||
os.system("{} -i {} -vn -acodec copy {}/output-audio.aac -y".format(self.ffmpeg_path, videoin, outpath))
|
||||
|
||||
def to_vid(self, framerate, resolution, folder):
|
||||
os.system("ffmpeg -r {} -f image2 -s {} -i {}/extracted_%d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p output.mp4".format(framerate, resolution, folder))
|
||||
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))
|
||||
|
||||
def pressin_audio(self, videoin):
|
||||
os.system("ffmpeg -i {} -i audio.mp3 -codec copy -shortest output.mp4")
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user