jhangyu

Mux movie eng track with hevc

Jul 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1. for movie_source_file in $(ls | grep -P -o '.*\.(mkv|m2ts|ts)$')
  2. do
  3.     movie_source_file_name=${movie_source_file%.*}
  4.     if [ ! -f ${movie_source_file_name}.mp4 ]; then
  5.         if [ ! -f ${movie_source_file_name}.m4a ]; then
  6.             #echo Find ${movie_source_file} english track
  7.             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')
  8.             if [ ${eng_track_info} ]; then
  9.                 eng_track=$(echo ${eng_track_info} | grep -P -o '(?<=^stream\|index=)\d*')
  10.                 echo 音訊軌${eng_track}為DTS格式,開始音訊編碼
  11.                 ffmpeg -n -i ${movie_source_file} -map 0:${eng_track} -c:a libfdk_aac -vbr 4 ${movie_source_file_name}.m4a
  12.             else
  13.                 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')
  14.                 eng_track=$(echo ${eng_track_info} | grep -P -o '(?<=^stream\|index=)\d*')
  15.                 echo 音訊軌${eng_track}非DTS格式,開始音訊編碼
  16.                 ffmpeg -n -i ${movie_source_file} -map 0:${eng_track} -c:a libfdk_aac -vbr 4 ${movie_source_file_name}.m4a
  17.             fi
  18.             echo
  19.         fi
  20.         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
  21.     else
  22.         echo ${movie_source_file_name}.mp4 存在 視訊混流已完成
  23.         rm ${movie_source_file_name}.m4a
  24.     fi
  25. done
Add Comment
Please, Sign In to add comment