yerang's picture
Upload 1110 files
e3af00f verified
import subprocess
from stf_tools.writers.ffmpeg import ThreadFFMPEGWriter
class WebmWriter(ThreadFFMPEGWriter):
def _run_ffmpeg(self, quiet):
return subprocess.Popen(
[
"ffmpeg",
"-f",
"rawvideo",
"-pix_fmt",
"rgba",
"-r",
f"{self.fps}",
"-s",
f"{self.width}x{self.height}",
"-thread_queue_size",
"1024",
"-probesize",
f"{self.width*self.height}",
"-i",
self.video_pipe_path,
"-f",
"s16le",
"-ac",
"1",
"-acodec",
"pcm_s16le",
"-ar",
"16k",
"-thread_queue_size",
"4096",
"-probesize",
"32",
"-i",
self.audio_pipe_path,
"-map",
"0:v:0",
"-map",
"1:a:0",
"-pix_fmt",
"yuva420p",
"-crf",
f"{self.crf}",
"-r",
f"{self.fps}",
"-s",
f"{self.width//2*2}x{self.height//2*2}",
"-threads",
"16",
"-vcodec",
"libvpx-vp9",
str(self.path),
"-y",
],
stdout=subprocess.DEVNULL if quiet else None,
stderr=subprocess.STDOUT if quiet else None,
)