Skip to content

Instantly share code, notes, and snippets.

@jarun jarun/
Last active Feb 15, 2020

What would you like to do?
Get the size to duration ratio of a media
#!/usr/bin/env sh
# Description: POSIZ compliant script to get the size to duration of a media file
# Requires: mediainfo, bc, ls
# For sorted output: | sort -rg
for file in *; do
# get duration in milliseconds->mins
ms=$(mediainfo --Inform="Video;%Duration%" "$file")
min=$(echo "scale=2;${ms}/60000" | bc)
# get the file size
size=$(ls -l "$file" | cut -d" " -f5)
mb=$(echo "scale=2;${size}/1048576" | bc)
# get mb/min ration
ratio=$(echo "scale=2;${mb}/${min}" | bc)
# echo $ratio "$file"
echo $ratio $(ls -sh "$file")

This comment has been minimized.

Copy link
Owner Author

jarun commented Feb 15, 2020

ratio | sort -nr > ratio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.