Skip to content

Instantly share code, notes, and snippets.

@MartinBucko
Forked from mmstick/transcode-install.sh
Created October 20, 2022 21:48
Show Gist options
  • Select an option

  • Save MartinBucko/191759140ced08716960283d9b66ff2f to your computer and use it in GitHub Desktop.

Select an option

Save MartinBucko/191759140ced08716960283d9b66ff2f 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.
#!/bin/bash
mkdir ~/.local/src
export CFLAGS='-march=native -O3 -pipe -fstack-protector -Wall'
export CXXFLAGS='-march=native -O3 -pipe -fstack-protector -Wall'
function package-deb() {
sudo checkinstall --pkgname "$1" --pkgversion "$2" --provides "$3" -y
}
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 build-libass() {
sudo apt-get autoremove libass{5,-dev}
sudo apt-fast install lib{freetype6,fribidi,fontconfig1}-dev
cd ~/.local/src
cd libass
./autogen.sh
./configure
make -j9
package-deb "libass-git" "$(git rev-list --count HEAD)" "libass5, libass-dev"
make distclean
}
function build-x265() {
cd ~/.local/src/x265/build/linux
[[ $(arch) == x86_64 ]] && LDFLAGS+=',-z,noexecstack'
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr ../../source -DHIGH_BIT_DEPTH=1
make -j9
package-deb "x265-10bit" "1.6" "x265"
make clean
}
function build-ffmpeg() {
cd ~/.local/src/ffmpeg
sudo apt-fast install -y libx264-dev libvpx-dev libtheora-dev libopus-dev libvorbis-dev libfdk-aac-dev libx11-dev libharfbuzz-dev libenca-dev
./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-x11grab --extra-cflags="-march=native -O3" --extra-cxxflags="-march=native -O3"
make -j9
package-deb "ffmpeg-git" "$(git rev-list --count HEAD)" "ffmpeg"
make distclean
}
function build-bomi() {
cd ~/.local/src/
git clone https://github.com/xylosper/bomi
cd bomi
./download-libchardet
./build-libchardet
sudo apt-fast install qt5-default qttools5-dev-tools lib{pulse,libasound2,jack}-dev \
lib{dvdread,dvdnav,bluray,glib2.0,libva,vdpau,xcb-icccm4,xcb-screensaver0}-dev \
lib{xcb-randr0,xcb-xtest0,systemd,cdio,cdio-cdda,cdio-paranoia,smbclient}-dev \
lib{qt5svg5,qt5x11extras5,xv,bz2}-dev qt-quick1-5-dev qtdeclarative5-dev \
qtdeclarative5-controls-plugin
package-deb "bomi-git" "$(git rev-list --count HEAD)" "bomi"
make distclean
}
sudo apt-fast install -y libtool autoconf build-essential cmake yasm
cd ~/.local/src
download-x265
download-ffmpeg
download-libass
build-libass
build-x265
build-ffmpeg
build-bomi ## Optional
#!/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
#!/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
#!/bin/bash
mkdir ~/.local/src
export CFLAGS='-march=native -O3 -pipe -fstack-protector -Wall'
export CXXFLAGS='-march=native -O3 -pipe -fstack-protector -Wall'
function package-deb() {
sudo checkinstall --pkgname "$1" --pkgversion "$2" --provides "$3" -y
}
function update-libass() {
cd ~/.local/src/libass; git pull
./autogen.sh; ./configure
make -j9
package-deb "libass-git" "$(git rev-list --count HEAD)" "libass5, libass-dev"
make distclean
}
function update-x265() {
cd ~/.local/src/x265; git pull
cd ~/.local/src/x265/build/linux
[[ $(arch) == x86_64 ]] && LDFLAGS+=',-z,noexecstack'
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr ../../source -DHIGH_BIT_DEPTH=1
make -j9
package-deb "x265-10bit" "1.6" "x265"
make clean
}
function update-ffmpeg() {
cd ~/.local/src/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-x11grab --extra-cflags="-march=native -O3" --extra-cxxflags="-march=native -O3"
make -j9
package-deb "ffmpeg-git" "$(git rev-list --count HEAD)" "ffmpeg"
make distclean
}
function update-bomi() {
cd ~/.local/src/bomi; git pull
./download-libchardet
./build-libchardet
sudo apt-fast install qt5-default qttools5-dev-tools lib{pulse,libasound2,jack}-dev \
lib{dvdread,dvdnav,bluray,glib2.0,libva,vdpau,xcb-icccm4,xcb-screensaver0}-dev \
lib{xcb-randr0,xcb-xtest0,systemd,cdio,cdio-cdda,cdio-paranoia,smbclient}-dev \
lib{qt5svg5,qt5x11extras5,xv,bz2}-dev qt-quick1-5-dev qtdeclarative5-dev \
qtdeclarative5-controls-plugin
package-deb "bomi-git" "$(git rev-list --count HEAD)" "bomi"
make distclean
}
sudo apt-fast update; sudo apt-fast dist-upgrade -y
update-libass
update-x265
update-ffmpeg
update-bomi ## Optional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment