Support for H265 HDR conversion to H264 (ks-mix)
This commit is contained in:
parent
8e1b7e01e3
commit
d25a15babb
29
src/ks-mix
29
src/ks-mix
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# 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: 13-02-2023 #
|
# Date: 11-03-2023 #
|
||||||
# Author: q3aql #
|
# Author: q3aql #
|
||||||
# Contact: q3aql@duck.com #
|
# Contact: q3aql@duck.com #
|
||||||
#####################################################################
|
#####################################################################
|
||||||
VERSION="8.4-dev"
|
VERSION="8.4-dev"
|
||||||
M_DATE="130223"
|
M_DATE="110323"
|
||||||
|
|
||||||
# Detect version ffmpeg for old releases
|
# Detect version ffmpeg for old releases
|
||||||
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
|
ffmpeg_version=$(ffmpeg -version 2>&1 | grep version | head -1 | cut -d " " -f 3 | cut -d "." -f 1)
|
||||||
|
@ -222,8 +222,10 @@ elif [ "${1}" == "-ev25" ] ; then
|
||||||
codec_hevc=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
|
codec_hevc=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "hevc")
|
||||||
yuv420p10le=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
|
yuv420p10le=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "yuv420p10le")
|
||||||
hevc_main10=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
|
hevc_main10=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
|
||||||
hevc_profile_10bit="${yuv420p10le}${hevc_main10}"
|
|
||||||
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
|
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
|
||||||
|
hevc_hdr_bt=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
|
||||||
|
hevc_hdr_smp=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
|
||||||
|
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
|
||||||
# Check if video input uses MPEG4/XVID
|
# Check if video input uses MPEG4/XVID
|
||||||
codec_mpeg4=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "mpeg4")
|
codec_mpeg4=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "mpeg4")
|
||||||
codec_xvid=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "xvid")
|
codec_xvid=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "xvid")
|
||||||
|
@ -235,10 +237,10 @@ elif [ "${1}" == "-ev25" ] ; then
|
||||||
codec_encoded="mpeg4_encoded"
|
codec_encoded="mpeg4_encoded"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${hevc_profile_10bit}" ] ; then
|
if [ -z "${hevc_hdr}" ] ; then
|
||||||
codec_encoded="h265_encoded"
|
codec_encoded="h265_encoded"
|
||||||
else
|
else
|
||||||
codec_encoded="h265_encoded_10bit"
|
codec_encoded="h265_encoded_hdr"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Extract video with diferent codecs
|
# Extract video with diferent codecs
|
||||||
|
@ -266,9 +268,8 @@ elif [ "${1}" == "-ev25" ] ; then
|
||||||
rm -rf "${current_dir}/seeing.mp4"
|
rm -rf "${current_dir}/seeing.mp4"
|
||||||
echo "" && echo ""
|
echo "" && echo ""
|
||||||
exit
|
exit
|
||||||
elif [ "${codec_encoded}" == "h265_encoded_10bit" ] ; then
|
elif [ "${codec_encoded}" == "h265_encoded_hdr" ] ; then
|
||||||
#ffmpeg -y -i "${2}" -map ${video_track} -c:v libx264 -x264opts colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084:chromaloc=2 -profile:v high -pix_fmt yuv420p -b:v 3500k -preset medium "${current_dir}/temp-h265.mkv"
|
ffmpeg -y -i "${2}" -map ${video_track} -c:v libx264 -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv -profile:v high -pix_fmt yuv420p -b:v 3500k -preset medium "${current_dir}/temp-h265.mkv"
|
||||||
ffmpeg -y -i "${2}" -map ${video_track} -c:v libx264 -profile:v high -pix_fmt yuv420p -b:v 3500k -preset medium "${current_dir}/temp-h265.mkv"
|
|
||||||
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"
|
||||||
|
@ -346,6 +347,9 @@ elif [ "${1}" == "-evpf" ] ; then
|
||||||
hevc_main10=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
|
hevc_main10=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "Main 10")
|
||||||
hevc_profile_10bit="${yuv420p10le}${hevc_main10}"
|
hevc_profile_10bit="${yuv420p10le}${hevc_main10}"
|
||||||
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
|
codec_h265_hevc="${codec_h265}${codec_hevc}${yuv420p10le}"
|
||||||
|
hevc_hdr_bt=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "bt2020")
|
||||||
|
hevc_hdr_smp=$(${p_ffmpeg} "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "smpte2084")
|
||||||
|
hevc_hdr="${hevc_hdr_bt}${hevc_hdr_smp}"
|
||||||
# Check if video input uses MPEG4/XVID
|
# Check if video input uses MPEG4/XVID
|
||||||
codec_mpeg4=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "mpeg4")
|
codec_mpeg4=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "mpeg4")
|
||||||
codec_xvid=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "xvid")
|
codec_xvid=$(ffmpeg -i "${2}" 2>&1 | grep Stream | tr -s " " | grep "Video:" | grep "xvid")
|
||||||
|
@ -357,10 +361,10 @@ elif [ "${1}" == "-evpf" ] ; then
|
||||||
codec_encoded="mpeg4_encoded"
|
codec_encoded="mpeg4_encoded"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -z "${hevc_profile_10bit}" ] ; then
|
if [ -z "${hevc_hdr}" ] ; then
|
||||||
codec_encoded="h265_encoded"
|
codec_encoded="h265_encoded"
|
||||||
else
|
else
|
||||||
codec_encoded="h265_encoded_10bit"
|
codec_encoded="h265_encoded_hdr"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Extract video with diferent codecs
|
# Extract video with diferent codecs
|
||||||
|
@ -388,9 +392,8 @@ elif [ "${1}" == "-evpf" ] ; then
|
||||||
rm -rf "${current_dir}/seeing.mp4"
|
rm -rf "${current_dir}/seeing.mp4"
|
||||||
echo "" && echo ""
|
echo "" && echo ""
|
||||||
exit
|
exit
|
||||||
elif [ "${codec_encoded}" == "h265_encoded_10bit" ] ; then
|
elif [ "${codec_encoded}" == "h265_encoded_hdr" ] ; then
|
||||||
#ffmpeg -y -i "${2}" -map ${video_track} -c:v libx264 -x264opts colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084:chromaloc=2 -profile:v high -pix_fmt yuv420p -b:v 3500k -preset medium "${current_dir}/temp-h265.mkv"
|
ffmpeg -y -i "${2}" -map ${video_track} -c:v libx264 vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv -profile:v high -pix_fmt yuv420p -b:v 3500k -preset medium "${current_dir}/temp-h265.mkv"
|
||||||
ffmpeg -y -i "${2}" -map ${video_track} -c:v libx264 -profile:v high -pix_fmt yuv420p -b:v 3500k -preset medium "${current_dir}/temp-h265.mkv"
|
|
||||||
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"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user