Made DOckerfile workd
This commit is contained in:
parent
6d667466e0
commit
bdceac06c1
|
@ -1,7 +1,7 @@
|
||||||
FROM docker
|
FROM docker
|
||||||
|
|
||||||
# Add bash, needed for our conversion script
|
# Add bash, needed for our conversion script
|
||||||
RUN apk add --update bash util-linux && rm -rf /var/cache/apk/*
|
RUN apk add --update bash util-linux jq bc && rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
# Create folders
|
# Create folders
|
||||||
RUN mkdir /var/videos && \
|
RUN mkdir /var/videos && \
|
||||||
|
@ -19,5 +19,6 @@ chmod +x /var/videoconversion/jq
|
||||||
VOLUME /var/videos
|
VOLUME /var/videos
|
||||||
VOLUME /var/videoconversion/config
|
VOLUME /var/videoconversion/config
|
||||||
|
|
||||||
#ENTRYPOINT while true; do sleep 1d; done
|
ENV VIDEO_FOLDER=/var/videos
|
||||||
ENTRYPOINT ./var/videoconversion/convert.sh -c /var/videoconversion/config/video_formats.json -p /var/videos -f "docker run -v /var/videos:/var/videos jrottenberg/ffmpeg:alpine-3.3"
|
|
||||||
|
CMD bash ./var/videoconversion/convert.sh -c /var/videoconversion/config/video_formats.json -p /var/videos -f "docker run -v $VIDEO_FOLDER:/var/videos jrottenberg/ffmpeg:3.4-alpine" -i "docker run -v $VIDEO_FOLDER:/var/videos sjourdan/ffprobe"
|
||||||
|
|
18
convert.sh
18
convert.sh
|
@ -189,13 +189,13 @@ while true; do
|
||||||
|
|
||||||
# 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=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | ./jq --raw-output '.streams [0] .codec_type')
|
codec_type=$($video_ffprobe_path -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=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | ./jq '.streams [0] .height')
|
video_height=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .height')
|
||||||
video_width=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | ./jq '.streams [0] .width')
|
video_width=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | jq '.streams [0] .width')
|
||||||
else
|
else
|
||||||
video_height=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | ./jq '.streams [1] .height')
|
video_height=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | jq '.streams [1] .height')
|
||||||
video_width=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | ./jq '.streams [1] .width')
|
video_width=$($video_ffprobe_path -v quiet -show_streams -print_format json "$file" | jq '.streams [1] .width')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate aspect ratio
|
# Calculate aspect ratio
|
||||||
|
@ -214,13 +214,15 @@ while true; do
|
||||||
mkdir $file.out
|
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() {
|
||||||
echo ${row} | base64 --decode | ./jq -r ${1}
|
echo ${row} | base64 -d | jq -r ${1}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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
|
||||||
if [ "$(_jq '.height')" -le "$video_height" ]
|
format_new_height=$(_jq '.height')
|
||||||
|
|
||||||
|
if [ "$format_new_height" -le "$video_height" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
# Calculate the new width based on aspect ratio
|
# Calculate the new width based on aspect ratio
|
||||||
|
|
Loading…
Reference in New Issue