Compare commits
6 Commits
basic_filt
...
master
Author | SHA1 | Date |
---|---|---|
Hendrik Schutter | b8de81a302 | |
Hendrik Schutter | 251859e989 | |
Hendrik Schutter | 381ce3027d | |
Hendrik Schutter | d8cf752428 | |
Hendrik Schutter | b71ae899ef | |
Hendrik Schutter | b2f84a46eb |
|
@ -138,3 +138,8 @@ dmypy.json
|
|||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
av1output/
|
||||
|
||||
*.mp4
|
||||
*.mkv
|
||||
*.png
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
},
|
||||
)
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
""" 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
|
||||
|
@ -63,7 +63,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 +112,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 +134,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 +182,4 @@ def main() -> None:
|
|||
delete_temp_dir()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
Binary file not shown.
Before Width: | Height: | Size: 3.2 MiB |
|
@ -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'
|
||||
]
|
||||
)
|
|
@ -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
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Author: Hendrik Schutter, localhorst@mosad.xyz
|
||||
Date of creation: 2023/02/22
|
||||
Date of last modification: 2023/02/22
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import datetime
|
||||
from dataclasses import dataclass
|
||||
from tqdm import tqdm
|
||||
import operator
|
||||
|
||||
@dataclass
|
||||
class MediaFile:
|
||||
name: str #without extension
|
||||
extension: str #without dot
|
||||
full_path: str
|
||||
|
||||
def supported_file_extension(filename):
|
||||
if filename.endswith('.mp4') or filename.endswith('.mkv') or filename.endswith('.m4v'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_number_of_files(path):
|
||||
#filter(supported_file_extension, files)
|
||||
return sum([len(list(filter(supported_file_extension, files))) for r, d, files in os.walk(path)])
|
||||
|
||||
def cut_file_name(filename, max_lenght, ellipsis="..."):
|
||||
if len(filename) > max_lenght:
|
||||
return filename[:max_lenght-len(ellipsis)] + ellipsis
|
||||
else:
|
||||
return filename
|
||||
|
||||
def scan_files(path):
|
||||
total_numbers_to_scan = get_number_of_files(path)
|
||||
|
||||
media_files = list() #stores all found files with metadata
|
||||
|
||||
pbar = tqdm(total=total_numbers_to_scan) #print progress bar
|
||||
|
||||
for root, dirs, files in os.walk(path, topdown=True):
|
||||
for name in filter(supported_file_extension, files):
|
||||
pbar.set_description("Processing %s" % str("{:<32}".format(cut_file_name(name, 32))))
|
||||
full_path = os.path.join(root, name)
|
||||
media_files.append(MediaFile(name=os.path.splitext(name)[0], extension=os.path.splitext(name)[1], full_path=full_path))
|
||||
pbar.update(1)
|
||||
pbar.close()
|
||||
return media_files
|
||||
|
||||
def print_all(media_files, path):
|
||||
for media_file in media_files:
|
||||
if (media_file.extension == ".mp4"):
|
||||
#print(media_file.name)
|
||||
file_test_path = path + media_file.name + ".mkv"
|
||||
#print("Testing for: " + file_test_path)
|
||||
if (os.path.isfile(file_test_path)):
|
||||
print(media_file.full_path)
|
||||
#os.remove(media_file.full_path)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if(len(sys.argv) != 2):
|
||||
path = '.' #use current pwd
|
||||
else:
|
||||
path = sys.argv[1] #use arg0 as path
|
||||
|
||||
media_files = scan_files(path) #scan all media files
|
||||
|
||||
print("")
|
||||
print_all(media_files, path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue