Fix fps_mode parameter with old ffmpeg releases

This commit is contained in:
q3aql 2023-02-11 14:33:51 +01:00
parent 400318bdb4
commit 8f47ebabed
6 changed files with 123 additions and 33 deletions

View File

@ -2,12 +2,27 @@
############################################################### ###############################################################
# ks-avi (ks-tools) - Convert video to AVI format # # ks-avi (ks-tools) - Convert video to AVI format #
# Date: 04-02-2022 # # Date: 10-02-2023 #
# Author: q3aql # # Author: q3aql #
# Contact: q3aql@duck.com # # Contact: q3aql@duck.com #
############################################################### ###############################################################
VERSION="8.4-dev" VERSION="8.4-dev"
M_DATE="040222" M_DATE="100223"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=""
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters # Global parameters
dirTemp="/tmp" dirTemp="/tmp"
@ -198,8 +213,8 @@ fi
p_ffmpeg="ffmpeg -i" p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999" p_ffmpeg_patched="-max_muxing_queue_size 9999"
# f_conversion="-vsync 1 -async 1" # Deprecated method # f_conversion="-vsync 1 -async 1" # Deprecated method
#f_conversion="-fps_mode cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0" #f_conversion="-${video_sync} cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0"
f_conversion="-fps_mode cfr -af aresample=async=1" f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC) # Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265") codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc") codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")

View File

@ -2,12 +2,27 @@
############################################################### ###############################################################
# ks-crop (ks-tools) - Crop or change aspect ratio of a video # # ks-crop (ks-tools) - Crop or change aspect ratio of a video #
# Date: 08-02-2023 # # Date: 10-02-2023 #
# Author: q3aql # # Author: q3aql #
# Contact: q3aql@duck.com # # Contact: q3aql@duck.com #
############################################################### ###############################################################
VERSION="8.4-dev" VERSION="8.4-dev"
M_DATE="080223" M_DATE="100223"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=""
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters # Global parameters
dirTemp="/tmp" dirTemp="/tmp"
@ -137,8 +152,8 @@ function errorReadingFile() {
p_ffmpeg="ffmpeg -i" p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999" p_ffmpeg_patched="-max_muxing_queue_size 9999"
# f_conversion="-vsync 1 -async 1" # Deprecated method # f_conversion="-vsync 1 -async 1" # Deprecated method
f_conversion="-fps_mode cfr" f_conversion="-${video_sync} cfr"
f_conversion_crop="-fps_mode cfr -async 1" f_conversion_crop="-${video_sync} cfr -async 1"
# Check if video input uses H265 (HEVC) # Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265") codec_h265=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc") codec_hevc=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")

View File

@ -2,12 +2,27 @@
##################################################################### #####################################################################
# ks-mix (ks-tools) - Extract video/audio and mix video/audio files # # ks-mix (ks-tools) - Extract video/audio and mix video/audio files #
# Date: 08-02-2023 # # Date: 10-02-2023 #
# Author: q3aql # # Author: q3aql #
# Contact: q3aql@duck.com # # Contact: q3aql@duck.com #
##################################################################### #####################################################################
VERSION="8.4-dev" VERSION="8.4-dev"
M_DATE="080223" M_DATE="100223"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=""
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# File(s) detection # File(s) detection
current_dir="$(pwd)" current_dir="$(pwd)"
@ -135,7 +150,7 @@ elif [ "${1}" == "-evid" ] ; then
echo -n "* Starting extract video track (${2}) " echo -n "* Starting extract video track (${2}) "
sleep 3 sleep 3
ffmpeg -y -i "${2}" -map ${video_track} -c:v copy "${current_dir}/seeing.mp4" ffmpeg -y -i "${2}" -map ${video_track} -c:v copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir}" echo -n "* Extracted video into ${video_file_dir}"
sleep 2 sleep 2
@ -208,7 +223,7 @@ elif [ "${1}" == "-ev25" ] ; then
if [ "${codec_encoded}" == "h264_encoded" ] ; then if [ "${codec_encoded}" == "h264_encoded" ] ; then
ffmpeg -y -i "${2}" -map ${video_track} -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${2}" -map ${video_track} -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -221,7 +236,7 @@ elif [ "${1}" == "-ev25" ] ; then
ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
rm -rf "${current_dir}/temp-h265.mkv" rm -rf "${current_dir}/temp-h265.mkv"
ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -235,7 +250,7 @@ elif [ "${1}" == "-ev25" ] ; then
ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
rm -rf "${current_dir}/temp-h265.mkv" rm -rf "${current_dir}/temp-h265.mkv"
ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -248,7 +263,7 @@ elif [ "${1}" == "-ev25" ] ; then
ffmpeg -y -i "${current_dir}/temp-mpeg4.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${current_dir}/temp-mpeg4.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
rm -rf "${current_dir}/temp-mpeg4.mkv" rm -rf "${current_dir}/temp-mpeg4.mkv"
ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -330,7 +345,7 @@ elif [ "${1}" == "-evpf" ] ; then
if [ "${codec_encoded}" == "h264_encoded" ] ; then if [ "${codec_encoded}" == "h264_encoded" ] ; then
ffmpeg -y -i "${2}" -map ${video_track} -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${2}" -map ${video_track} -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
ffmpeg -y -r ${frames_default} -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r ${frames_default} -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -343,7 +358,7 @@ elif [ "${1}" == "-evpf" ] ; then
ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
rm -rf "${current_dir}/temp-h265.mkv" rm -rf "${current_dir}/temp-h265.mkv"
ffmpeg -y -r ${frames_default} -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r ${frames_default} -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -357,7 +372,7 @@ elif [ "${1}" == "-evpf" ] ; then
ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${current_dir}/temp-h265.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
rm -rf "${current_dir}/temp-h265.mkv" rm -rf "${current_dir}/temp-h265.mkv"
ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r 25 -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -370,7 +385,7 @@ elif [ "${1}" == "-evpf" ] ; then
ffmpeg -y -i "${current_dir}/temp-mpeg4.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264" ffmpeg -y -i "${current_dir}/temp-mpeg4.mkv" -c copy -f h264 "${current_dir}/seeing_noaudio.h264"
rm -rf "${current_dir}/temp-mpeg4.mkv" rm -rf "${current_dir}/temp-mpeg4.mkv"
ffmpeg -y -r ${frames_default} -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4" ffmpeg -y -r ${frames_default} -i "${current_dir}/seeing_noaudio.h264" -c copy "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir} (25 fps)" echo -n "* Extracted video into ${video_file_dir} (25 fps)"
sleep 2 sleep 2
@ -613,7 +628,7 @@ elif [ "${1}" == "-evti" ] ; then
echo -n "* Starting extract video track (${2}) " echo -n "* Starting extract video track (${2}) "
sleep 3 sleep 3
ffmpeg -y -i "${2}" -map ${video_track} -c:v copy -ss ${hourCut}:${minuteCut}:${secondCut} "${current_dir}/seeing.mp4" ffmpeg -y -i "${2}" -map ${video_track} -c:v copy -ss ${hourCut}:${minuteCut}:${secondCut} "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir}" echo -n "* Extracted video into ${video_file_dir}"
sleep 2 sleep 2
@ -723,7 +738,7 @@ elif [ "${1}" == "-evti" ] ; then
echo -n "* Starting extract video track (${2}) " echo -n "* Starting extract video track (${2}) "
sleep 3 sleep 3
ffmpeg -y -i "${2}" -map ${video_track} -c:v copy -ss ${hourCut}:${minuteCut}:${secondCut} -t ${hourCutAfter}:${minuteCutAfter}:${secondCutAfter} "${current_dir}/seeing.mp4" ffmpeg -y -i "${2}" -map ${video_track} -c:v copy -ss ${hourCut}:${minuteCut}:${secondCut} -t ${hourCutAfter}:${minuteCutAfter}:${secondCutAfter} "${current_dir}/seeing.mp4"
ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -fps_mode cfr -c:v copy "${video_file_dir}" ffmpeg -y -i "${current_dir}/seeing.mp4" -map 0:0 -${video_sync} cfr -c:v copy "${video_file_dir}"
echo "" echo ""
echo -n "* Extracted video into ${video_file_dir}" echo -n "* Extracted video into ${video_file_dir}"
sleep 2 sleep 2

View File

@ -2,12 +2,27 @@
############################################################### ###############################################################
# ks-mp4 (ks-tools) - Convert video to MP4 format # # ks-mp4 (ks-tools) - Convert video to MP4 format #
# Date: 08-02-2023 # # Date: 10-02-2023 #
# Author: q3aql # # Author: q3aql #
# Contact: q3aql@duck.com # # Contact: q3aql@duck.com #
############################################################### ###############################################################
VERSION="8.4-dev" VERSION="8.4-dev"
M_DATE="080223" M_DATE="100223"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=""
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters # Global parameters
dirTemp="/tmp" dirTemp="/tmp"
@ -198,8 +213,8 @@ fi
p_ffmpeg="ffmpeg -i" p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999" p_ffmpeg_patched="-max_muxing_queue_size 9999"
# f_conversion="-vsync 1 -async 1" # Deprecated method # f_conversion="-vsync 1 -async 1" # Deprecated method
#f_conversion="-fps_mode cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0" #f_conversion="-${video_sync} cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0"
f_conversion="-fps_mode cfr -af aresample=async=1" f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC) # Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265") codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc") codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")

View File

@ -2,12 +2,27 @@
############################################################### ###############################################################
# ks-mp4k (ks-tools) - Convert video to MP4 format (4K) # # ks-mp4k (ks-tools) - Convert video to MP4 format (4K) #
# Date: 08-02-2023 # # Date: 10-02-2023 #
# Author: q3aql # # Author: q3aql #
# Contact: q3aql@duck.com # # Contact: q3aql@duck.com #
############################################################### ###############################################################
VERSION="8.4-dev" VERSION="8.4-dev"
M_DATE="080223" M_DATE="100223"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=""
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters # Global parameters
dirTemp="/tmp" dirTemp="/tmp"
@ -198,8 +213,8 @@ fi
p_ffmpeg="ffmpeg -i" p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999" p_ffmpeg_patched="-max_muxing_queue_size 9999"
# f_conversion="-vsync 1 -async 1" # Deprecated method # f_conversion="-vsync 1 -async 1" # Deprecated method
#f_conversion="-fps_mode cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0" #f_conversion="-${video_sync} cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0"
f_conversion="-fps_mode cfr -af aresample=async=1" f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC) # Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265") codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc") codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")

View File

@ -2,12 +2,27 @@
############################################################### ###############################################################
# ks-mp4s (ks-tools) - Convert video to MP4 format (Series) # # ks-mp4s (ks-tools) - Convert video to MP4 format (Series) #
# Date: 08-02-2023 # # Date: 10-02-2023 #
# Author: q3aql # # Author: q3aql #
# Contact: q3aql@duck.com # # Contact: q3aql@duck.com #
############################################################### ###############################################################
VERSION="8.4-dev" VERSION="8.4-dev"
M_DATE="080223" M_DATE="100223"
# Detect version ffmpeg for old releases
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
IFS="abcdefghijklmnopqrstyvwxzABCDEFHIJKLMNOPQRSTYVWXZ@/()"
ffmpeg_version=$(echo ${ffmpeg_version})
IFS=""
if [ -z "${ffmpeg_version}" ] ; then
video_sync="vsync"
else
if [ ${ffmpeg_version} -lt 5 ] ; then
video_sync="vsync"
else
video_sync="fps_mode"
fi
fi
# Global parameters # Global parameters
dirTemp="/tmp" dirTemp="/tmp"
@ -198,8 +213,8 @@ fi
p_ffmpeg="ffmpeg -i" p_ffmpeg="ffmpeg -i"
p_ffmpeg_patched="-max_muxing_queue_size 9999" p_ffmpeg_patched="-max_muxing_queue_size 9999"
# f_conversion="-vsync 1 -async 1" # Deprecated method # f_conversion="-vsync 1 -async 1" # Deprecated method
#f_conversion="-fps_mode cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0" #f_conversion="-${video_sync} cfr -af aresample=async=1:min_hard_comp=0.100000:first_pts=0"
f_conversion="-fps_mode cfr -af aresample=async=1" f_conversion="-${video_sync} cfr -af aresample=async=1"
# Check if video input uses H265 (HEVC) # Check if video input uses H265 (HEVC)
codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265") codec_h265=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "h265")
codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc") codec_hevc=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")