File size: 1,652 Bytes
36cb39e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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,
        )