Advertisement
Guest User

Transcode Hi10p

a guest
Apr 1st, 2012
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.88 KB | None | 0 0
  1. #!/bin/bash
  2. # ----------
  3. # This script uses x264/mkvmerge to convert any mkv x264 video to 8-bit (high @ 4.1 Profile) circumventing possible
  4. # issues with the High 10 Profile (Hi10p)
  5. #
  6. # While Hi10p is supreme to 8-Bit (regarding both file size and quality), there is a serious lack of support for it,
  7. # especially on linux (surprise, surprise!). Only newer versions of mplayer/2 and ffmpeg support this format.
  8. # And even then you won't get GPU acceleration rendering the support useless unless you have a fast CPU, especially regarding
  9. # 1080p material found in anime movies and BD rips of series.
  10. #
  11. # Unfortunately, more and more anime fansub groups are jumping on the Hi10P train :-(. Some don't even bother to tag
  12. # their files with something like "Hi10p".
  13. # ----------
  14. # Needed tools:
  15. # MKVToolnix (install Ubuntu mkvtoolnix package)
  16. # x264 (install Ubuntu x264 package)
  17. # ----------
  18. # Usage:
  19. # transcode_8bit <output directory> FILE1 FILE2 ...
  20. # ----------
  21.  
  22. # initialize variables
  23. OUTPUTDIR=$1
  24. shift
  25.  
  26. if [ ! -d $OUTPUTDIR ]
  27. then
  28.    mkdir $OUTPUTDIR
  29. fi
  30.  
  31. WORKDIR=$HOME
  32. TEMPFILE=$WORKDIR/transcode.8bit.temp.$$.mkv
  33.  
  34. for input in "$@"
  35. do
  36.    output=$input
  37.    output=${output##*/}
  38.    output=${output%.mkv}[8-bit].mkv
  39.    output=$OUTPUTDIR/$output
  40.  
  41.    echo "processing $input -> $output ..."
  42.  
  43.    # use x264 to transcode the video stream -- not sure which crf-value I should use
  44.    # priorize quality over file size!
  45.    x264 --threads=auto --tune animation --preset veryfast --profile high --level 4.1 --crf 16 -o "$TEMPFILE" "$input"
  46.    # use mkvmerge to put everything back together (except the original video, of course)
  47.    mkvmerge -o "$output" -D "$input" "$TEMPFILE"
  48.    # make things pretty
  49.    echo
  50.    # clean up temp files
  51.    if [ -e $TEMPFILE ]
  52.    then
  53.       rm -f "$TEMPFILE"
  54.    fi
  55.  
  56.    echo "processing $input -> $output done"
  57.    echo
  58. done
  59.  
  60. # all done
  61. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement