Compare commits

...

6 Commits

7 changed files with 87 additions and 5 deletions

5
.gitignore vendored
View File

@ -138,3 +138,8 @@ dmypy.json
# Cython debug symbols
cython_debug/
av1output/
*.mp4
*.mkv
*.png

12
check_metadata/setup.py Normal file
View File

@ -0,0 +1,12 @@
from setuptools import setup
setup(
name="checkMetadata",
version="0.0.1",
packages=["checkMetadata"],
entry_points={
"console_scripts": [
"checkMetadata = checkMetadata.__main__:main"
]
},
)

View File

@ -3,10 +3,11 @@
""" Author: Hendrik Schutter, localhorst@mosad.xyz
Date of creation: 2022/01/22
Date of last modification: 2022/01/25
Date of last modification: 2022/08/25
"""
import os
import platform
import sys
import time
import subprocess
@ -55,6 +56,12 @@ def extract_frame(video_file, time_offset, output_file):
subprocess.call(shlex.split(cmd),stdout=devnull, stderr=devnull)
def get_font_path():
if platform.system() == "Darwin":
# Assume DejaVu to be installed in the user library
path = "~/Library/Fonts/DejaVuSans-Bold.ttf"
return os.path.expanduser(path)
# Default platform: Linux
path = "/usr/share/fonts"
files = glob.glob(path + "/**/DejaVuSans-Bold.ttf", recursive = True)
return files[0]
@ -63,7 +70,7 @@ def zoom_at(img, crop_factor):
image_width, image_height = img.size
img = img.crop((int(image_width/2) - int(image_width/crop_factor) / (crop_factor * 2), int(image_height/2) - int(image_height/crop_factor) / (crop_factor * 2),
int(image_width/2) + int(image_width/crop_factor) / (crop_factor * 2), int(image_height/2) + int(image_height/crop_factor) / (crop_factor * 2)))
return img.resize((int(image_width/crop_factor*2), int(image_height/crop_factor*2)), Image.LANCZOS)
return img.resize((int(image_width/crop_factor*2), int(image_height/crop_factor*2)), Image.Resampling.LANCZOS)
def create_collage(images_A, images_B, statistics, output_file):
image_width, image_height = images_A[0].size
@ -112,7 +119,7 @@ def create_collage(images_A, images_B, statistics, output_file):
cropped_image = zoom_at(images_A[i], crop_factor)
cropped_image_with, _ = cropped_image.size
output_image.paste(cropped_image, (int(x_offset/2) + image_width - cropped_image_with , y))
cropped_image = zoom_at(images_B[i].transpose(PIL.Image.FLIP_LEFT_RIGHT), crop_factor)
cropped_image = zoom_at(images_B[i].transpose(PIL.Image.Transpose.FLIP_LEFT_RIGHT), crop_factor)
output_image.paste(cropped_image, (int(x_offset/2) + image_width, y))
i += 1
y += image_height
@ -134,7 +141,7 @@ def human_readable_size(size, decimal_places=2):
size /= 1024.0
return f"{size:.{decimal_places}f} {unit}"
def main() -> None:
def main():
if(len(sys.argv) != 3):
print("Bad usage!")
print("Usage: python ./codec_analyzer.py file file")
@ -182,4 +189,4 @@ def main() -> None:
delete_temp_dir()
if __name__ == "__main__":
main()
main()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

15
codec_visualizer/setup.py Normal file
View File

@ -0,0 +1,15 @@
from setuptools import setup
setup(
name="codecVis",
version="0.0.1",
packages=["codecVis"],
entry_points={
"console_scripts": [
"codecVis = codecVis.__main__:main"
]
},
install_requires=[
'Pillow>=9.2.0'
]
)

43
convert/convert_movies.sh Executable file
View File

@ -0,0 +1,43 @@
#! /bin/sh
####################################### HOW TO USE ################################################
# manually set MOVIES_DIR
# manually create and set OUTPUT_DIR
# manually set movies names in array
#####################################################################################################
MOVIES_DIR=/home/hendrik/git/media_management_scripts/codec_visualizer/
OUTPUT_DIR=/home/hendrik/git/media_management_scripts/av1output/
movies=("test.mp4")
echo "starting script ..."
echo " "
for movie in ${movies[@]}; do
echo "loop for $movie"
NEW_MOVIE_NAME=$"$(b=${movie##*/}; echo ${b%.*}).mkv"
TMP_MOVIE_NAME=$"tmp_$(b=${movie##*/}; echo ${b%.*}).mkv"
SCREENSHOT_MOVIE_NAME=$"tmp_$(b=${movie##*/}; echo ${b%.*}).png"
echo "NEW_MOVIE_NAME: $NEW_MOVIE_NAME"
echo "TMP_MOVIE_NAME: $TMP_MOVIE_NAME"
if [ -f "$OUTPUT_DIR$TMP_MOVIE_NAME" ]; then
echo "warning: tmp file exists --> delete $TMP_MOVIE_NAME"
rm "$OUTPUT_DIR$TMP_MOVIE_NAME"
fi
if [ -f "$OUTPUT_DIR$NEW_MOVIE_NAME" ]; then
echo "$NEW_MOVIE_NAME exists."
else
#ffmpeg -i $MOVIES_DIR$movie -c:v libaom-av1 -c:a libopus -mapping_family 1 -af aformat=channel_layouts=5.1 -c:s copy -map 0 -crf 24 -b:v 0 -b:a 128k -cpu-used 4 -row-mt 1 -tiles 2x2 $OUTPUT_DIR$TMP_MOVIE_NAME
ffmpeg -i $MOVIES_DIR$movie -vcodec libx264 -acodec aac $OUTPUT_DIR$TMP_MOVIE_NAME
mv $OUTPUT_DIR$TMP_MOVIE_NAME $OUTPUT_DIR$NEW_MOVIE_NAME
echo "$NEW_MOVIE_NAME converted."
codecVis $MOVIES_DIR$movie $OUTPUT_DIR$NEW_MOVIE_NAME
mv output.png $OUTPUT_DIR$SCREENSHOT_MOVIE_NAME
fi
done