v0.10.1
This commit is contained in:
		
							parent
							
								
									0b604be35a
								
							
						
					
					
						commit
						cb96ff8b3c
					
				
					 1 changed files with 56 additions and 20 deletions
				
			
		
							
								
								
									
										76
									
								
								burnSubs
									
										
									
									
									
								
							
							
						
						
									
										76
									
								
								burnSubs
									
										
									
									
									
								
							| 
						 | 
					@ -294,7 +294,7 @@ function parseStreams() {
 | 
				
			||||||
	export SUB_COUNT=$("$JQ" 'length' "${STREAMS_SUB}")
 | 
						export SUB_COUNT=$("$JQ" 'length' "${STREAMS_SUB}")
 | 
				
			||||||
	# shellcheck disable=SC2016
 | 
						# shellcheck disable=SC2016
 | 
				
			||||||
	"$JQ" 'reduce .streams[] as $item ([]; if ($item.codec_type == "audio") then [.[],$item] else . end) | reduce .[] as $item ([]; [.[],{t:($item.tags.title),i:($item.index),lang:$item.tags.language, disposition:$item.disposition}]) | reduce .[] as $item ([]; [.[],{t:($item.t // ($item.lang + "-" + ($item.i | tostring))),i:$item.i,lang:$item.lang,disposition:$item.disposition}])' "${STREAMS_ALL}" > "${STREAMS_AUDIO}"
 | 
						"$JQ" 'reduce .streams[] as $item ([]; if ($item.codec_type == "audio") then [.[],$item] else . end) | reduce .[] as $item ([]; [.[],{t:($item.tags.title),i:($item.index),lang:$item.tags.language, disposition:$item.disposition}]) | reduce .[] as $item ([]; [.[],{t:($item.t // ($item.lang + "-" + ($item.i | tostring))),i:$item.i,lang:$item.lang,disposition:$item.disposition}])' "${STREAMS_ALL}" > "${STREAMS_AUDIO}"
 | 
				
			||||||
	export AUDIO_COUNT=$("$JQ" 'length' "${STREAMS_SUB}")
 | 
						export AUDIO_COUNT=$("$JQ" 'length' "${STREAMS_AUDIO}")
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -306,8 +306,8 @@ function listSubtitles() {
 | 
				
			||||||
	printf "Num: %4s %s\n" "LANG" "Subtitle Title String"
 | 
						printf "Num: %4s %s\n" "LANG" "Subtitle Title String"
 | 
				
			||||||
	echo "---------------------------------"
 | 
						echo "---------------------------------"
 | 
				
			||||||
	for iSUB in $(seq 0 $(($SUB_COUNT-1))); do
 | 
						for iSUB in $(seq 0 $(($SUB_COUNT-1))); do
 | 
				
			||||||
		X_TITLE=$($JQ '.['$iSUB'].t' $STREAMS_SUB)
 | 
							X_TITLE=$($JQ '.['$iSUB'].t' $STREAMS_SUB | tr -d '"')
 | 
				
			||||||
		X_INDEX=$($JQ '.['$iSUB'].i' $STREAMS_SUB)
 | 
							X_INDEX=$($JQ '.['$iSUB'].i' $STREAMS_SUB | tr -d '"')
 | 
				
			||||||
		X_LANG=$($JQ '.['$iSUB'].lang' $STREAMS_SUB)
 | 
							X_LANG=$($JQ '.['$iSUB'].lang' $STREAMS_SUB)
 | 
				
			||||||
		printf " %2d: %4s %s\n" $X_INDEX $X_LANG "$X_TITLE" 
 | 
							printf " %2d: %4s %s\n" $X_INDEX $X_LANG "$X_TITLE" 
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
| 
						 | 
					@ -315,6 +315,22 @@ function listSubtitles() {
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function listAudioTracks() {
 | 
				
			||||||
 | 
						# TODO: 
 | 
				
			||||||
 | 
						echo ""
 | 
				
			||||||
 | 
						echo "available audio tracks:"
 | 
				
			||||||
 | 
						printf "Num: %4s %s\n" "LANG" "Title String"
 | 
				
			||||||
 | 
						echo "---------------------------------"
 | 
				
			||||||
 | 
						for iAUDIO in $(seq 0 $(($AUDIO_COUNT-1))); do
 | 
				
			||||||
 | 
							X_TITLE=$($JQ '.['$iAUDIO'].t' $STREAMS_AUDIO | tr -d '"')
 | 
				
			||||||
 | 
							X_INDEX=$($JQ '.['$iAUDIO'].i' $STREAMS_AUDIO | tr -d '"')
 | 
				
			||||||
 | 
							X_LANG=$($JQ '.['$iAUDIO'].lang' $STREAMS_AUDIO)
 | 
				
			||||||
 | 
							printf " %2d: %4s %s\n" $X_INDEX $X_LANG "$X_TITLE" 
 | 
				
			||||||
 | 
						done
 | 
				
			||||||
 | 
						echo ""
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function selectSubs() {
 | 
					function selectSubs() {
 | 
				
			||||||
	# TODO: handle multiple subtitle files
 | 
						# TODO: handle multiple subtitle files
 | 
				
			||||||
	# TODO: verify the the subtitle index is legal
 | 
						# TODO: verify the the subtitle index is legal
 | 
				
			||||||
| 
						 | 
					@ -350,17 +366,21 @@ function selectSubs() {
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if [[ $AUDIO_COUNT -gt 1 ]]; then
 | 
						if [[ $AUDIO_COUNT -gt 1 ]]; then
 | 
				
			||||||
		LANG_TEST=$($JQ '[.[].lang] | index("jpn")' "$STREAMS_AUDIO")
 | 
							if [[ $OPTS_SELAUDIO -lt 0 ]]; then
 | 
				
			||||||
		echo "   > WARNING: Multiple audio streams!"
 | 
								LANG_TEST=$($JQ '[.[].lang] | index("jpn")' "$STREAMS_AUDIO")
 | 
				
			||||||
		printf "       Using default selection rules... "
 | 
								echo "   > WARNING: Multiple audio streams!"
 | 
				
			||||||
		if [[ "$LANG_TEST" == "null" ]]; then
 | 
								printf "       Using default selection rules... "
 | 
				
			||||||
			echo "Japanese audio not found!"
 | 
								if [[ "$LANG_TEST" == "null" ]]; then
 | 
				
			||||||
			echo "    ==> Reverting to first subtitle file."
 | 
									echo "Japanese audio not found!"
 | 
				
			||||||
			export AUDIO_INDEX=$($JQ '.[0].i' "$STREAMS_AUDIO")
 | 
									echo "    ==> Reverting to first subtitle file."
 | 
				
			||||||
 | 
									export AUDIO_INDEX=$($JQ '.[0].i' "$STREAMS_AUDIO")
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									# we found english
 | 
				
			||||||
 | 
									echo "Japanese audio found"
 | 
				
			||||||
 | 
									export AUDIO_INDEX=$($JQ '.['$LANG_TEST'].i' "$STREAMS_AUDIO")
 | 
				
			||||||
 | 
								fi
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			# we found english
 | 
								AUDIO_INDEX=$OPTS_SELAUDIO
 | 
				
			||||||
			echo "Japanese audio found"
 | 
					 | 
				
			||||||
			export AUDIO_INDEX=$($JQ '.['$LANG_TEST'].i' "$STREAMS_AUDIO")
 | 
					 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
		export FF_AUDIO="-map 0:$AUDIO_INDEX -map 0:v:0"
 | 
							export FF_AUDIO="-map 0:$AUDIO_INDEX -map 0:v:0"
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -443,6 +463,7 @@ function alertUser() {
 | 
				
			||||||
OPTS_KLOBBER=false
 | 
					OPTS_KLOBBER=false
 | 
				
			||||||
OPTS_LISTSUBS=false
 | 
					OPTS_LISTSUBS=false
 | 
				
			||||||
OPTS_SELSUB=-1
 | 
					OPTS_SELSUB=-1
 | 
				
			||||||
 | 
					OPTS_SELAUDIO=-1
 | 
				
			||||||
OPTS_LISTSUBS=false
 | 
					OPTS_LISTSUBS=false
 | 
				
			||||||
OPTS_FORCESOFT=false
 | 
					OPTS_FORCESOFT=false
 | 
				
			||||||
OPTS_FORCEPARTSOFT=false
 | 
					OPTS_FORCEPARTSOFT=false
 | 
				
			||||||
| 
						 | 
					@ -505,13 +526,21 @@ while true; do
 | 
				
			||||||
			shift 2
 | 
								shift 2
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
 | 
							"-a")
 | 
				
			||||||
 | 
								OPTS_SELAUDIO="$2"
 | 
				
			||||||
 | 
								#TODO: verify legal subtitle track number convention"
 | 
				
			||||||
 | 
								echo "TODO: verify legal audio track number convention" 
 | 
				
			||||||
 | 
								echo ">> !! Selecting audio track #${OPTS_SELAUDIO}"
 | 
				
			||||||
 | 
								shift 2
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							;;
 | 
				
			||||||
		"--psoft")
 | 
							"--psoft")
 | 
				
			||||||
			OPTS_FORCEPARTSOFT=true
 | 
								OPTS_FORCEPARTSOFT=true
 | 
				
			||||||
			echo ">> !! forcing software encoding."
 | 
								echo ">> !! forcing software encoding."
 | 
				
			||||||
			shift
 | 
								shift
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		;;
 | 
							;;
 | 
				
			||||||
		"--audio")
 | 
							"--lpf")
 | 
				
			||||||
			OPTS_LPF_AUDIO=true
 | 
								OPTS_LPF_AUDIO=true
 | 
				
			||||||
			OPTS_TRANS_AUDIO=true
 | 
								OPTS_TRANS_AUDIO=true
 | 
				
			||||||
			echo ">> !! low pass filter audio to AAC."
 | 
								echo ">> !! low pass filter audio to AAC."
 | 
				
			||||||
| 
						 | 
					@ -567,11 +596,13 @@ while true; do
 | 
				
			||||||
    --soft      force software decode and encode
 | 
					    --soft      force software decode and encode
 | 
				
			||||||
    --psoft     use software encoding (allow hardware decode when available)
 | 
					    --psoft     use software encoding (allow hardware decode when available)
 | 
				
			||||||
    --audiofix  transcode audio
 | 
					    --audiofix  transcode audio
 | 
				
			||||||
    --audio     transcode audio, and low-pass filter as well
 | 
					    --lpf     transcode audio, and low-pass filter as well
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -l          list subtitles (no encoding)
 | 
					    -l          list subtitles and audio tracks (no encoding)
 | 
				
			||||||
    -s <#>      select specific subtitle track number
 | 
					    -s <#>      select specific subtitle track number
 | 
				
			||||||
                #TODO: verify legal subtitle track number convention
 | 
					                #TODO: verify legal subtitle track number convention
 | 
				
			||||||
 | 
					    -a <#>      select specific subtitle track number
 | 
				
			||||||
 | 
					                #TODO: verify legal subtitle track number convention
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -d          debug (no cleanup)
 | 
					    -d          debug (no cleanup)
 | 
				
			||||||
    --dry       dry run (no encoding)
 | 
					    --dry       dry run (no encoding)
 | 
				
			||||||
| 
						 | 
					@ -587,13 +618,17 @@ _EOT
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Now parse POSITIONAL ARGUMENTS
 | 
					# Now parse POSITIONAL ARGUMENTS
 | 
				
			||||||
if [[ $# -ne 2 ]]; then
 | 
					if [[ $# -eq 2 || $OPTS_derived_NO_OUTPUT == true ]]; then
 | 
				
			||||||
 | 
						INPUT_VIDEO="$(readlink -f "$1")"
 | 
				
			||||||
 | 
						if [[ $# -eq 2 ]]; then
 | 
				
			||||||
 | 
							OUTPUT_VIDEO="$2"
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							OUTPUT_VIDEO="/dev/null"
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
	echo "ERROR: Incorrect number of positional arguments. Expected 2, got $#"
 | 
						echo "ERROR: Incorrect number of positional arguments. Expected 2, got $#"
 | 
				
			||||||
	echo "       $(basename $0) [args] <input> <output>"
 | 
						echo "       $(basename $0) [args] <input> <output>"
 | 
				
			||||||
	exit
 | 
						exit
 | 
				
			||||||
else
 | 
					 | 
				
			||||||
	INPUT_VIDEO="$(readlink -f "$1")"
 | 
					 | 
				
			||||||
	OUTPUT_VIDEO="$2"
 | 
					 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
###############
 | 
					###############
 | 
				
			||||||
| 
						 | 
					@ -616,6 +651,7 @@ parseStreams
 | 
				
			||||||
# Now! If OPTS_LISTSUBS is defined, then we branch to list subs and exit.
 | 
					# Now! If OPTS_LISTSUBS is defined, then we branch to list subs and exit.
 | 
				
			||||||
if [[ "$OPTS_LISTSUBS" == "true" ]]; then
 | 
					if [[ "$OPTS_LISTSUBS" == "true" ]]; then
 | 
				
			||||||
	listSubtitles
 | 
						listSubtitles
 | 
				
			||||||
 | 
						listAudioTracks
 | 
				
			||||||
	exit	
 | 
						exit	
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
# ask the user for the subtitle file if more than one is available
 | 
					# ask the user for the subtitle file if more than one is available
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue