added check for actual video size to not convert a video to a larger size
This commit is contained in:
parent
bda176b5c7
commit
97d897e427
34
convert.sh
34
convert.sh
|
@ -136,9 +136,6 @@ fi
|
||||||
# Remove end slash in video location
|
# Remove end slash in video location
|
||||||
video_location=${video_location%/}
|
video_location=${video_location%/}
|
||||||
|
|
||||||
# Make an array of all video formats we want to convert
|
|
||||||
IFS=':' read -r -a video_formats <<< "$video_formats_string"
|
|
||||||
|
|
||||||
# Loop through our convertfile
|
# Loop through our convertfile
|
||||||
video_formats_file=$(<$video_formats_location)
|
video_formats_file=$(<$video_formats_location)
|
||||||
|
|
||||||
|
@ -170,24 +167,37 @@ while true; do
|
||||||
|
|
||||||
# Create the output folder
|
# Create the output folder
|
||||||
mkdir $file.out
|
mkdir $file.out
|
||||||
|
|
||||||
|
# Get the video width and height
|
||||||
|
video_width=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .width')
|
||||||
|
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .height')
|
||||||
|
|
||||||
|
|
||||||
# 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() {
|
||||||
echo ${row} | base64 --decode | jq -r ${1}
|
echo ${row} | base64 --decode | jq -r ${1}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Converting to $(_jq '.name'), Resolution: $(_jq '.resolution'), Bitrate: $(_jq '.video_bitrate'), Framerate: $(_jq '.framerate')"
|
|
||||||
|
|
||||||
# Make Framerate optional, don't modify the framerate if it is not set
|
# Check if the video is larger or as large as the format we want to convert it to
|
||||||
framerate=""
|
IFS=':' read -r -a video_resolutions <<< "$(_jq '.resolution')"
|
||||||
if [ "$(_jq '.framerate')" != "null" ]
|
echo ${video_resolutions[1]}
|
||||||
|
echo $video_height
|
||||||
|
|
||||||
|
if [ "${video_resolutions[1]}" -le "$video_height" ]
|
||||||
then
|
then
|
||||||
framerate=" -r $(_jq '.framerate')"
|
echo "Converting to $(_jq '.name'), Resolution: $(_jq '.resolution'), Bitrate: $(_jq '.video_bitrate'), Framerate: $(_jq '.framerate')"
|
||||||
fi
|
|
||||||
|
|
||||||
# Convert
|
# Make Framerate optional, don't modify the framerate if it is not set
|
||||||
$video_ffmpeg_path -i $file -b:v $(_jq '.video_bitrate') $framerate -c:v $(_jq '.video_codec') -vf scale=$(_jq '.resolution') -c:a $(_jq '.audio_codec') -b:a $(_jq '.audio_bitrate') $file.out/$(basename "$file" "$file_format")_$(_jq '.name').$(_jq '.file_ending') &
|
framerate=""
|
||||||
|
if [ "$(_jq '.framerate')" != "null" ]
|
||||||
|
then
|
||||||
|
framerate=" -r $(_jq '.framerate')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Convert
|
||||||
|
$video_ffmpeg_path -i $file -b:v $(_jq '.video_bitrate') $framerate -c:v $(_jq '.video_codec') -vf scale=$(_jq '.resolution') -c:a $(_jq '.audio_codec') -b:a $(_jq '.audio_bitrate') $file.out/$(basename "$file" "$file_format")_$(_jq '.name').$(_jq '.file_ending') &
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Wait until all formats are created
|
# Wait until all formats are created
|
||||||
|
|
Loading…
Reference in New Issue