Last active
February 15, 2020 06:28
-
-
Save jarun/e822b13774cd64e177dc333a74be6765 to your computer and use it in GitHub Desktop.
Get the size to duration ratio of a media
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
#!/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: ratio.sh | 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") | |
done |
Author
jarun
commented
Feb 15, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment