Merge branch 'main' of git.gmoker.com:icing/poc
This commit is contained in:
commit
6fd20f12fa
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
|
||||
### Audio ###
|
||||
*.aif
|
||||
*.amr
|
||||
*.flac
|
||||
*.iff
|
||||
*.m3u
|
||||
|
15
compression/ctest/main.py
Normal file
15
compression/ctest/main.py
Normal file
@ -0,0 +1,15 @@
|
||||
import ctypes
|
||||
|
||||
|
||||
def avcodec_version():
|
||||
f = ctypes.CDLL("libavcodec.so")
|
||||
|
||||
print(f.avcodec_version())
|
||||
|
||||
|
||||
def main():
|
||||
avcodec_version()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,16 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
from ffmpy import FFmpeg
|
||||
|
||||
class FFmpeg:
|
||||
input: str
|
||||
output: str
|
||||
format: str
|
||||
bitrate: int | None
|
||||
fpass: tuple[int, int] | None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
input="pipe:0",
|
||||
output="pipe:1",
|
||||
format="amr",
|
||||
bitrate=None,
|
||||
fpass=None,
|
||||
):
|
||||
self.input = input
|
||||
self.output = output
|
||||
self.format = format
|
||||
self.bitrate = bitrate
|
||||
self.fpass = fpass
|
||||
|
||||
def __get_cmd(self) -> list[str]:
|
||||
cmd = [
|
||||
"ffmpeg",
|
||||
"-i",
|
||||
self.input,
|
||||
"-f",
|
||||
self.format,
|
||||
"-ac",
|
||||
"1",
|
||||
"-ar",
|
||||
"8000",
|
||||
]
|
||||
|
||||
if self.bitrate is not None:
|
||||
cmd += ["-b:a", str(self.bitrate)]
|
||||
if self.fpass:
|
||||
cmd += [
|
||||
"-filter:a",
|
||||
f"highpass=f={self.fpass[0]},lowpass=f={self.fpass[1]}",
|
||||
]
|
||||
return cmd + [self.output]
|
||||
|
||||
def run(self):
|
||||
cmd = self.__get_cmd()
|
||||
|
||||
subprocess.Popen(cmd)
|
||||
|
||||
|
||||
def main():
|
||||
ff = FFmpeg(
|
||||
inputs={"pipe:0": None},
|
||||
outputs={"pipe:1": "-ar 8000 -b:a 128k -f mp3"},
|
||||
)
|
||||
ff.run(input_data=sys.stdin.buffer.read())
|
||||
ff = FFmpeg(bitrate=12200, fpass=[200, 3400])
|
||||
ff.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1 +0,0 @@
|
||||
ffmpy~=0.3
|
Reference in New Issue
Block a user