Skip to content

Commit

Permalink
Added --re-encode-audio option, see #31
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed May 2, 2024
1 parent e843fc0 commit 3f9f5d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = cleanvid
version = 1.5.6
version = 1.5.7
author = Seth Grover
author_email = mero.mero.guero@gmail.com
description = cleanvid is a little script to mute profanity in video files.
Expand Down
2 changes: 1 addition & 1 deletion src/cleanvid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""cleanvid is a little script to mute profanity in video files."""

__version__ = "1.5.6"
__version__ = "1.5.7"
__author__ = "Seth Grover <mero.mero.guero@gmail.com>"
__all__ = []

Expand Down
36 changes: 25 additions & 11 deletions src/cleanvid/cleanvid.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ def ExtractSubtitles(vidFileSpec, srtLanguage):
subFileSpec = ""
srtLanguage, srtForceIndex = SplitLanguageIfForced(srtLanguage)
if (streamInfo := GetStreamSubtitleMap(vidFileSpec)) and (
stream := next(iter([k for k, v in streamInfo.items() if (v == srtLanguage)]), None)
if not srtForceIndex
else srtForceIndex
stream := (
next(iter([k for k, v in streamInfo.items() if (v == srtLanguage)]), None)
if not srtForceIndex
else srtForceIndex
)
):
subFileParts = os.path.splitext(vidFileSpec)
subFileSpec = subFileParts[0] + "." + srtLanguage + ".srt"
Expand Down Expand Up @@ -195,7 +197,8 @@ class VidCleaner(object):
subsOnly = False
edl = False
hardCode = False
reEncode = False
reEncodeVideo = False
reEncodeAudio = False
unalteredVideo = False
subsLang = SUBTITLE_DEFAULT_LANG
vParams = VIDEO_DEFAULT_PARAMS
Expand Down Expand Up @@ -223,7 +226,8 @@ def __init__(
edl=False,
jsonDump=False,
subsLang=SUBTITLE_DEFAULT_LANG,
reEncode=False,
reEncodeVideo=False,
reEncodeAudio=False,
hardCode=False,
vParams=VIDEO_DEFAULT_PARAMS,
aParams=AUDIO_DEFAULT_PARAMS,
Expand Down Expand Up @@ -262,7 +266,8 @@ def __init__(
self.jsonDumpList = [] if jsonDump else None
self.plexAutoSkipJson = plexAutoSkipJson
self.plexAutoSkipId = plexAutoSkipId
self.reEncode = reEncode
self.reEncodeVideo = reEncodeVideo
self.reEncodeAudio = reEncodeAudio
self.hardCode = hardCode
self.subsLang = subsLang
self.vParams = vParams
Expand Down Expand Up @@ -496,8 +501,14 @@ def MultiplexCleanVideo(self):
# - we are hard-coding (burning) subs
# - we are embedding a subtitle stream
# - we are not doing "subs only" or EDL mode and there more than zero mute sections
if self.reEncode or self.hardCode or self.embedSubs or ((not self.subsOnly) and (len(self.muteTimeList) > 0)):
if self.reEncode or self.hardCode:
if (
self.reEncodeVideo
or self.reEncodeAudio
or self.hardCode
or self.embedSubs
or ((not self.subsOnly) and (len(self.muteTimeList) > 0))
):
if self.reEncodeVideo or self.hardCode:
if self.hardCode and os.path.isfile(self.cleanSubsFileSpec):
self.assSubsFileSpec = self.cleanSubsFileSpec + '.ass'
subConvCmd = f"ffmpeg -hide_banner -nostats -loglevel error -y -i {self.cleanSubsFileSpec} {self.assSubsFileSpec}"
Expand Down Expand Up @@ -622,7 +633,8 @@ def RunCleanvid():
dest='json',
action='store_true',
)
parser.add_argument('-r', '--re-encode', help='Re-encode video', dest='reEncode', action='store_true')
parser.add_argument('--re-encode-video', help='Re-encode video', dest='reEncodeVideo', action='store_true')
parser.add_argument('--re-encode-audio', help='Re-encode audio', dest='reEncodeAudio', action='store_true')
parser.add_argument(
'-b', '--burn', help='Hard-coded subtitles (implies re-encode)', dest='hardCode', action='store_true'
)
Expand All @@ -644,7 +656,8 @@ def RunCleanvid():
fullSubs=False,
subsOnly=False,
offline=False,
reEncode=False,
reEncodeVideo=False,
reEncodeAudio=False,
hardCode=False,
edl=False,
)
Expand Down Expand Up @@ -682,7 +695,8 @@ def RunCleanvid():
args.edl,
args.json,
lang,
args.reEncode,
args.reEncodeVideo,
args.reEncodeAudio,
args.hardCode,
args.vParams,
args.aParams,
Expand Down

0 comments on commit 3f9f5d5

Please sign in to comment.