Last active
April 30, 2018 20:29
-
-
Save paazmaya/0fcdd0deec63577dce532b17dac61283 to your computer and use it in GitHub Desktop.
FFmpeg from source in Ubuntu
This file contains hidden or 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
git clone https://git.ffmpeg.org/ffmpeg.git | |
cd ffmpeg | |
# Just enabling few important libraries, which are available in Ubuntu | |
# Also look at https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu | |
./configure \ | |
--prefix=/usr \ | |
--enable-gpl \ | |
--enable-version3 \ | |
--enable-nonfree \ | |
--enable-shared \ | |
--enable-frei0r \ | |
--enable-libx264 \ | |
--enable-libx265 \ | |
--enable-libvpx \ | |
--enable-libfdk-aac \ | |
--enable-libmp3lame \ | |
--enable-libopus \ | |
--enable-libass \ | |
--enable-libtheora \ | |
--enable-libvorbis \ | |
--enable-libfreetype \ | |
--enable-libfribidi \ | |
--enable-libfontconfig \ | |
--enable-libgsm \ | |
--enable-libopencore-amrnb \ | |
--enable-libopencore-amrwb \ | |
--enable-libshine \ | |
--enable-libsnappy \ | |
--enable-libspeex \ | |
--enable-libtwolame \ | |
--enable-libv4l2 \ | |
--enable-libwebp \ | |
--enable-libvo-amrwbenc \ | |
--enable-opengl \ | |
--enable-libdrm | |
# Use four threads to speed up | |
make -j4 | |
sudo make install |
This file contains hidden or 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
# Encode all MOV files found recursively from the given directory. | |
# Skip any MOV files that have MP4 counterpart file already. | |
DIRECTORY=$(realpath "${1:-.}"); | |
BITRATE=${2:-3200k} | |
IFS=$'\n' # split only on newlines | |
LIST=$(find "${DIRECTORY}" -maxdepth 4 -type f -iname '*.mov' -or -iname '*.mts'); | |
echo "Encoding directory '${DIRECTORY}' with video bitrate ${BITRATE}"; | |
# How much visual difference does "slow" and "slower" produce? | |
for MOVFILE in ${LIST}; do | |
echo ${MOVFILE}; | |
MP4FILE="${MOVFILE%.*}.mp4" | |
echo ${MP4FILE}; | |
if [ ! -f ${MP4FILE} ]; then | |
# First pass | |
ffmpeg -y -i "${MOVFILE}" -c:v libx265 \ | |
-preset slower -tune fastdecode -b:v ${BITRATE} \ | |
-x265-params pass=1 -c:a aac -b:a 128k \ | |
-f mp4 /dev/null; | |
# Second pass | |
ffmpeg -i "${MOVFILE}" -c:v libx265 \ | |
-preset slower -tune fastdecode -b:v ${BITRATE} \ | |
-x265-params pass=2 -c:a aac -b:a 128k \ | |
"${MP4FILE}"; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment