Improved ffmpeg conversion script with stream mapping, quality control, and new format support
- Added explicit stream mapping for video (-map 0:v), audio (-map 0:a?), and subtitles (-map 0:s?) to preserve all streams during conversion. - Removed '-strict experimental' for AV1 as it's no longer necessary for most ffmpeg builds. - Introduced CRF (Constant Rate Factor) settings for AV1 and x265 for better control over quality and file size. - Standardized audio and subtitle copying with '-c:a copy' and '-c:s copy' for efficiency. - Added support for .mov and .ts formats in MediaCurator.
This commit is contained in:
parent
1516b6a321
commit
8319851836
@ -90,6 +90,8 @@ class MediaLibrary():
|
|||||||
videolist += list(path.rglob("*.[fF][lL][vV]"))
|
videolist += list(path.rglob("*.[fF][lL][vV]"))
|
||||||
if "mpg" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
if "mpg" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
||||||
videolist += list(path.rglob("*.[mM][pP][gG]"))
|
videolist += list(path.rglob("*.[mM][pP][gG]"))
|
||||||
|
if "mov" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
||||||
|
videolist += list(path.rglob("*.[mM][oO][vV]"))
|
||||||
if "mpeg" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
if "mpeg" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
||||||
videolist += list(path.rglob("*.[mM][pP][eE][gG]"))
|
videolist += list(path.rglob("*.[mM][pP][eE][gG]"))
|
||||||
if "vid" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
if "vid" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
||||||
@ -100,6 +102,8 @@ class MediaLibrary():
|
|||||||
videolist += list(path.rglob("*.[dD][iI][vV][xX]"))
|
videolist += list(path.rglob("*.[dD][iI][vV][xX]"))
|
||||||
if "ogm" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
if "ogm" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
||||||
videolist += list(path.rglob("*.[oO][gG][mM]"))
|
videolist += list(path.rglob("*.[oO][gG][mM]"))
|
||||||
|
if "ts" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
||||||
|
videolist += list(path.rglob("*.[tT][sS]"))
|
||||||
if "webm" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
if "webm" in self.inputs or "any" in self.inputs or len(self.inputs) < 1:
|
||||||
videolist += list(path.rglob("*.[wW][eE][bB][mM]"))
|
videolist += list(path.rglob("*.[wW][eE][bB][mM]"))
|
||||||
|
|
||||||
|
|||||||
@ -174,14 +174,25 @@ class Video():
|
|||||||
self.filename_tmp = newfilename
|
self.filename_tmp = newfilename
|
||||||
|
|
||||||
# Setting ffmpeg
|
# Setting ffmpeg
|
||||||
args = ['ffmpeg', '-i', self.path + self.filename_origin]
|
args = [
|
||||||
|
'ffmpeg', '-i', self.path + self.filename_origin, '-map', '0:v',
|
||||||
|
'-map', '0:a?', '-map', '0:s?'
|
||||||
|
]
|
||||||
|
|
||||||
# Conversion options
|
# Conversion options
|
||||||
if vcodec == "av1":
|
if vcodec == "av1":
|
||||||
args += ['-c:v', 'libaom-av1', '-strict', 'experimental']
|
args += ['-c:v', 'libaom-av1']
|
||||||
|
# Optionally, control quality with a crf value for AV1
|
||||||
|
args += ['-crf', '30']
|
||||||
elif vcodec == "x265" or vcodec == "hevc":
|
elif vcodec == "x265" or vcodec == "hevc":
|
||||||
args += ['-c:v', 'libx265']
|
args += ['-c:v', 'libx265']
|
||||||
|
# Add max_muxing_queue_size to avoid buffer overflows
|
||||||
args += ['-max_muxing_queue_size', '1000']
|
args += ['-max_muxing_queue_size', '1000']
|
||||||
|
# Control quality with crf for x265
|
||||||
|
args += ['-preset', 'medium', '-crf', '28']
|
||||||
|
|
||||||
|
# Add mapping for video, audio, and subtitle streams
|
||||||
|
args += ['-c:a', 'copy', '-c:s', 'copy']
|
||||||
# Conversion output
|
# Conversion output
|
||||||
args += [self.path + self.filename_tmp]
|
args += [self.path + self.filename_tmp]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user