-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
742af00
commit 75aa956
Showing
11 changed files
with
727 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from . import colourtime as colourtime | ||
from . import event_rate as event_rate | ||
from . import spatiospectrogram as spatiospectrogram | ||
from . import spectrogram as spectrogram | ||
from . import video as video | ||
from . import wiggle as wiggle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import atexit | ||
import importlib.resources | ||
import pathlib | ||
import subprocess | ||
import typing | ||
|
||
EXTENSION = ".mp4" | ||
|
||
|
||
def run( | ||
input: pathlib.Path, | ||
output: pathlib.Path, | ||
begin: int, | ||
end: int, | ||
parameters: dict[str, typing.Any], | ||
): | ||
width, height = ( | ||
int(value) | ||
for value in subprocess.run( | ||
[ | ||
str(importlib.resources.files("charidotella").joinpath("assets/size")), | ||
str(input), | ||
], | ||
check=True, | ||
capture_output=True, | ||
).stdout.split(b"x") | ||
) | ||
width *= parameters["scale"] | ||
height *= parameters["scale"] | ||
spatiospectrogram_arguments = [ | ||
str( | ||
importlib.resources.files("charidotella").joinpath( | ||
"assets/spatiospectrogram" | ||
) | ||
), | ||
f"--input={input}", | ||
f"--begin={begin}", | ||
f"--end={end}", | ||
f"--frametime={parameters['frametime']}", | ||
f"--scale={parameters['scale']}", | ||
f"--tau={parameters['tau']}", | ||
f"--mode={parameters['mode']}", | ||
f"--minimum={parameters['minimum']}", | ||
f"--maximum={parameters['maximum']}", | ||
f"--frequencies={parameters['frequencies']}", | ||
f"--frequency-gamma={parameters['frequency-gamma']}", | ||
f"--amplitude-gamma={parameters['amplitude-gamma']}", | ||
f"--discard={parameters['discard']}", | ||
] | ||
if parameters["timecode"]: | ||
spatiospectrogram_arguments.append("--add-timecode") | ||
spatiospectrogram = subprocess.Popen( | ||
spatiospectrogram_arguments, | ||
stdout=subprocess.PIPE, | ||
) | ||
assert spatiospectrogram.stdout is not None | ||
ffmpeg = subprocess.Popen( | ||
[ | ||
parameters["ffmpeg"], | ||
"-hide_banner", | ||
"-loglevel", | ||
"warning", | ||
"-stats", | ||
"-f", | ||
"rawvideo", | ||
"-s", | ||
f"{width}x{height}", | ||
"-framerate", | ||
"50", | ||
"-pix_fmt", | ||
"rgb24", | ||
"-i", | ||
"-", | ||
"-c:v", | ||
"libx264", | ||
"-pix_fmt", | ||
"yuv420p", | ||
"-crf", | ||
str(parameters["h264_crf"]), | ||
"-f", | ||
"mp4", | ||
"-y", | ||
str(output), | ||
], | ||
stdin=subprocess.PIPE, | ||
) | ||
assert ffmpeg.stdin is not None | ||
frame_size = width * height * 3 | ||
|
||
def cleanup(): | ||
if es_to_frames is not None: | ||
es_to_frames.kill() | ||
if ffmpeg is not None: | ||
ffmpeg.kill() | ||
|
||
atexit.register(cleanup) | ||
while True: | ||
frame = spatiospectrogram.stdout.read(frame_size) | ||
if len(frame) != frame_size: | ||
break | ||
ffmpeg.stdin.write(frame) | ||
ffmpeg.stdin.close() | ||
spatiospectrogram.wait() | ||
es_to_frames = None | ||
ffmpeg.wait() | ||
ffmpeg = None | ||
atexit.unregister(cleanup) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import importlib.resources | ||
import pathlib | ||
import subprocess | ||
import typing | ||
|
||
EXTENSION = ".png" | ||
|
||
|
||
def run( | ||
input: pathlib.Path, | ||
output: pathlib.Path, | ||
begin: int, | ||
end: int, | ||
parameters: dict[str, typing.Any], | ||
): | ||
arguments = [ | ||
str(importlib.resources.files("charidotella").joinpath("assets/spectrogram")), | ||
str(input), | ||
str(output), | ||
str(output.with_suffix(".json")), | ||
f"--begin={begin}", | ||
f"--end={end}", | ||
f"--tau={parameters['tau']}", | ||
f"--mode={parameters['mode']}", | ||
f"--maximum={parameters['maximum']}", | ||
f"--frequencies={parameters['frequencies']}", | ||
f"--times={parameters['times']}", | ||
f"--gamma={parameters['gamma']}", | ||
] | ||
if "minimum" in parameters: | ||
arguments.append(f"--minimum={parameters['minimum']}") | ||
if "region-of-interest" in parameters: | ||
arguments.append(f"--left={parameters['region-of-interest'][0]}") | ||
arguments.append(f"--bottom={parameters['region-of-interest'][1]}") | ||
arguments.append(f"--width={parameters['region-of-interest'][2]}") | ||
arguments.append(f"--height={parameters['region-of-interest'][3]}") | ||
subprocess.run( | ||
arguments, | ||
check=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.10" | ||
__version__ = "1.0" |
Submodule command_line_tools
updated
8 files
+74 −1 | README.md | |
+44 −0 | premake4.lua | |
+1 −1 | source/es_to_frames.cpp | |
+84 −22 | source/event_rate.cpp | |
+0 −1 | source/rainbow.cpp | |
+2 −4 | source/rainmaker.cpp | |
+583 −0 | source/spatiospectrogram.cpp | |
+544 −0 | source/spectrogram.cpp |
Oops, something went wrong.