Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for movie_source_file in $(ls | grep -P -o '.*\.(mkv|m2ts|ts)$')
- do
- movie_source_file_name=${movie_source_file%.*}
- if [ ! -f ${movie_source_file_name}.mp4 ]; then
- if [ ! -f ${movie_source_file_name}.m4a ]; then
- #echo Find ${movie_source_file} english track
- eng_track_info=$(ffprobe -show_entries stream=index,codec_type,codec_name:stream_tags=language -of compact ${movie_source_file} -v 0 | grep 'eng' | grep 'audio'| grep 'dts')
- if [ ${eng_track_info} ]; then
- eng_track=$(echo ${eng_track_info} | grep -P -o '(?<=^stream\|index=)\d*')
- echo 音訊軌${eng_track}為DTS格式,開始音訊編碼
- ffmpeg -n -i ${movie_source_file} -map 0:${eng_track} -c:a libfdk_aac -vbr 4 ${movie_source_file_name}.m4a
- else
- eng_track_info=$(ffprobe -show_entries stream=index,codec_type,codec_name:stream_tags=language -of compact ${movie_source_file} -v 0 | grep 'eng' | grep 'audio')
- eng_track=$(echo ${eng_track_info} | grep -P -o '(?<=^stream\|index=)\d*')
- echo 音訊軌${eng_track}非DTS格式,開始音訊編碼
- ffmpeg -n -i ${movie_source_file} -map 0:${eng_track} -c:a libfdk_aac -vbr 4 ${movie_source_file_name}.m4a
- fi
- echo
- fi
- ffmpeg -loglevel panic -i ${movie_source_file_name}.hevc -i ${movie_source_file_name}.m4a -map 0:0 -map 1:0 -c:v copy -c:a copy ${movie_source_file_name}.mp4
- else
- echo ${movie_source_file_name}.mp4 存在 視訊混流已完成
- rm ${movie_source_file_name}.m4a
- fi
- done
Add Comment
Please, Sign In to add comment