duration-length script

This commit is contained in:
Jason TIAN 2022-04-02 22:43:43 +08:00 committed by Jason Tian
parent 3f91595272
commit 7a6a48a5bd
1 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
file="./scripts/duration-length.txt"
if [ -f "$file" ]
then
for i in $(cat $file); do
mp3=$(cat "$i" | grep "^mp3 =" | awk -F'"' '{print $2}')
duration=$(ffprobe -i "$mp3" -show_entries format=duration -v quiet -of csv="p=0" -sexagesimal)
length=$(ffprobe -i "$mp3" -show_entries format=size -v quiet -of csv="p=0")
sed -i "s/^duration = .*/duration = \"$duration\"/g" "$i"
sed -i "s/^length = .*/length = $length/g" "$i"
cat "$i"
done
fi