\ added check for height when audio and video streams are in reversed order
This commit is contained in:
parent
97d897e427
commit
884658769d
26
convert.sh
26
convert.sh
|
@ -139,14 +139,14 @@ video_location=${video_location%/}
|
||||||
# Loop through our convertfile
|
# Loop through our convertfile
|
||||||
video_formats_file=$(<$video_formats_location)
|
video_formats_file=$(<$video_formats_location)
|
||||||
|
|
||||||
# Remove Spaces in filename (because bash doesn't like them and would throw an error)
|
|
||||||
rename 's/ /_/g' *
|
|
||||||
|
|
||||||
########
|
########
|
||||||
# Run every 5 seconds
|
# Run every 5 seconds
|
||||||
########
|
########
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
# Remove Spaces in filename (because bash doesn't like them and would throw an error)
|
||||||
|
rename 's/ /_/g' *
|
||||||
|
|
||||||
# loop through all files
|
# loop through all files
|
||||||
for file in $video_location/*; do
|
for file in $video_location/*; do
|
||||||
# Check if the current file is a video
|
# Check if the current file is a video
|
||||||
|
@ -165,14 +165,22 @@ while true; do
|
||||||
# Create Lock file
|
# Create Lock file
|
||||||
touch $file.lock
|
touch $file.lock
|
||||||
|
|
||||||
|
# Check if the file is a video file
|
||||||
|
# TODO
|
||||||
|
|
||||||
# Create the output folder
|
# Create the output folder
|
||||||
mkdir $file.out
|
mkdir $file.out
|
||||||
|
|
||||||
# Get the video width and height
|
# Get the video width and height
|
||||||
video_width=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .width')
|
# Hack to get the height even if the audio and video stream are in reverse order
|
||||||
video_height=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .height')
|
codec_type=$(ffprobe -v quiet -show_streams -print_format json "$file" | jq --raw-output '.streams [0] .codec_type')
|
||||||
|
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
|
||||||
|
|
||||||
# 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() {
|
||||||
|
@ -181,8 +189,8 @@ 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')"
|
||||||
echo ${video_resolutions[1]}
|
|
||||||
echo $video_height
|
# 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
|
||||||
|
|
||||||
if [ "${video_resolutions[1]}" -le "$video_height" ]
|
if [ "${video_resolutions[1]}" -le "$video_height" ]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in New Issue