-
-
Save nicksan2c/061abd27a393f2d5b91d64f621d89f43 to your computer and use it in GitHub Desktop.
Ubuntu 10-bit HEVC Transcoding Tools -- Contains a script to install x265-10bit-git, libass-git, ffmpeg-git and bomi-git; another for updating everything; as well as scripts for transcoding videos with ffmpeg. Transcoding scripts require the fish shell to be installed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sourcedir="$HOME/.local/src/" | |
mkdir "$sourcedir" | |
export CFLAGS='-march=native -O3 -pipe -fstack-protector -Wall' | |
export CXXFLAGS='-march=native -O3 -pipe -fstack-protector -Wall' | |
function install-dependencies() { | |
# Install build tools and Mesa VDPAU support. | |
sudo apt-fast install -y cmake yasm autoconf build-essential mesa-vdpau-drivers \ | |
libvdpau-va-gl1 | |
# Remove Conflicts | |
sudo apt-get autoremove libass{5,-dev} libx265{-43,-dev} -y | |
# These packages are removed for some reason when removing libass from Ubuntu. | |
sudo apt-fast install -y freepats gstreamer1.0-plugins-bad-faad \ | |
gstreamer1.0-plugins-bad-videoparsers libcdaudio1 libdca0 \ | |
libdirac-encoder0 libdirectfb-1.2-9 libfluidsynth1 libgme0 \ | |
libgstreamer-plugins-bad0.10-0 libgstreamer-plugins-bad1.0-0 libkate1 libmimic0 \ | |
libmms0 libmpg123-0 libofa0 libopencv-calib3d2.4 libopencv-contrib2.4 \ | |
libopencv-features2d2.4 libopencv-flann2.4 libopencv-legacy2.4 \ | |
libopencv-ml2.4 libopencv-objdetect2.4 libopencv-video2.4 libslv2-9 \ | |
libsoundtouch0 libspandsp2 libsrtp0 libwildmidi-config libwildmidi1 libzbar0 \ | |
libzvbi-common libzvbi0 | |
# Development Libraries | |
sudo apt-fast install -y lib{pulse,asound2,jack}-dev \ | |
lib{x264,vpx,theora,opus,vorbis,fdk-aac}-dev \ | |
lib{freetype6,fribidi,fontconfig1,harfbuzz,enca}-dev \ | |
lib{dvdread,dvdnav,bluray,cdio,cdio-cdda,cdio-paranoia,smbclient}-dev \ | |
lib{va,vdpau}-dev | |
# X11 Libs | |
sudo apt-fast install lib{x11,xcb-icccm4,xcb-screensaver0,xcb-randr0}-dev \ | |
lib{xcb-xtest0,xv,xrandr,xfixes,x11-xcb}-dev -y | |
## Bomi Development Libraries | |
sudo apt-fast install qt5-default qttools5-dev-tools qtquick1-5-dev \ | |
lib{qt5svg5,qt5x11extras5,systemd,glib2.0}-dev \ | |
libbz2-dev qtdeclarative5-dev -y | |
# Bomi Dependencies | |
sudo apt-fast install qtdeclarative5-controls-plugin -y | |
} | |
## Compiles the source code, packages it into a deb and cleans up compiled files | |
## from the source tree. | |
function package-deb() { | |
make -j9 | |
sudo checkinstall --pkgname "$1" --pkgversion "$2" --provides "$3" -y | |
make distclean; make clean | |
} | |
## Functions for downloading the latest git of each respective project. | |
function download-x265() { | |
git clone https://github.com/videolan/x265 | |
} | |
function download-ffmpeg() { | |
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg | |
} | |
function download-libass() { | |
git clone https://github.com/libass/libass/ | |
} | |
function download-bomi() { | |
git clone https://github.com/xylosper/bomi | |
} | |
## Builds the latest version of the libass subtitle library, which is needed by bomi. | |
function build-libass() { | |
cd "${sourcedir}/libass" | |
./autogen.sh; ./configure prefix=/usr | |
package-deb "libass-git" "$(git rev-list --count HEAD)" "libass5, libass-dev" | |
} | |
## Bulds the latest version of x265 compiled with 10-bit encode support. | |
function build-x265() { | |
cd "${sourcedir}x265/build/linux" | |
sudo apt-fast autoremove libx265{-43,-dev} -y # Conflicts with ffmpeg | |
[[ $(arch) == x86_64 ]] && LDFLAGS+=',-z,noexecstack' | |
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr ../../source -DHIGH_BIT_DEPTH=1 | |
package-deb "x265-10bit" "$(git rev-list --count HEAD)" "x265" | |
} | |
## Builds the latest version of ffmpeg with libass-git and x265-10bit-git support. | |
function build-ffmpeg() { | |
cd ${sourcedir}ffmpeg | |
./configure --prefix=/usr --enable-gpl --enable-nonfree --enable-libass --enable-libfreetype --enable-libopus --enable-libvorbis --enable-libfdk-aac --enable-libx265 --enable-libx264 --enable-libvpx --enable-libtheora --enable-libbluray --enable-libcdio --enable-libfreetype --enable-libfribidi --enable-libsmbclient --enable-version3 --enable-x11grab --extra-cflags="-march=native -O3" --extra-cxxflags="-march=native -O3" | |
package-deb "ffmpeg-git" "$(git rev-list --count HEAD)" "ffmpeg" | |
} | |
## Builds the latest git of Bomi using the version of ffmpeg that we compiled earlier, | |
## and with all features enabled. Please report missing features. | |
function build-bomi() { | |
cd "${sourcedir}bomi" | |
./download-libchardet | |
./build-libchardet | |
./configure --prefix=/usr/local | |
package-deb "bomi-git" "$(git rev-list --count HEAD)" "bomi" | |
} | |
function main() { | |
cd "$sourcedir" | |
install-dependencies | |
download-265; download-ffmpeg; download-libass | |
build-libass; build-x265; build-ffmpeg | |
download-bomi; build-bomi ## Optional | |
} | |
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sourcedir="$HOME/.local/src/" | |
mkdir $sourcedir | |
export CFLAGS='-march=native -O3 -pipe -fstack-protector -Wall' | |
export CXXFLAGS='-march=native -O3 -pipe -fstack-protector -Wall' | |
function package-deb() { | |
make -j9 | |
sudo checkinstall --pkgname "$1" --pkgversion "$2" --provides "$3" -y | |
make distclean; make clean | |
} | |
function update-libass() { | |
cd "${sourcedir}libass"; git pull | |
./autogen.sh; ./configure prefix=/usr | |
package-deb "libass-git" "$(git rev-list --count HEAD)" "libass5, libass-dev" | |
} | |
function update-x265() { | |
cd "${sourcedir}x265"; git pull | |
cd "${sourcedir}x265/build/linux" | |
[[ $(arch) == x86_64 ]] && LDFLAGS+=',-z,noexecstack' | |
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr ../../source -DHIGH_BIT_DEPTH=1 | |
package-deb "x265-10bit" "$(git rev-list --count HEAD)" "x265" | |
} | |
function update-ffmpeg() { | |
cd "${sourcedir}ffmpeg"; git pull | |
./configure --prefix=/usr --enable-gpl --enable-nonfree --enable-libass --enable-libfreetype --enable-libopus --enable-libvorbis --enable-libfdk-aac --enable-libx265 --enable-libx264 --enable-libvpx --enable-libtheora --enable-libbluray --enable-libcdio --enable-libfreetype --enable-libfribidi --enable-libsmbclient --enable-version3 --enable-x11grab --extra-cflags="-march=native -O3" --extra-cxxflags="-march=native -O3" | |
package-deb "ffmpeg-git" "$(git rev-list --count HEAD)" "ffmpeg" | |
} | |
function update-bomi() { | |
cd "${sourcedir}bomi"; git pull | |
./download-libchardet; ./build-libchardet | |
./configure --prefix=/usr/local | |
package-deb "bomi-git" "$(git rev-list --count HEAD)" "bomi" | |
} | |
sudo apt-fast update; sudo apt-fast dist-upgrade -y | |
update-libass | |
update-x265 | |
update-ffmpeg | |
update-bomi ## Optional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/fish | |
# Gets a list of all videos in the current directory and subdirectory. | |
function get_video_list | |
find * -type f -name \*.mkv | |
end | |
# Utilizes ffmpeg to transcode the current input video, $1, with Opus audio and | |
# H.265 video. It receives a preset parameter, "$2", and a CRF parameter, "$3", | |
# and will write the newly-transcoded videos to the transcoded directory. | |
function transcode | |
ffmpeg -i "$argv[1]" -c:a libopus -c:v libx264 -profile:v high -level 4.2 \ | |
-crf "$argv[2]" (basename $argv[1] .mkv)_transcoded.mkv | |
end | |
# After the transcode is complete, it moves the files to another directory | |
# for easy cleanup. | |
function move_transcodes | |
mv "$argv[1]" original | |
mv (basename $argv[1] .mkv)_transcoded.mkv transcoded | |
end | |
# This will create two directories: transcoded and | |
# original; then get a list of all videos and begin transcoding each video | |
# one by one. After it finishes transcoding a video, it will | |
function main | |
mkdir transcoded original | |
for video in (get_video_list) | |
transcode "$video" "18" | |
move_transcodes "$video" | |
end | |
end | |
## Start script | |
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/fish | |
# Gets a list of all videos in the current directory and subdirectory. | |
function get_video_list | |
find * -type f -name \*.mkv | |
end | |
# Utilizes ffmpeg to transcode the current input video, $1, with Opus audio and | |
# H.265 video. It receives a preset parameter, "$2", and a CRF parameter, "$3", | |
# and will write the newly-transcoded videos to the transcoded directory. | |
function transcode | |
ffmpeg -i "$argv[1]" -preset "$argv[2]" -c:a libopus -c:v libx265 \ | |
-x265-params "crf=$argv[3]:ref=6:subme=7:bframes=16" \ | |
(basename $argv[1] .mkv)_transcoded.mkv | |
end | |
# After the transcode is complete, it moves the files to another directory | |
# for easy cleanup. | |
function move_transcodes | |
mv "$argv[1]" original | |
mv (basename $argv[1] .mkv)_transcoded.mkv transcoded | |
end | |
# This will create two directories: transcoded and | |
# original; then get a list of all videos and begin transcoding each video | |
# one by one. After it finishes transcoding a video, it will | |
function main | |
mkdir transcoded original | |
for video in (get_video_list) | |
transcode "$video" "veryslow" "18" | |
move_transcodes "$video" | |
end | |
end | |
## Start script | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment