mirror of
https://github.com/kolaente/Docker-Video-Decoding.git
synced 2024-06-02 19:59:40 +00:00
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 "================"
|
||||||
echo "Found file: $file"
|
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
|
# Get the video width and height
|
||||||
# Hack to get the height even if the audio and video stream are in reverse order
|
# 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')
|
codec_type=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq --raw-output '.streams [0] .codec_type')
|
||||||
if [ "$codec_type" = "video" ]
|
if [ "$codec_type" = "video" ]; then
|
||||||
then
|
|
||||||
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .height')
|
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .height')
|
||||||
else
|
else
|
||||||
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [1] .height')
|
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [1] .height')
|
||||||
fi
|
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
|
# Loop through all videoformats and convert them
|
||||||
for row in $(echo "${video_formats_file}" | jq -r '.[] | @base64'); do
|
for row in $(echo "${video_formats_file}" | jq -r '.[] | @base64'); do
|
||||||
_jq() {
|
_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
|
# 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')"
|
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" ]
|
if [ "${video_resolutions[1]}" -le "$video_height" ]
|
||||||
then
|
then
|
||||||
|
@ -218,6 +220,8 @@ while true; do
|
||||||
|
|
||||||
echo "Finished Converting $file"
|
echo "Finished Converting $file"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
echo "================"
|
echo "================"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user