-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
4 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python3 | ||
import ffmpeg | ||
import pathlib | ||
|
||
import common | ||
|
||
|
||
def convert_mp4_previews(pack_set: pathlib.Path) -> None: | ||
previews = pack_set / "preview" | ||
|
||
for preview in previews.glob("*.mp4"): | ||
probe = ffmpeg.probe(preview) | ||
|
||
for stream in probe["streams"]: | ||
if stream["codec_type"] == "video": | ||
break | ||
else: # Did not break, so no video stream | ||
print(f"Preview has no video: {preview.relative_to(common.packs_root)}") | ||
continue | ||
|
||
convert = ffmpeg.input(str(preview)) | ||
|
||
# Personal ease of use: when captured from qFlipper with BlueRecorder, | ||
# this crops to fit the preview window perfectly | ||
if stream["width"] == 862 and stream["height"] == 532: | ||
convert = convert.crop(width=512, height=256, x=66, y=82) | ||
|
||
convert = convert.output(str(preview.with_suffix(".gif"))) | ||
convert.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
for pack_set in common.cli_pack_sets(): | ||
convert_mp4_previews(pack_set) |
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
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
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,3 +1,4 @@ | ||
black==24.3.0 | ||
heatshrink2==0.13.0 | ||
pillow==10.3.0 | ||
ffmpeg-python==0.2.0 |