mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-03-03 21:12:13 +00:00
v2.0 lots of bug fixes and enhancements
This commit is contained in:
parent
c5fdbfa470
commit
c2ee564e3b
37
ffmpeg.py
37
ffmpeg.py
@ -4,15 +4,14 @@
|
|||||||
Name: FFMPEG Class
|
Name: FFMPEG Class
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: Feb 24, 2018
|
Date Created: Feb 24, 2018
|
||||||
Last Modified: Feb 24, 2018
|
Last Modified: May 19, 2018
|
||||||
|
|
||||||
Description: This class handles all FFMPEG related
|
Description: This class handles all FFMPEG related
|
||||||
operations.
|
operations.
|
||||||
|
|
||||||
Version 1.1
|
Version 2.0
|
||||||
"""
|
"""
|
||||||
|
import subprocess
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class FFMPEG:
|
class FFMPEG:
|
||||||
@ -37,8 +36,9 @@ class FFMPEG:
|
|||||||
videoin {string} -- input video path
|
videoin {string} -- input video path
|
||||||
outpath {string} -- video output folder
|
outpath {string} -- video output folder
|
||||||
"""
|
"""
|
||||||
os.system(
|
execute = "{} -i {} {}\\extracted_%0d.png -y".format(self.ffmpeg_path, videoin, outpath)
|
||||||
"{} -i {} {}/extracted_%0d.png -y".format(self.ffmpeg_path, videoin, outpath))
|
print(execute)
|
||||||
|
subprocess.call(execute)
|
||||||
|
|
||||||
def extract_audio(self, videoin, outpath):
|
def extract_audio(self, videoin, outpath):
|
||||||
"""Strips audio tracks from videos
|
"""Strips audio tracks from videos
|
||||||
@ -50,10 +50,11 @@ class FFMPEG:
|
|||||||
videoin {string} -- input video path
|
videoin {string} -- input video path
|
||||||
outpath {string} -- video output folder
|
outpath {string} -- video output folder
|
||||||
"""
|
"""
|
||||||
os.system(
|
execute = "{} -i {} -vn -acodec copy {}\\output-audio.aac -y".format(self.ffmpeg_path, videoin, outpath)
|
||||||
"{} -i {} -vn -acodec copy {}/output-audio.aac -y".format(self.ffmpeg_path, videoin, outpath))
|
print(execute)
|
||||||
|
subprocess.call(execute)
|
||||||
|
|
||||||
def to_vid(self, framerate, resolution, folder):
|
def to_vid(self, framerate, resolution, upscaled, ):
|
||||||
"""Converts images into videos
|
"""Converts images into videos
|
||||||
|
|
||||||
This method converts a set of images into a
|
This method converts a set of images into a
|
||||||
@ -62,20 +63,22 @@ class FFMPEG:
|
|||||||
Arguments:
|
Arguments:
|
||||||
framerate {float} -- target video framerate
|
framerate {float} -- target video framerate
|
||||||
resolution {string} -- target video resolution
|
resolution {string} -- target video resolution
|
||||||
folder {string} -- source images folder
|
upscaled {string} -- source images folder
|
||||||
"""
|
"""
|
||||||
os.system("{} -r {} -f image2 -s {} -i {}/extracted_%d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p output.mp4 -y".format(
|
execute = "{} -r {} -f image2 -s {} -i {}\\extracted_%d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p {}\\no_audio.mp4 -y".format(
|
||||||
self.ffmpeg_path, framerate, resolution, folder))
|
self.ffmpeg_path, framerate, resolution, upscaled, upscaled)
|
||||||
|
print(execute)
|
||||||
|
subprocess.call(execute)
|
||||||
|
|
||||||
def insert_audio_track(self, videoin, outpath):
|
def insert_audio_track(self, upscaled):
|
||||||
"""Insert audio into video
|
"""Insert audio into video
|
||||||
|
|
||||||
Inserts the AAC audio track stripped from
|
Inserts the AAC audio track stripped from
|
||||||
the original video into final video.
|
the original video into final video.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
videoin {string} -- input video path
|
upscaled {string} -- upscaled image folder
|
||||||
outpath {string} -- video output folder
|
|
||||||
"""
|
"""
|
||||||
os.system("{} -i {} -i {}/output-audio.aac -codec copy -shortest {} -y".format(
|
execute = "{} -i {}\\no_audio.mp4 -i {}\\output-audio.aac -c copy {} -y".format(self.ffmpeg_path, upscaled, upscaled, self.outfile)
|
||||||
self.ffmpeg_path, videoin, outpath, self.outfile))
|
print(execute)
|
||||||
|
subprocess.call(execute)
|
||||||
|
Loading…
Reference in New Issue
Block a user