Projects
Multimedia
ffhevc
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 16
View file
ffhevc.changes
Changed
@@ -1,4 +1,22 @@ ------------------------------------------------------------------- +Sun Nov 13 11:36:00 UTC 2016 - neutrino8@opensuse.org + +- Update to version 3.0.0 + * Added support for batch encoding mode, to be activated with the + new -b option. It's used to encode directories with video files + * Renamed variable $mode to $encmode for clarity + * Reworked the input/output code + * Disabled strong-intra-smoothing in the default x265 options + in the config file + * Instead of relying on a config var to set the subtitles amount + to support, ask the user each time to provide it. Makes the + code less complex and easier to extend in the future. Bumps up + config file version to 30 + * Check if the X265PARAMS var is missing from config in case we're + not using an x265 preset + * Updated the man page + +------------------------------------------------------------------- Sat Nov 12 10:48:00 UTC 2016 - neutrino8@opensuse.org - Update to version 2.9.9
View file
ffhevc.spec
Changed
@@ -17,7 +17,7 @@ Name: ffhevc -Version: 2.9.9 +Version: 3.0.0 Release: 0 Summary: A small shell script for encoding to H.265/HEVC with ffmpeg License: GPL-2.0+
View file
ffhevc-2.9.9.tar.gz/ChangeLog -> ffhevc-3.0.0.tar.gz/ChangeLog
Changed
@@ -1,3 +1,18 @@ +2016-11-13 - ffhevc 3.0.0 + * Added support for batch encoding mode, to be activated with the + new -b option. It's used to encode directories with video files + * Renamed variable $mode to $encmode for clarity + * Reworked the input/output code + * Disabled strong-intra-smoothing in the default x265 options + in the config file + * Instead of relying on a config var to set the subtitles amount + to support, ask the user each time to provide it. Makes the + code less complex and easier to extend in the future. Bumps up + config file version to 30 + * Check if the X265PARAMS var is missing from config in case we're + not using an x265 preset + * Updated the man page + 2016-11-12 - ffhevc 2.9.9 * Added support for importing external srt/ssa subtitles for the mkv, m2ts, mts and ts containers
View file
ffhevc-2.9.9.tar.gz/ffhevc -> ffhevc-3.0.0.tar.gz/ffhevc
Changed
@@ -2,8 +2,8 @@ # # Small script to encode to H.265/HEVC video using FFmpeg and libx265. # Author: Grozdan "microchip" Nikolov <neutrino8@opensuse.org> -# Version: 2.9.9 -# Date: 2016-11-12 +# Version: 3.0.0 +# Date: 2016-11-13 # # ffhevc is free software ; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,10 +23,10 @@ brown() { echo -e "\e[0;33m$1\e[0;39;49m"; } error() { echo -e "\e[1;31m$1\e[0;39;49m"; } -version="2.9.9" +version="3.0.0" CFG="$HOME/.ffhevc" -cfgversion="29" +cfgversion="30" genconfig_func() { cat<<EOF>>"$CFG" @@ -96,17 +96,11 @@ # detected audio tracks MAX_AUD_TRACKS="2" -# Set to "n" to disable subtitles +# Enable subtitles support? # Note: not all containers support # all types of subs! SUBS="y" -# Max amount of subtitles to support -# Any non-zero value will do. Set it -# to "auto" to ask for as many as -# detected subtitles -MAX_SUBS="1" - # Copy original metadata from input? METADATA="n" @@ -115,8 +109,8 @@ # libx265 parameters. Modify, if needed, # to fit your needs -# merange is calculated as: ctu size - 4 - 2 (- 1 if me=hex is used) -X265PARAMS="ref=4:me=star:bframes=6:rd=5:subme=6:merange=58:strong-intra-smoothing=1:ctu=64:sao=0:cu-lossless=1:cutree=1:rskip=1:max-merge=3:rc-lookahead=60:aq-mode=1:aq-strength=1.1:rdoq-level=1:psy-rdoq=5.5:psy-rd=3.0:limit-modes=1:limit-refs=1:rd-refine=1:deblock=-2,-2:weightb=1:weightp=1:rect=1:amp=0:wpp=1:pmode=0:pme=0:b-intra=1:b-adapt=2:b-pyramid=1:tskip-fast=0:fast-intra=0:early-skip=0:min-keyint=24:keyint=240" +# merange is calculated as: ctu size - 4(luma) - 2(chroma) (- 1 if me=hex is used) +X265PARAMS="ref=4:me=star:bframes=6:rd=5:subme=6:merange=58:strong-intra-smoothing=0:ctu=64:sao=0:cu-lossless=1:cutree=1:rskip=1:max-merge=3:rc-lookahead=60:aq-mode=3:aq-strength=1.0:rdoq-level=1:psy-rdoq=5.5:psy-rd=3.0:limit-modes=1:limit-refs=1:rd-refine=1:deblock=-2,-2:weightb=1:weightp=1:rect=1:amp=0:wpp=1:pmode=0:pme=0:b-intra=1:b-adapt=2:b-pyramid=1:tskip-fast=0:fast-intra=0:early-skip=0:min-keyint=24:keyint=240" # Leave empty to auto-detect ffmpeg/ffprobe or # set your custom ones (eg, /path/to/bin/ffmpeg) @@ -131,7 +125,7 @@ EOF } -while getopts ":v :m: :c: :p: :t: :e :r :h" opt; do +while getopts ":v :b :e :r :h :m: :c: :p: :t:" opt; do case "$opt" in v) echo "$version" @@ -146,7 +140,10 @@ exit 1 ;; esac - mode="$OPTARG" + encmode="$OPTARG" + ;; + b) + batchmode="1" ;; c) if [ ! -f "$OPTARG" ]; then @@ -198,6 +195,10 @@ echo " 2p (2-pass mode)" echo " crf (constant rate factor mode)" echo + brown " -b" + echo " Activate batch encoding mode. This mode is used to encode" + echo " directories with video files in them." + echo brown " -c /path/to/file/preset.txt" echo " Load a custom preset file. An example 'preset.txt' file" echo " is included with the ffhevc package. This option can also" @@ -253,8 +254,8 @@ done if [ ! -z "$PRSTFILE" ]; then - if [ ! -z "$(grep '^X265PARAMS' "$PRSTFILE")" ]; then - if [ ! -z "$vpreset" -o ! -z "$vtune" ]; then + if [ ! -z "$vpreset" -o ! -z "$vtune" ]; then + if [ ! -z "$(grep '^X265PARAMS' "$PRSTFILE")" ]; then echo error "-> x265 presets/tune profiles are mutually exclusive with custom presets!" echo @@ -265,6 +266,19 @@ exit 1 fi fi +else + if [ -z "$vpreset" ]; then + if [ -f "$CFG" -a -z "$(grep '^X265PARAMS' "$CFG")" ]; then + echo + error "-> The X265PARAMS variable is commented out" + error " or missing from '$CFG'" + echo + error "-> Regenerating config file!" + rm -f "$CFG" + genconfig_func + echo + fi + fi fi brown " __ __ _" @@ -306,12 +320,14 @@ if [ ! -x "$FFMPEG" ]; then error "-> ffmpeg is missing from your system!" error "-> Check the config in '$CFG'" + echo exit 1 fi else FFMPEG="$(which ffmpeg 2>/dev/null)" if [ ! -x "$FFMPEG" ]; then error "-> ffmpeg is missing from your system!" + echo exit 1 fi fi @@ -320,127 +336,185 @@ if [ ! -x "$FFPROBE" ]; then error "-> ffprobe is missing from your system!" error "-> Check the config in '$CFG'" + echo exit 1 fi else FFPROBE="$(which ffprobe 2>/dev/null)" if [ ! -x "$FFPROBE" ]; then error "-> ffprobe is missing from your system!" + echo exit 1 fi fi -printf "Specify the Input File: " -read -e input +if [ -z "$OUTDIR" ]; then + error "-> OUTDIR is not set in the config file!" + error "-> Check your config in '$CFG'" + echo + exit 1 +else + mkdir -p "$OUTDIR" 2>/dev/null + if [ $? != 0 ]; then + error "-> Could not create the output directory!" + error "-> Check your config in '$CFG'" + echo + exit 1 + fi +fi + +if [ ! -z "$batchmode" ]; then + error "-> Note: batch mode is in effect!" + error "-> Be careful which settings you use as they will" + error " apply to all files and may cause problems!" + echo + printf "Specify a File from the Directory to Encode from: " + read -e input +else + printf "Specify the Input File: " + read -e input +fi + if [ ! -f "$input" ]; then error "-> No such file!" exit 1 fi -printf "Specify a Name for the Output: " -read -e output -if [ -z "$output" ]; then - error "-> You have to provide a name for the output!" - exit 1 +if [ ! -z "$batchmode" ]; then + OUTPUT="$OUTDIR/$(basename $0)_$$" + printf "Specify the Output Directory [default is $OUTPUT]: " + read -e output + test -z "$output" && OUTPUT="$OUTPUT/\$i" || OUTPUT="$output/\$i" + mkdir -p "$(dirname "$OUTPUT")" 2>/dev/null + if [ $? != 0 ]; then + error "-> Could not create the output directory!" + exit 1 + fi else + printf "Specify a Name for the Output: " + read -e output +fi + +if [ -z "$batchmode" ]; then + if [ -z "$output" ]; then + error "-> You have to provide a name for the output!" + exit 1 + fi if [ ! -z "$(echo "$output" | grep '/')" ]; then mkdir -p "$(dirname "$output")" 2>/dev/null if [ $? != 0 ]; then - error "-> Could not create output directory!" + error "-> Could not create the output directory!" exit 1 fi OUTPUT="$output" else OUTPUT="$OUTDIR/$output" fi - # Check if output dir is writable - WRITE="$(dirname "$OUTPUT")/.ff_writable$$" - touch "$WRITE" 2>/dev/null - if [ $? != 0 ]; then - error "-> Specified output directory is not writable by user '$(id -un)'" - exit 1 +fi + +# Check if output dir is writable +WRITE="$(dirname "$OUTPUT")/.ff_writable$$" +touch "$WRITE" 2>/dev/null +if [ $? != 0 ]; then + error "-> Specified output directory is not writable by user '$(id -un)'" + exit 1 +else + rm -f "$WRITE" +fi + +if [ -z "$CONFMT" ]; then + printf "Which Container Format to use? [default is mkv]: " + read confmt + test -z "$confmt" && CONFMT="mkv" || CONFMT="$confmt" +fi + +CONFMT="$(echo "$CONFMT" | tr '[:upper:]' '[:lower:]')" + +OUTPUT="$OUTPUT.$CONFMT" + +if [ -x "$(which realpath 2>/dev/null)" ]; then + if [ ! -z "$batchmode" ]; then + if [ "$(realpath -s "$(dirname "$input")")" = "$(realpath -s "$(dirname "$OUTPUT")")" ]; then + error "-> Input directory matches output directory!" + exit 1 + fi else - rm -f "$WRITE" - fi - - if [ -z "$CONFMT" ]; then - printf "Which Container Format to use? [default is mkv]: " - read confmt - test -z "$confmt" && CONFMT="mkv" || CONFMT="$confmt" - fi - - CONFMT="$(echo "$CONFMT" | tr '[:upper:]' '[:lower:]')" - - OUTPUT="$OUTPUT.$CONFMT" - - if [ -x "$(which realpath 2>/dev/null)" ]; then if [ "$(realpath -s "$input")" = "$(realpath -s "$OUTPUT")" ]; then error "-> Input file matches output file!" exit 1 fi fi - +fi + +if [ -z "$batchmode" ]; then if [ -e "$OUTPUT" ]; then echo error "-> Renaming existing file to '$OUTPUT.old'" echo mv -f "$OUTPUT" "$OUTPUT.old" fi - - case "$CONFMT" in - mp4|mov) movflags="-movflags +faststart" ;; - mkv|m2ts|mts|ts) true ;; - *) - error "-> HEVC video not supported by chosen container!" - error "-> Supported containers are: mkv, mp4, mov, m2ts, mts and ts" - error "-> Check your config file, if needed, in '$CFG'" - exit 1 - ;; - esac - - printf "Output to Additional Container Formats? [y/N]: " - read acf - if [ "$acf" = "y" -o "$acf" = "Y" ]; then - printf "Specify the Container Formats [example: mp4,mov,m2ts - press 'Enter' to skip]: " - read econ - test ! -z "$econ" && extracon="$(echo "$econ" | sed 's|,| |g' | tr '[:upper:]' '[:lower:]')" - if [ ! -z "$extracon" ]; then - container_func() { - case "$1" in - mp4|mov) - green "-> Note: additional container $i supports the following audio codecs:" - ;; - esac - case "$1" in - mp4) green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|copy|nosound" ;; - mov) green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|flac|copy|nosound" ;; - other) - error "-> HEVC video not supported by the $i container!" - error "-> Supported containers are: mkv, mp4, mov, m2ts, mts and ts" - echo - exit 1 - ;; - esac - } - - for i in $extracon; do - if [ "$i" = "$CONFMT" ]; then - error "-> Additional container matches the main output container!" - exit 1 - fi +else + OUTPUT="$(readlink -f "$(dirname "$OUTPUT")/\${i%.*}.$CONFMT")" + CHDIR="cd \"$(readlink -f "$(dirname "$input")")\"" + FORLOOP_START="for i in *; do" + CHKFILE_START="if [ -f \"\$i\" ]; then" + CHKFILE_END="fi" + FORLOOP_END="done" +fi + +METATITLE="-metadata title=\"$(basename "${OUTPUT%.*}")\" -metadata:s:v:0 title=\"$(basename "${OUTPUT%.*}")\"" + +case "$CONFMT" in + mp4|mov) movflags="-movflags +faststart" ;; + mkv|m2ts|mts|ts) true ;; + *) + error "-> HEVC video not supported by the chosen container!" + error "-> Supported containers are: mkv, mp4, mov, m2ts, mts and ts" + error "-> Check your config file, if needed, in '$CFG'" + exit 1 + ;; +esac + +printf "Output to Additional Container Formats? [y/N]: " +read acf +if [ "$acf" = "y" -o "$acf" = "Y" ]; then + printf "Specify the Container Formats [example: mp4,mov,m2ts - press 'Enter' to skip]: " + read econ + test ! -z "$econ" && extracon="$(echo "$econ" | sed 's|,| |g' | tr '[:upper:]' '[:lower:]')" + if [ ! -z "$extracon" ]; then + container_func() { + case "$1" in + mp4|mov) + green "-> Note: additional container $i supports the following audio codecs:" + ;; + esac + case "$1" in + mp4) green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|copy|nosound" ;; + mov) green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|flac|copy|nosound" ;; + other) + error "-> HEVC video not supported by the $i container!" + error "-> Supported containers are: mkv, mp4, mov, m2ts, mts and ts" echo - case "$i" in - mkv|m2ts|ts) green "-> Note: additional container $i supports all the audio codecs" ;; - mp4) container_func mp4 ;; - mov) container_func mov ;; - *) container_func other ;; - esac - done + exit 1 + ;; + esac + } + + for i in $extracon; do + if [ "$i" = "$CONFMT" ]; then + error "-> Additional container matches the main output container!" + exit 1 + fi echo - fi + case "$i" in + mkv|m2ts|ts) green "-> Note: additional container $i supports all the audio codecs" ;; + mp4) container_func mp4 ;; + mov) container_func mov ;; + *) container_func other ;; + esac + done + echo fi - - METATITLE="-metadata title=\"$(basename "${OUTPUT%.*}")\" -metadata:s:v:0 title=\"$(basename "${OUTPUT%.*}")\"" fi printf "Specify a Genre for the Content [press 'Enter' to skip]: " @@ -478,7 +552,7 @@ fi fi -case "$mode" in +case "$encmode" in [1-2]p) printf "Specify the desired Video Bitrate in kbps [default is 5000]: " read vbtr @@ -840,7 +914,7 @@ case "$infps" in 24/1|25/1|24000/1001|30000/1001) true ;; ""|*) - error "-> No value or unsupported value given!" + error "-> Unsupported or no value given!" exit 1 ;; esac @@ -984,10 +1058,16 @@ video_subtitles_func() { case "$1" in infile) - if [ "$MAX_SUBS" = "auto" ]; then - test "$SUBNR" = "0" && MAX_SUBS="1" || MAX_SUBS="$SUBNR" - fi - for i in $(eval echo "{1..$MAX_SUBS}"); do + printf "How many Subtitles to Copy?: " + read subcp + case "$subcp" in + [1-9]*) SUBCP="$subcp" ;; + ""|*) + error "-> Invalid or no value given!" + exit 1 + ;; + esac + for i in $(eval echo "{1..$SUBCP}"); do submapval[i]="$(($i-1))" printf "Sub $i: Specify a Subtitle to Copy [example: 0:2]: " read subnr[i] @@ -1035,15 +1115,15 @@ done fi printf "How many External Subtitles to Add?: " - read subamount - case "$subamount" in - [1-9]*) MAX_SUBS="$subamount" ;; + read subext + case "$subext" in + [1-9]*) SUBEXT="$subext" ;; ""|*) - error "-> Invalid value!" + error "-> Invalid or no value given!" exit 1 ;; esac - for i in $(eval echo "{1..$MAX_SUBS}"); do + for i in $(eval echo "{1..$SUBEXT}"); do test ! -z "${submapval[*]}" && submap[i]="$((${submapval[-1]}+$i))" || submap[i]="$(($i-1))" printf "Sub $i: Specify the Subtitle File: " read -e sub[i] @@ -1080,10 +1160,10 @@ echo green "$SUBSDETECT" echo + green "-> Detected $SUBNR subtitles" error "-> Note: not all containers support all types of subs!" else error "-> Could not detect any subtitles!" - SUBNR="0" fi echo if [ "$MAX_SUBS" = "auto" ]; then @@ -1691,7 +1771,7 @@ error " been disabled as it is incompatible with audio stream copy!" fi -case "$mode" in +case "$encmode" in [1-2]p) # Haven't found a reliable way to make it work with # FLAC and PCM audio so just skip this if one of @@ -1771,25 +1851,31 @@ esac } -case "$mode" in +case "$encmode" in 1p) pass="1-pass" ;; 2p) pass="2-pass" ;; - crf|"") pass="CRF"; mode="crf" ;; + crf|"") pass="CRF"; encmode="crf" ;; esac echo green "-> Starting to encode in $pass mode..." -green "-> Outputting to: $OUTPUT" +test -z "$batchmode" && OUT="$OUTPUT" || OUT="'$(dirname "$OUTPUT")' directory" +green "-> Outputting to: $OUT" echo color_func blue && printf "Starting to encode in: " && counter_func color_func normal && echo -OUTFILE="$(dirname "$OUTPUT")/$(basename "${OUTPUT%.*}" | sed 's| |_|g')" +if [ -z "$batchmode" ]; then + OUTFILE="$(dirname "$OUTPUT")/$(basename "${OUTPUT%.*}" | sed 's| |_|g')" +else + OUTFILE="$(dirname "$OUTPUT")/$(basename $0)_batch$$" + input="\$i" +fi encoder_func() { case "$1" in 1p|crf) - test "$mode" = "1p" && pmode="bitrate=$vbitrate" || pmode="crf=$CRF" + test "$encmode" = "1p" && pmode="bitrate=$vbitrate" || pmode="crf=$CRF" OPTS1="${EXTSUBS[*]} -map 0:0 -disposition:v:0 default $ofps $NOSUBS $MDATA $CHPS $METATITLE $METAGENRE $METAYEAR $METACOMMENT $vfilters $sws" OPTS2="${audparams[*]} ${auddis[*]} ${subcopy[*]} ${subcpy[*]} ${subdis[*]} ${subdispo[*]} $strict $movflags $METACOVER \"$OUTPUT\"" ;; @@ -1813,7 +1899,13 @@ echo "#!/usr/bin/env bash" > "$OUTFILE.sh" echo "" >> "$OUTFILE.sh" -encoder_func $mode >> "$OUTFILE.sh" +if [ ! -z "$batchmode" ]; then + echo "$CHDIR" >> "$OUTFILE.sh" + echo "" >> "$OUTFILE.sh" + echo "$FORLOOP_START" >> "$OUTFILE.sh" + echo "$CHKFILE_START" >> "$OUTFILE.sh" +fi +encoder_func $encmode >> "$OUTFILE.sh" echo "" >> "$OUTFILE.sh" if [ ! -z "$extracon" ]; then echo "grn() { echo -e \"\e[1;32m\$1\e[0;39;49m\"; }" >> "$OUTFILE.sh" @@ -1828,6 +1920,10 @@ done echo "echo" >> "$OUTFILE.sh" fi +if [ ! -z "$batchmode" ]; then + echo "$CHKFILE_END" >> "$OUTFILE.sh" + echo "$FORLOOP_END" >> "$OUTFILE.sh" +fi chmod +x "$OUTFILE.sh" source "$OUTFILE.sh"
View file
ffhevc-2.9.9.tar.gz/ffhevc.1 -> ffhevc-3.0.0.tar.gz/ffhevc.1
Changed
@@ -9,7 +9,7 @@ .SH SYNOPSIS .B ffhevc -[\-m <mode>] [\-p <preset>] [\-t <tune>] [\-v|\-e|\-r|\-h] [\-c <preset/config file>] +[\-m <mode>] [\-p <preset>] [\-t <tune>] [\-b|\-v|\-e|\-r|\-h] [\-c <preset/config file>] .br .SH DESCRIPTION @@ -43,6 +43,10 @@ .RE . .TP +.B -b +Activate batch encoding mode. This mode is used to encode directories +with video files in them. +.TP .B -c /path/to/file/preset.txt Load a custom preset file. The package includes an example preset file. This option can also be used to load a custom configuration file instead
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.