Projects
Multimedia
ffx264
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 17
View file
ffx264.changes
Changed
@@ -1,4 +1,20 @@ ------------------------------------------------------------------- +Sun Nov 13 11:36:00 UTC 2016 - neutrino8@opensuse.org + +- Update to version 3.1.6 + * 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 + * 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 26 + * Check if the X264PARAMS var is missing from config in case we're + not using an x264 preset + * Updated the man page + +------------------------------------------------------------------- Sat Nov 12 10:48:00 UTC 2016 - neutrino8@opensuse.org - Update to version 3.1.5
View file
ffx264.spec
Changed
@@ -17,7 +17,7 @@ Name: ffx264 -Version: 3.1.5 +Version: 3.1.6 Release: 0 Summary: A small shell script for encoding to H.264 with ffmpeg License: GPL-2.0+
View file
ffx264-3.1.5.tar.gz/ChangeLog -> ffx264-3.1.6.tar.gz/ChangeLog
Changed
@@ -1,3 +1,16 @@ +2016-11-13 - ffx264 3.1.6 + * 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 + * 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 26 + * Check if the X264PARAMS var is missing from config in case we're + not using an x264 preset + * Updated the man page + 2016-11-12 - ffx264 3.1.5 * Added support for importing external srt/ssa subtitles for the mkv, m2ts, mts and ts containers
View file
ffx264-3.1.5.tar.gz/ffx264 -> ffx264-3.1.6.tar.gz/ffx264
Changed
@@ -2,8 +2,8 @@ # # Small script to encode to H.264/AVC video using FFmpeg and libx264. # Author: Grozdan "microchip" Nikolov <neutrino8@opensuse.org> -# Version: 3.1.5 -# Date: 2016-11-12 +# Version: 3.1.6 +# Date: 2016-11-13 # # ffx264 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="3.1.5" +version="3.1.6" CFG="$HOME/.ffx264" -cfgversion="25" +cfgversion="26" 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" @@ -130,7 +124,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" @@ -145,7 +139,10 @@ exit 1 ;; esac - mode="$OPTARG" + encmode="$OPTARG" + ;; + b) + batchmode="1" ;; c) if [ ! -f "$OPTARG" ]; then @@ -197,6 +194,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 ffx264 package. This option can also" @@ -254,8 +255,8 @@ done if [ ! -z "$PRSTFILE" ]; then - if [ ! -z "$(grep '^X264PARAMS' "$PRSTFILE")" ]; then - if [ ! -z "$vpreset" -o ! -z "$vtune" ]; then + if [ ! -z "$vpreset" -o ! -z "$vtune" ]; then + if [ ! -z "$(grep '^X264PARAMS' "$PRSTFILE")" ]; then echo error "-> x264 presets/tune profiles are mutually exclusive with custom presets!" echo @@ -266,6 +267,19 @@ exit 1 fi fi +else + if [ -z "$vpreset" ]; then + if [ -f "$CFG" -a -z "$(grep '^X264PARAMS' "$CFG")" ]; then + echo + error "-> The X264PARAMS variable is commented out" + error " or missing from '$CFG'" + echo + error "-> Regenerating config file!" + rm -f "$CFG" + genconfig_func + echo + fi + fi fi brown " __ __ ____ __ _ _ " @@ -307,12 +321,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 @@ -321,139 +337,197 @@ 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 - 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" +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 [ -x "$(which realpath 2>/dev/null)" ]; then +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 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|m4v|mov) movflags="-movflags +faststart" ;; - avi|m2ts|mts|ts) annexb="-bsf:v h264_mp4toannexb" ;; - mkv|flv) true ;; - *) - error "-> H.264 video not supported by chosen container!" - error "-> Supported containers are: mkv, mp4, mov, m4v, m2ts, mts, ts, flv and avi" - 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,m2ts,mov - 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|m4v|avi|flv) - 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" ;; - m4v) green "-> ac3|aac|fdk-aac|copy|nosound" ;; - avi) green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|pcm|flac|copy|nosound" ;; - flv) green "-> aac|fdk-aac|mp3|copy|nosound" ;; - other) - error "-> H.264 video not supported by the $i container!" - error "-> Supported containers are: mkv, mp4, mov, m4v, m2ts, mts, ts, flv and avi" - 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|m4v|mov) movflags="-movflags +faststart" ;; + avi|m2ts|mts|ts) annexb="-bsf:v h264_mp4toannexb" ;; + mkv|flv) true ;; + *) + error "-> H.264 video not supported by the chosen container!" + error "-> Supported containers are: mkv, mp4, mov, m4v, m2ts, mts, ts, flv and avi" + 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,m2ts,mov - 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|m4v|avi|flv) + 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" ;; + m4v) green "-> ac3|aac|fdk-aac|copy|nosound" ;; + avi) green "-> ac3|eac3|dts|aac|fdk-aac|mp3|vorbis|pcm|flac|copy|nosound" ;; + flv) green "-> aac|fdk-aac|mp3|copy|nosound" ;; + other) + error "-> H.264 video not supported by the $i container!" + error "-> Supported containers are: mkv, mp4, mov, m4v, m2ts, mts, ts, flv and avi" echo - case "$i" in - mkv|m2ts|mts|ts) - green "-> Note: additional container $i supports all the audio codecs" - ;; - flv) - container_func flv - error "-> Note: you may need to resample the audio to 44100, 22050 or 11025 Hz!" - ;; - mp4) container_func mp4 ;; - mov) container_func mov ;; - m4v) container_func m4v ;; - avi) container_func avi ;; - *) 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|mts|ts) + green "-> Note: additional container $i supports all the audio codecs" + ;; + flv) + container_func flv + error "-> Note: you may need to resample the audio to 44100, 22050 or 11025 Hz!" + ;; + mp4) container_func mp4 ;; + mov) container_func mov ;; + m4v) container_func m4v ;; + avi) container_func avi ;; + *) 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]: " @@ -491,7 +565,7 @@ fi fi -case "$mode" in +case "$encmode" in [1-2]p) printf "Specify the desired Video Bitrate in kbps [default is 8000]: " read vbtr @@ -854,7 +928,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 @@ -998,10 +1072,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] @@ -1049,15 +1129,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] @@ -1094,18 +1174,12 @@ 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 - error "-> Note: MAX_SUBS variable is set to \"auto\" in the config file!" - error "-> This means it will ask for as many as detected subtitle tracks" - error " and you cannot skip them!" - echo - fi brown " Subtitles" brown " ~~~~~~~~~" echo " 0 -> Copy subtitles from the input file" @@ -1721,7 +1795,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 @@ -1801,25 +1875,32 @@ 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 $annexb $NOSUBS $MDATA $CHPS $METATITLE $METAGENRE $METAYEAR $METACOMMENT $vfilters $sws" OPTS2="${audparams[*]} ${auddis[*]} ${subcopy[*]} ${subcpy[*]} ${subdis[*]} ${subdispo[*]} $strict $movflags $METACOVER \"$OUTPUT\"" ;; @@ -1843,7 +1924,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" @@ -1861,6 +1948,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
ffx264-3.1.5.tar.gz/ffx264.1 -> ffx264-3.1.6.tar.gz/ffx264.1
Changed
@@ -9,7 +9,7 @@ .SH SYNOPSIS .B ffx264 -[\-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
.