added check if the file is a video
This commit is contained in:
parent
b68e79179c
commit
b7b51e7b67
28
convert.sh
28
convert.sh
|
@ -162,25 +162,27 @@ while true; do
|
|||
echo "================"
|
||||
echo "Found file: $file"
|
||||
|
||||
# Create Lock file
|
||||
touch $file.lock
|
||||
|
||||
# Check if the file is a video file
|
||||
# TODO
|
||||
|
||||
# Create the output folder
|
||||
mkdir $file.out
|
||||
|
||||
# Get the video width and height
|
||||
# Hack to get the height even if the audio and video stream are in reverse order
|
||||
codec_type=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq --raw-output '.streams [0] .codec_type')
|
||||
if [ "$codec_type" = "video" ]
|
||||
then
|
||||
if [ "$codec_type" = "video" ]; then
|
||||
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .height')
|
||||
else
|
||||
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [1] .height')
|
||||
fi
|
||||
|
||||
# Check if the file is a video file
|
||||
if [ "$codec_type" = "null" ]; then
|
||||
echo "$file is not a video file"
|
||||
|
||||
else
|
||||
|
||||
# Create Lock file
|
||||
touch $file.lock
|
||||
|
||||
# Create the output folder
|
||||
mkdir $file.out
|
||||
|
||||
# Loop through all videoformats and convert them
|
||||
for row in $(echo "${video_formats_file}" | jq -r '.[] | @base64'); do
|
||||
_jq() {
|
||||
|
@ -190,7 +192,7 @@ while true; do
|
|||
# Check if the video is larger or as large as the format we want to convert it to
|
||||
IFS=':' read -r -a video_resolutions <<< "$(_jq '.resolution')"
|
||||
|
||||
# TODO don't ignore aspect ratio, maybe even only input a height in conversion json file, calculate the with based on aspect ration obtained from ffprobe
|
||||
# TODO don't ignore aspect ratio, maybe even only input a height in conversion json file, calculate the with based on aspect ration obtained from ffprobe. Setting to however force the aspect ratio
|
||||
|
||||
if [ "${video_resolutions[1]}" -le "$video_height" ]
|
||||
then
|
||||
|
@ -218,6 +220,8 @@ while true; do
|
|||
|
||||
echo "Finished Converting $file"
|
||||
|
||||
fi
|
||||
|
||||
echo "================"
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue