Projects
Multimedia
ffhevc
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 9
View file
ffhevc.changes
Changed
@@ -1,4 +1,25 @@ ------------------------------------------------------------------- +Sun Nov 06 09:52:00 UTC 2016 - neutrino8@opensuse.org + +- Update to version 2.9.4 + * Bugfix: resampling wasn't working for fdk-aac due to missing + value in the case statement + * Check if output file exists and if so, move it to $file.old + * Use test directly instead of an if condition to set the audio + filters + * Support bitrate calculations for target file size when doing + audio copy + * Use fdk* in the case statements for easier typing + * Renamed variable astrm to astream for clarity + * Use [1-2]p in the case statements for passmodes instead of 1p|2p + * New function, video_field_parity_func(), to detect and report the + interlace field order. Used by motion-compensation deinterlacing + and interlaced encoding + * Detect and display audio sample rate in case resampling is chosen + * Improvements to the video_fps_func() function. Get the FPS value + directly instead of outputting to a file and reading it + +------------------------------------------------------------------- Sat Nov 05 10:56:00 UTC 2016 - neutrino8@opensuse.org - Update to version 2.9.3
View file
ffhevc.spec
Changed
@@ -17,7 +17,7 @@ Name: ffhevc -Version: 2.9.3 +Version: 2.9.4 Release: 0 Summary: A small shell script for encoding to H.265/HEVC with ffmpeg License: GPL-2.0+
View file
ffhevc-2.9.3.tar.gz/AUTHORS -> ffhevc-2.9.4.tar.gz/AUTHORS
Changed
@@ -1,3 +1,3 @@ -- Grozdan Nikolov aka microchip <neutrino8@gmail.com> +- Grozdan Nikolov aka microchip <neutrino8@opensuse.org> Author/maintainer/developer/packager
View file
ffhevc-2.9.3.tar.gz/ChangeLog -> ffhevc-2.9.4.tar.gz/ChangeLog
Changed
@@ -1,3 +1,21 @@ +2016-11-06 - ffhevc 2.9.4 + * Bugfix: resampling wasn't working for fdk-aac due to missing + value in the case statement + * Check if output file exists and if so, move it to $file.old + * Use test directly instead of an if condition to set the audio + filters + * Support bitrate calculations for target file size when doing + audio copy + * Use fdk* in the case statements for easier typing + * Renamed variable astrm to astream for clarity + * Use [1-2]p in the case statements for passmodes instead of 1p|2p + * New function, video_field_parity_func(), to detect and report the + interlace field order. Used by motion-compensation deinterlacing + and interlaced encoding + * Detect and display audio sample rate in case resampling is chosen + * Improvements to the video_fps_func() function. Get the FPS value + directly instead of outputting to a file and reading it + 2016-11-05 - ffhevc 2.9.3 * Use a single var, $ofps, to set the output FPS for both deinterlace bobbing and FPS conversion
View file
ffhevc-2.9.3.tar.gz/ffhevc -> ffhevc-2.9.4.tar.gz/ffhevc
Changed
@@ -1,16 +1,16 @@ #!/usr/bin/env bash # # Small script to encode to H.265/HEVC video using FFmpeg and libx265. -# Author: Grozdan "microchip" Nikolov <neutrino8@gmail.com> -# Version: 2.9.3 -# Date: 2016-11-05 +# Author: Grozdan "microchip" Nikolov <neutrino8@opensuse.org> +# Version: 2.9.4 +# Date: 2016-11-06 # License: GNU GPLv2+ green() { echo -e "\e[1;32m$1\e[0;39;49m"; } 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.3" +version="2.9.4" CFG="$HOME/.ffhevc" cfgversion="28" @@ -126,7 +126,7 @@ ;; m) case "$OPTARG" in - 1p|2p|crf) true ;; + [1-2]p|crf) true ;; *) error "-> Invalid mode!" error "-> Use: $(basename $0) -h" @@ -362,6 +362,8 @@ OUTPUT="$OUTPUT.$CON" + test -e "$OUTPUT" && mv -f "$OUTPUT" "$OUTPUT.old" + METATITLE="-metadata title=\"$(basename "${OUTPUT%.*}")\" -metadata:s:v:0 title=\"$(basename "${OUTPUT%.*}")\"" fi @@ -401,7 +403,7 @@ fi case "$mode" in - 1p|2p) + [1-2]p) printf "Specify the desired Video Bitrate in kbps [default is 5000]: " read vbtr test -z "$vbtr" && vbitrate="5000" || vbitrate="$vbtr" @@ -510,8 +512,32 @@ # Used by mc deinterlace and FPS conversion video_fps_func() { - FPSOUT="$(dirname "$OUTPUT")/.ff_fps$$" - $FFPROBE -i "$input" -select_streams v:0 -show_entries stream=r_frame_rate > "$FPSOUT" 2>&1 + GETFPS="$($FFPROBE -i "$input" -select_streams v:0 -show_entries stream=r_frame_rate 2>&1 | sed -n 's|^r_frame_rate=||p')" +} + +# Used by mc deinterlace and interlace-aware encoding +video_field_parity_func() { + echo + green "-> Detecting Field Parity..." + FPAR="$($FFPROBE -i "$input" -show_streams -select_streams v:0 -show_frames -read_intervals %+7 2>&1 | sed -n 's|^field_order=||p' | tail -1)" + case "$FPAR" in + t*|T*) fp="tff"; fparity="Top Field First (TFF)" ;; + b*|B*) fp="bff"; fparity="Bottom Field First (BFF)" ;; + p*|P*) fp="progressive"; fparity="Progressive" ;; + ""|*) fp="???"; fparity="???" ;; + esac + green "-> Detected $fparity Parity" + if [ "$fp" = "progressive" ]; then + error "-> Your file appears to be progressive but" + error " this may be a misdetection!" + elif [ "$fp" = "???" ]; then + error "-> Could not detect the Field Parity!" + fi + echo + case "$fp" in + bff) defpar="bff" ;; + *) defpar="tff" ;; + esac } if [ "$VID_DEINTERLACE" = "y" ]; then @@ -519,16 +545,10 @@ printf "Use Motion-Compensation Deinterlacing? [y/N]: " read mcd if [ "$mcd" = "y" -o "$mcd" = "Y" ]; then - printf "Specify the Field Parity of the Input File [tff/bff - default is tff]: " + video_field_parity_func + printf "Specify the Field Parity of the Input File [tff/bff - default is $defpar]: " read par - case "$par" in - t*|T*|"") fpar="tff" ;; - b*|B*) fpar="bff" ;; - *) - error "-> Invalid option!" - exit 1 - ;; - esac + test -z "$par" && fpar="$defpar" || fpar="$par" fi case "$1" in ofps) test ! -z "$fpar" && deinterlace="yadif=1,mcdeint=mode=medium:parity=$fpar:qp=10,framestep=step=2," || deinterlace="yadif=0," ;; @@ -550,16 +570,22 @@ case "$dmethod" in 0|"") video_deinterlace_func ofps ;; 1) - video_fps_func - FPS1="$(cat "$FPSOUT" | sed -n 's|r_frame_rate=||p' | awk -F/ '{print $1}')" - FPS2="$(cat "$FPSOUT" | sed -n 's|r_frame_rate=||p' | awk -F/ '{print $2}')" - OFPS="$(($FPS1*2))/$FPS2" - rm -f "$FPSOUT" - echo - green "-> Detected $FPS1/$FPS2 FPS" - green "-> Setting output FPS to: $OFPS" echo - ofps="-r $OFPS" + green "-> Detecting FPS value..." + sleep 1 + video_fps_func + if [ ! -z "$GETFPS" ]; then + FPS1="$(echo "$GETFPS" | awk -F/ '{print $1}')" + FPS2="$(echo "$GETFPS"| awk -F/ '{print $2}')" + OFPS="$(($FPS1*2))/$FPS2" + green "-> Detected: $FPS1/$FPS2 FPS" + green "-> Setting output FPS to: $OFPS" + echo + ofps="-r $OFPS" + else + error "-> Could not detect the FPS value!" + echo + fi video_deinterlace_func bob bob="1" ;; @@ -604,16 +630,10 @@ printf "Enable Interlace-aware encoding? [y/N]: " read intaw if [ "$intaw" = "y" -o "$intaw" = "Y" ]; then - printf "Specify the Field Parity of the Input File [tff/bff - default is tff]: " + video_field_parity_func + printf "Specify the Field Parity of the Input File [tff/bff - default is $defpar]: " read parity - case "$parity" in - t*|T*|"") interlaced=":interlace=tff" ;; - b*|B*) interlaced=":interlace=bff" ;; - *) - error "-> Invalid option!" - exit 1 - ;; - esac + test -z "$parity" && interlaced=":interlaced=$defpar" || interlaced=":interlaced=$parity" X265PARAMS="$X265PARAMS$interlaced" fi fi @@ -621,7 +641,7 @@ if [ "$AUTOCROP" = "y" ]; then echo green "-> Detecting crop values..." - VDUR="$($FFPROBE -i "$input" -select_streams v:0 -show_format 2>&1 | sed -n 's|duration=||p' | awk -F. '{print $1}')" + VDUR="$($FFPROBE -i "$input" -select_streams v:0 -show_format 2>&1 | sed -n 's|^duration=||p' | awk -F. '{print $1}')" CROPVAL="$($FFMPEG -ss $(($VDUR/2)) -i "$input" -map 0:0 -vf cropdetect=24:4 -frames:v 1000 -f null - 2>&1 | awk '/crop/ {print $NF}' | awk -F= '{print $2}' | tail -1)" if [ ! -z "$CROPVAL" ]; then green "-> Found crop values: $CROPVAL" @@ -729,12 +749,14 @@ green "-> Detecting FPS value..." sleep 1 video_fps_func - FPS="$(cat "$FPSOUT" | sed -n 's|r_frame_rate=||p')" - rm -f "$FPSOUT" - green "-> Detected: $FPS FPS" - case "$FPS" in + if [ ! -z "$GETFPS" ]; then + green "-> Detected: $GETFPS FPS" + else + error "-> Could not detect the FPS value!" + fi + case "$GETFPS" in 24/1|25/1|24000/1001|30000/1001) true ;; - *) + ""|*) echo error "-> Detected FPS is not supported yet!" error "-> Supported FPS are: 24/1, 25/1, 24000/1001 and 30000/1001" @@ -948,11 +970,11 @@ defaudtrk="press 'Enter' to skip" fi printf "Track $i: Specify the Audio Track to Encode or Copy [$defaudtrk]: " - read astrm[i] - if [ -z "${astrm[1]}" -a "$ATRKS" != "0" ]; then - astrm[1]="0:1" + read astream[i] + if [ -z "${astream[1]}" -a "$ATRKS" != "0" ]; then + astream[1]="0:1" fi - if [ ! -z "${astrm[i]}" ]; then + if [ ! -z "${astream[i]}" ]; then printf "Track $i: Specify the 3-letter Language Code for Metadata [press 'Enter' to skip]: " read alang[i] if [ ! -z "${alang[i]}" ]; then @@ -961,7 +983,7 @@ fi done -test -z "$(echo "${astrm[*]}" | sed 's| ||g')" && audparams[1]="-an" +test -z "$(echo "${astream[*]}" | sed 's| ||g')" && audparams[1]="-an" if [ "${audparams[1]}" != "-an" ]; then echo @@ -982,9 +1004,9 @@ fi for i in $(eval echo "{1..$MAX_AUD_TRACKS}"); do - if [ ! -z "${astrm[i]}" ]; then + if [ ! -z "${astream[i]}" ]; then echo - audmap[i]="-map ${astrm[i]}" + audmap[i]="-map ${astream[i]}" # Workaround for an ffmpeg disposition issue # where in some cases it flags subsequent @@ -1021,7 +1043,7 @@ abropts[i]="32-512" abrdef[i]="448" ;; - fdk-aac) + fdk*) acdc[i]="libfdk_aac" abropts[i]="8-512" abrdef[i]="448" @@ -1055,7 +1077,6 @@ ;; copy) acdc[i]="copy" - skiptfs="1" # FPS conversion is incompatible with audio stream copy for # obvious reasons. We can't speed up or slow down audio that's # being copied. Audio filters have no effect on stream copy. @@ -1114,7 +1135,8 @@ if [ "${acodec[i]}" != "copy" ]; then if [ "${acodec[i]}" != "flac" ]; then if [ "${acodec[i]}" != "pcm" ]; then - if [ "${acodec[i]}" = "fdk-aac" ]; then + case "${acodec[i]}" in + fdk*) printf "Track $i: Which AAC Profile to Use? [LC/HE/HEv2 - default is LC]: " read aprof[i] case "${aprof[i]}" in @@ -1127,8 +1149,8 @@ ;; esac audprofile[i]="-profile:a:${audmapval[i]} ${aacprof[i]} -afterburner:a:${audmapval[i]} 1" - - fi + ;; + esac printf "Track $i: Specify the Audio Bitrate in kbps [${abropts[i]} - default is ${abrdef[i]}]: " read abr[i] test -z "${abr[i]}" && abitrate[i]="${abrdef[i]}k" || abitrate[i]="${abr[i]}k" @@ -1155,7 +1177,7 @@ ac3|eac3|dts|"") chanrange[i]="1-6"; defchan[i]="6" ;; aac|opus|vorbis|flac|pcm) chanrange[i]="1-8"; defchan[i]="8" ;; mp3) chanrange[i]="1-2"; defchan[i]="2" ;; - fdk-aac) + fdk*) case "${aacprof[i]}" in aac_low|aac_he) chanrange[i]="1-8"; defchan[i]="8" ;; *) chanrange[i]="1-2"; defchan[i]="2" ;; @@ -1201,7 +1223,7 @@ ;; esac ;; - fdk-aac) + fdk*) case "${aacprof[i]}" in aac_he_v2) case "${ach[i]}" in @@ -1251,9 +1273,19 @@ printf "Track $i: Resample the Audio? [y/N]: " read ares[i] if [ "${ares[i]}" = "y" -o "${ares[i]}" = "Y" ]; then + echo + green "-> Track $i: detecting audio sample rate..." + sleep 1 + aid[i]="$(($(echo "${astream[i]}" | awk -F: '{print $2}')-1))" + ASR[i]="$($FFPROBE -i "$input" -show_streams -select_streams a:${aid[i]} 2>&1 | sed -n 's|^sample_rate=||p')" + if [ ! -z "${ASR[i]}" ]; then + green "-> Track $i: detected ${ASR[i]} Hz" + else + error "-> Track $i: could not detect the audio sample rate!" + fi + echo case "${acodec[i]}" in mp3|ac3|eac3|dts|"") - echo brown " Supported Sample Rates" brown " ~~~~~~~~~~~~~~~~~~~~~~" echo " 0 -> 32000 Hz" @@ -1272,8 +1304,7 @@ ;; esac ;; - aac|flac) - echo + aac|fdk*|flac) brown " Supported Sample Rates" brown " ~~~~~~~~~~~~~~~~~~~~~~" echo " 0 -> 8000 Hz 5 -> 24000 Hz 10 -> 88200 Hz" @@ -1304,7 +1335,6 @@ esac ;; opus) - echo brown " Supported Sample Rates" brown " ~~~~~~~~~~~~~~~~~~~~~~" echo " 0 -> 8000 Hz 5 -> 24000 Hz" @@ -1332,7 +1362,6 @@ esac ;; vorbis|pcm) - echo brown " Supported Sample Rates" brown " ~~~~~~~~~~~~~~~~~~~~~~" echo " 0 -> 8000 Hz 5 -> 24000 Hz 10 -> 88200 Hz" @@ -1370,9 +1399,9 @@ fi afilters[i]="$(echo "${aresample[i]}${anormalize[i]}${avolume[i]}$atempo" | sed 's|,$||')" - if [ ! -z "${afilters[i]}" ]; then - audfilters[i]="-filter:a:${audmapval[i]} ${afilters[i]}" - fi + + test ! -z "${afilters[i]}" && audfilters[i]="-filter:a:${audmapval[i]} ${afilters[i]}" + fi audparams[i]="${audmap[i]} -c:a:${audmapval[i]} ${acdc[i]} ${audprofile[i]} ${audbtr[i]} ${audchan[i]} ${audfilters[i]} ${audlang[i]} ${audmeta[i]}" @@ -1386,10 +1415,10 @@ fi case "$mode" in - 1p|2p) + [1-2]p) # Haven't found a reliable way to make it work with - # FLAC, PCM and Copy audio so just skip this if one - # of these audio options are chosen. Patch welcome + # FLAC and PCM audio so just skip this if one of + # these audio codecs is chosen. Patch welcome if [ -z "$skiptfs" ]; then echo printf "Set a Target File Size? [y/N]: " @@ -1398,12 +1427,23 @@ printf "Specify the Target File Size in MiB [default is 5120]: " read tsize test -z "$tsize" && target="5120" || target="$tsize" - VLENGTH="$($FFPROBE -i "$input" -select_streams v:0 -show_format 2>&1 | sed -n 's|duration=||p' | awk -F. '{print $1}')" + VLENGTH="$($FFPROBE -i "$input" -select_streams v:0 -show_format 2>&1 | sed -n 's|^duration=||p' | awk -F. '{print $1}')" if [ -z "$VLENGTH" ]; then echo error "-> Could not detect video length!" error "-> Skipping bitrate calculation!" else + # Audio copy, get bitrate + for i in $(eval echo "{1..$MAX_AUD_TRACKS}"); do + if [ "${acodec[i]}" = "copy" ]; then + aid[i]="$(($(echo "${astream[i]}" | awk -F: '{print $2}')-1))" + abtr[i]="$($FFPROBE -i "$input" -show_streams -select_streams a:${aid[i]} 2>&1 | sed -n 's|^bit_rate=||p')" + case "${abtr[i]}" in + [1-9]*) abitrate[i]="$((${abtr[i]}/1000))" ;; + ""|*) abitrate[i]="0" ;; + esac + fi + done AUDBTR="$(($(echo "${abitrate[*]}" | sed 's|k||g; s| |+|g')))" VBITRATE="$((($target*8192/$VLENGTH)-$AUDBTR))" echo
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
.