Skip to content

Commit

Permalink
Added option to force video level
Browse files Browse the repository at this point in the history
  • Loading branch information
xzKinGzxBuRnzx committed Aug 20, 2018
1 parent 2110e05 commit e977b57
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
21 changes: 17 additions & 4 deletions M4V-Converter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
# NOTE: https://trac.ffmpeg.org/wiki/Encode/H.264#Compatibility
#Level=4.1

# Force Video Level (true, false).
# This forces video level to the specified setting above.
#Force Level=false

# Video Constant Rate Factor (0-51).
# This controls maximum compression efficiency with a single pass.
#
Expand All @@ -99,7 +103,7 @@
# File/Directory Rename (true, false).
# This will rename the file/directory when resolution is changed.
#
# NOTE: Ex. movie.'Video.2018.4K.UHD.King' to 'Video.2018.1080p.King' (when using the above Video Resolution option)
# NOTE: Ex. 'Video.2018.4K.UHD.King' to 'Video.2018.1080p.King' (when using the above Video Resolution option)
#
# NOTE: You must allow the script to run as a global extension (applies to all nzbs in queue) for this to work on NZBGet.
#Rename=true
Expand Down Expand Up @@ -299,6 +303,7 @@ while getopts hvdi:o:c:b-: opts; do
preset=*) CONF_PRESET="${ARG}" ;;
profile=*) CONF_PROFILE="${ARG}" ;;
level=*) CONF_LEVEL="${ARG}" ;;
force-level=*) CONF_FORCE_LEVEL="${ARG}" ;;
crf=*) CONF_CRF="${ARG}" ;;
resolution=*) CONF_RESOLUTION="${ARG}" ;;
rename=*) CONF_RENAME="${ARG}" ;;
Expand Down Expand Up @@ -419,8 +424,8 @@ CONF_ENCODER=${CONF_ENCODER:-${NZBPO_ENCODER:-${ENCODER}}}
: "${CONF_ENCODER:=H.264}"
CONF_ENCODER=${CONF_ENCODER,,}
case "${CONF_ENCODER}" in
h.264|[h|x]264|libx264) CONF_ENCODER_NAME="h264"; CONF_ENCODER="libx264" ;;
h.265|[h|x]265|hevc|libx265) CONF_ENCODER_NAME="hevc"; CONF_ENCODER="libx265" ;;
h.264|h264|x264|libx264) CONF_ENCODER_NAME="h264"; CONF_ENCODER="libx264" ;;
h.265|h265|x265|hevc|libx265) CONF_ENCODER_NAME="hevc"; CONF_ENCODER="libx265" ;;
"*") ;;
*) echo "Encoder is incorrectly configured"; exit ${CONFIG} ;;
esac
Expand Down Expand Up @@ -449,6 +454,14 @@ case "${CONF_LEVEL}" in
*) echo "Level is incorrectly configured"; exit ${CONFIG} ;;
esac

CONF_FORCE_LEVEL=${CONF_FORCE_LEVEL:-${NZBPO_FORCE_LEVEL:-${FORCE_LEVEL}}}
: "${CONF_FORCE_LEVEL:=false}"
CONF_FORCE_LEVEL=${CONF_FORCE_LEVEL,,}
case "${CONF_FORCE_LEVEL}" in
true|false) ;;
*) echo "Force Level is incorrectly configured"; exit ${CONFIG} ;;
esac

CONF_CRF=${CONF_CRF:-${NZBPO_CRF:-${CRF}}}
case "${CONF_ENCODER_NAME}" in
h264) : "${CONF_CRF:=23}" ;;
Expand Down Expand Up @@ -970,7 +983,7 @@ for valid in "${VALID[@]}"; do
level=false
if [[ "${CONF_LEVEL}" != "*" ]] && [[ "${CONF_ENCODER_NAME}" == "h264" ]]; then
videolevel=$(echo "${videodata}" | grep -x 'level=.*' | sed -E 's/[^0-9]//g')
if (( videolevel < 30 )) || (( videolevel > ${CONF_LEVEL//./} )); then
if ${CONF_FORCE_LEVEL} || (( videolevel < 30 )) || (( videolevel > ${CONF_LEVEL//./} )); then
convert=true
level=true
fi
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ advanced optional arguments: (Use ONLY if you know what you are doing)
This is another form of constraints that define things like maximum bitrates, framerates and resolution etc.
NOTE: Selecting "*" will disable this check.
NOTE: https://trac.ffmpeg.org/wiki/Encode/H.264#Compatibility
--force-level=[false,true]
This forces video level to the specified setting above.
--crf=[0-51]
This controls maximum compression efficiency with a single pass.
NOTE: https://trac.ffmpeg.org/wiki/Encode/H.264#crf
Expand Down Expand Up @@ -176,4 +178,4 @@ Useful links:
- http://ffmpeg.org/documentation.html
- https://trac.ffmpeg.org/wiki

Enjoy
Enjoy
6 changes: 5 additions & 1 deletion default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ PROFILE=main
# NOTE: https://trac.ffmpeg.org/wiki/Encode/H.264#Compatibility
LEVEL=4.1

# Force Video Level (true, false).
# This forces video level to the specified setting above.
FORCE_LEVEL=false

# Video Constant Rate Factor (0-51).
# This controls maximum compression efficiency with a single pass.
#
Expand Down Expand Up @@ -157,4 +161,4 @@ DIRECTORY_PERMISSION=
# These are the processes background mode will look for and auto-pause any active converting if found.
#
# NOTE: Use quotes when specifying more than one process. Ex. "ffmpeg, Plex Transcoder"
PROCESSES="ffmpeg"
PROCESSES="ffmpeg"

0 comments on commit e977b57

Please sign in to comment.