Start work on reorganizing easyffmpeg
Goals: 1. Check if the biggest subtitle was selected and produce a warning otherwise 2. Allow more different subtitle languages, follow a set preference of order 3. More audio languages
This commit is contained in:
parent
ff492ef07e
commit
d6b8a6d578
@ -11,6 +11,9 @@ import csv
|
||||
# ffmpeg wrapper
|
||||
import ffmpy
|
||||
|
||||
# Mediainfo wrapper
|
||||
import pymediainfo
|
||||
|
||||
# argument parsing
|
||||
import argparse
|
||||
|
||||
@ -54,6 +57,10 @@ def valid_duration(filename: str, filetype: str):
|
||||
write.writerow((filetype, filename))
|
||||
|
||||
|
||||
def validate_subtitle_size(filename: str):
|
||||
pass
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description="")
|
||||
|
||||
# Input file
|
||||
@ -118,10 +125,6 @@ parser.add_argument(
|
||||
help="Stream identifier for english audio",
|
||||
)
|
||||
|
||||
# Subtitle stuff
|
||||
parser.add_argument(
|
||||
"-sn", "--subtitle-name", required=False, type=str, help="Name for subtitles"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-si",
|
||||
"--subtitle-stream",
|
||||
@ -130,16 +133,6 @@ parser.add_argument(
|
||||
help="Stream identifier for subtitles",
|
||||
)
|
||||
|
||||
"""
|
||||
parser.add_argument(
|
||||
"-sd",
|
||||
"--set-default-subtitle",
|
||||
required=False,
|
||||
action="store_true",
|
||||
help="If passed, set the first subtitle as default",
|
||||
)
|
||||
"""
|
||||
|
||||
# Output file
|
||||
parser.add_argument("-o", "--output-file", required=True, type=str, help="Output file")
|
||||
|
||||
@ -213,7 +206,6 @@ if args.audio_japanese is None:
|
||||
else:
|
||||
audiometa = "-metadata:s:a:0 title='Japanese' -metadata:s:a:0 language=jpn -metadata:s:a:1 title='English' -metadata:s:a:1 language=eng"
|
||||
|
||||
subtitle = args.subtitle_name
|
||||
subtitlestream = args.subtitle_stream
|
||||
|
||||
"""
|
||||
@ -246,7 +238,7 @@ ff = ffmpy.FFmpeg(
|
||||
" "
|
||||
"{audiometa} -disposition:a:0 default"
|
||||
" "
|
||||
"-c:s copy -map {substream}? -metadata:s:s:0 title='{subtitle}' -metadata:s:s:0 language=eng {defaultsub}"
|
||||
"-c:s copy -map {substream}? -metadata:s:s:0 title='English' -metadata:s:s:0 language=eng {defaultsub}"
|
||||
" ".format(
|
||||
title=title,
|
||||
videocodec=videocodec,
|
||||
@ -259,7 +251,6 @@ ff = ffmpy.FFmpeg(
|
||||
engaudiomap=englishaudio,
|
||||
audiometa=audiometa,
|
||||
substream=subtitlestream,
|
||||
subtitle=subtitle,
|
||||
defaultsub=defaultsub,
|
||||
)
|
||||
},
|
||||
|
23
easyffmpeg/mediainfotest.py
Executable file
23
easyffmpeg/mediainfotest.py
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Mediainfo wrapper
|
||||
import pymediainfo
|
||||
|
||||
media_info = pymediainfo.MediaInfo.parse(
|
||||
"/mnt/storage/MediaLibrary/_output/[Drag] Durarara!! - 15 (BD 1080p x264 10-bit FLAC) [1E249118].mkv"
|
||||
)
|
||||
for track in media_info.tracks:
|
||||
if track.track_type == "Text":
|
||||
# NOTE get all data
|
||||
# print(track.to_data())
|
||||
print(
|
||||
"Subtitle Stream: {t.stream_identifier}, Size: {t.stream_size}".format(
|
||||
t=track
|
||||
)
|
||||
)
|
||||
|
||||
# all data
|
||||
"""
|
||||
{'track_type': 'Text', 'count': '304', 'count_of_stream_of_this_kind': '2', 'kind_of_stream': 'Text', 'other_kind_of_stream': ['Text'], 'stream_identifier': 0, 'other_stream_identifier': ['1'], 'streamorder': '3', 'track_id': 4, 'other_track_id': ['4'], 'unique_id': '13175609095553569913', 'format': 'ASS', 'other_format': ['ASS'], 'format_url': 'http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow', 'commercial_name': 'ASS', 'codec_id': 'S_TEXT/ASS', 'codec_id_info': 'Advanced Sub Station Alpha', 'duration': '1462540.000000', 'other_duration': ['24 min 22 s', '24 min 22 s 540 ms', '24 min 22 s', '00:24:22.540', '00:24:22.540'], 'bit_rate': 199, 'other_bit_rate': ['199 b/s'], 'frame_rate': '0.346', 'other_frame_rate': ['0.346 FPS'], 'frame_count': '506', 'count_of_elements': '506', 'compression_mode': 'Lossless', 'other_compression_mode': ['Lossless'], 'stream_size': 36545, 'other_stream_size': ['35.7 KiB (0%)', '36 KiB', '36 KiB', '35.7 KiB', '35.69 KiB', '35.7 KiB (0%)'], 'proportion_of_this_stream': '0.00003', 'title': 'Signs & Songs [Coalgirls]', 'language': 'zxx', 'other_language': ['zxx', 'zxx', 'zxx'], 'default': 'Yes', 'other_default': ['Yes'], 'forced': 'No', 'other_forced': ['No']}
|
||||
{'track_type': 'Text', 'count': '304', 'count_of_stream_of_this_kind': '2', 'kind_of_stream': 'Text', 'other_kind_of_stream': ['Text'], 'stream_identifier': 1, 'other_stream_identifier': ['2'], 'streamorder': '4', 'track_id': 5, 'other_track_id': ['5'], 'unique_id': '10941183927163099426', 'format': 'ASS', 'other_format': ['ASS'], 'format_url': 'http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow', 'commercial_name': 'ASS', 'codec_id': 'S_TEXT/ASS', 'codec_id_info': 'Advanced Sub Station Alpha', 'duration': '1462540.000000', 'other_duration': ['24 min 22 s', '24 min 22 s 540 ms', '24 min 22 s', '00:24:22.540', '00:24:22.540'], 'bit_rate': 70, 'other_bit_rate': ['70 b/s'], 'frame_rate': '0.091', 'other_frame_rate': ['0.091 FPS'], 'frame_count': '133', 'count_of_elements': '133', 'compression_mode': 'Lossless', 'other_compression_mode': ['Lossless'], 'stream_size': 12980, 'other_stream_size': ['12.7 KiB (0%)', '13 KiB', '13 KiB', '12.7 KiB', '12.68 KiB', '12.7 KiB (0%)'], 'proportion_of_this_stream': '0.00001', 'title': 'Full Subtitles [Coalgirls]', 'language': 'en', 'other_language': ['English', 'English', 'en', 'eng', 'en'], 'default': 'No', 'other_default': ['No'], 'forced': 'No', 'other_forced': ['No']}
|
||||
"""
|
@ -1 +1,2 @@
|
||||
ffmpy
|
||||
pymediainfo
|
||||
|
Loading…
Reference in New Issue
Block a user