Detect audio 5.1/7.1 & change to stereo (ks-mp3/oga)

This commit is contained in:
q3aql 2021-03-09 12:51:21 +01:00
parent 529db471c4
commit c276345ec6
2 changed files with 24 additions and 4 deletions

View File

@ -247,12 +247,22 @@ else
genre_file="${genre_file}" genre_file="${genre_file}"
fi fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion # Show commands for conversion
echo "" echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:" echo "* COMMANDS THAT WILL BE EXECUTED:"
echo "" echo ""
echo " # Convert the file '${1}' to MP3 Audio" echo " # Convert the file '${1}' to MP3 Audio"
echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\"" echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\""
# Execute commands for conversion # Execute commands for conversion
echo "" echo ""
@ -260,6 +270,6 @@ else
if [ "${run_commands_ffmpeg}" == "n" ] ; then if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit exit
else else
${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}" ${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}"
fi fi
fi fi

View File

@ -247,12 +247,22 @@ else
genre_file="${genre_file}" genre_file="${genre_file}"
fi fi
# Check audio 5.1 or 7.1
audio_5_7_1=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "5.1")
audio_5_7_1_2=$(${p_ffmpeg} "${1}" 2>&1 | grep Stream | tr -s " " | grep "Audio:" | grep "${audio_track}" | grep -i "7.1")
audio_5_7_1="${audio_5_7_1}${audio_5_7_1_2}"
if [ -z "${audio_5_7_1}" ] ; then
stereo_params="-ac 2"
else
stereo_params="-ac 2 -clev 3dB -slev -6dB"
fi
# Show commands for conversion # Show commands for conversion
echo "" echo ""
echo "* COMMANDS THAT WILL BE EXECUTED:" echo "* COMMANDS THAT WILL BE EXECUTED:"
echo "" echo ""
echo " # Convert the file '${1}' to OGG Audio" echo " # Convert the file '${1}' to OGG Audio"
echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\"" echo " ${p_ffmpeg} \"${1}\" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title=\"${name_title}\" -metadata date=\"${year_num}\" -metadata genre=\"${genre_file}\" -metadata album=\"${album_title}\" -metadata artist=\"${artist_title}\" -metadata track=\"${track_num}\" \"${2}.${v_ext}\""
# Execute commands for conversion # Execute commands for conversion
echo "" echo ""
@ -260,6 +270,6 @@ else
if [ "${run_commands_ffmpeg}" == "n" ] ; then if [ "${run_commands_ffmpeg}" == "n" ] ; then
exit exit
else else
${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}" ${p_ffmpeg} "${1}" -map ${audio_track} -c:a ${acodec} -b:a ${b_acodec} ${stereo_params} -metadata title="${name_title}" -metadata date="${year_num}" -metadata genre="${genre_file}" -metadata album="${album_title}" -metadata artist="${artist_title}" -metadata track="${track_num}" "${2}.${v_ext}"
fi fi
fi fi