lazarusking commited on
Commit
a044023
1 Parent(s): c0b6376

Added multiple filters and options;added Video,audio and file view

Browse files
Files changed (8) hide show
  1. .gitignore +3 -1
  2. app.py +194 -35
  3. codecs.json +23 -0
  4. data.json +1189 -0
  5. functions.py +345 -0
  6. mappings.json +62 -0
  7. output.json +46 -0
  8. styles.css +6 -0
.gitignore CHANGED
@@ -1 +1,3 @@
1
- flagged
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ flagged/
app.py CHANGED
@@ -1,46 +1,205 @@
 
1
  import logging
2
  import os
3
  import subprocess
 
4
  from tempfile import _TemporaryFileWrapper
5
 
6
  from ffmpy import FFmpeg
7
 
8
  import gradio as gr
 
 
9
 
10
  logging.basicConfig(level=logging.INFO)
11
 
12
- def convert(file:_TemporaryFileWrapper,options:list,):
13
- logging.info(f"Current working path :{os.getcwd()}")
14
- logging.info(f"File name: {file.name}")
15
- # options.append(["Boy","Girl"])
16
- new_name,_=file.name.split(".")
17
- logging.info(f"New filename:{new_name}")
18
- cm=["ffmpeg","-y","-i",file.name,f"{new_name}.{options}"]
19
- output_file=f"{new_name}.{options}"
20
- ffmpeg=FFmpeg(inputs={file.name:None},outputs={output_file:None},global_options=["-y","-hide_banner"])
21
- print(ffmpeg)
22
- ffmpeg.run()
23
- # subprocess.run(cm,text=True)
24
- # gr.CheckboxGroup(choices=["Fast","HD"])
25
- return [output_file,ffmpeg]
26
-
27
- app=gr.Interface(fn=convert,inputs=[gr.File(),gr.Radio(choices=["mp3","ogg","flac","wav"])],outputs=[gr.Audio(),"text"],flagging_dir="flagged")
28
- app.launch(server_port=3000)
29
- # cm=["ffmpeg","-i","/home/accel/Documents/Denouement.ogg","/home/accel/Documents/Denouement.mp3"]
30
-
31
- # subprocess.run(cm,text=True)
32
- # dm=gr.Blocks()
33
- # with dm:
34
- # gr.Markdown("Something")
35
- # with gr.Tabs():
36
- # with gr.TabItem("A tab"):
37
- # text_input=gr.Textbox()
38
- # text_output=gr.Textbox()
39
- # text_button=gr.Button("Action")
40
- # with gr.TabItem("Second tab"):
41
- # with gr.Row():
42
- # txt_input=gr.Textbox()
43
- # txt_output=gr.Textbox()
44
- # txt_button=gr.Button("Play")
45
- # text_button.click(hello,inputs=text_input,outputs=text_output)
46
- # dm.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
  import logging
3
  import os
4
  import subprocess
5
+ from pprint import pprint
6
  from tempfile import _TemporaryFileWrapper
7
 
8
  from ffmpy import FFmpeg
9
 
10
  import gradio as gr
11
+ from functions import (Clear, CommandBuilder, change_clipbox, customBitrate, mediaChange,
12
+ supported_codecs, supported_presets, updateOutput, videoChange)
13
 
14
  logging.basicConfig(level=logging.INFO)
15
 
16
+ choices = ["mp3", "ogg", "flac", "wav"]
17
+
18
+
19
+ def parse(param: json) -> dict:
20
+ with open(param) as file:
21
+ return json.load(file)
22
+
23
+ # global inputs,inputs_clip
24
+ data = parse("./data.json")
25
+
26
+ containers=[j.get("name") for i in data["containers"] for j in data["containers"][i]]
27
+ video_containers = [i.get("name") for i in data["containers"]["video"]]
28
+ video_codecs = [i.get("name") for i in data["codecs"]["video"]]
29
+ video_aspect_ratio = [i.get("name") for i in data["aspects"]]
30
+ video_scaling = [i.get("name") for i in data["scalings"]]
31
+ """ Audio """
32
+ audio_containers = [i.get("name") for i in data["containers"]["audio"]]
33
+ audio_codecs = [i.get("name") for i in data["codecs"]["audio"]]
34
+ audio_channels = [i.get("name") for i in data["audioChannels"]]
35
+ audio_quality = [i.get("name") for i in data["audioQualities"]]
36
+ audio_sample_rates = [i.get("name") for i in data["sampleRates"]]
37
+
38
+ """ Video & Audio Filters """
39
+ # deband=[i.get("name") for i in data["deband"]]
40
+ # deflicker=[i.get("name") for i in data["deflicker"]]
41
+ # deshake=[i.get("name") for i in data["deshake"]]
42
+ # dejudder=[i.get("name") for i in data["dejudder"]]
43
+ # denoise=[i.get("name") for i in data["denoise"]]
44
+ # deinterlace=[i.get("name") for i in data["deinterlace"]]
45
+ filters = ["deband", "deflicker", "deshake",
46
+ "dejudder", "denoise", "deinterlace"]
47
+ vf = [{vFilter: names} for vFilter in filters for names in [
48
+ [i for i in data[vFilter]]]]
49
+
50
+ presets = [i.get("name") for i in data["presets"]]
51
+ profiles = [i.get("name") for i in data["profiles"]]
52
+ speeds = [i.get("name") for i in data["speeds"]]
53
+
54
+ logging.info(msg=f"{video_containers}")
55
+
56
+
57
+ def convert(file: _TemporaryFileWrapper, options: str):
58
+ stderr=""
59
+ stdout=""
60
+ output_file=""
61
+ video=""
62
+ ffmpeg=FFmpeg()
63
+ try:
64
+ logging.info(f"File name: {file.name}")
65
+ new_name, _ = file.name.split(".")
66
+ logging.info(f"New filename:{new_name}")
67
+ output_file = f"{new_name}1.{options.lower()}"
68
+ ffmpeg = FFmpeg(inputs={file.name: None}, outputs={
69
+ output_file: ffmpeg_commands.commands.split()}, global_options=["-y", "-hide_banner"])
70
+ print(ffmpeg)
71
+ print(ffmpeg.cmd)
72
+
73
+ stdout, stderr=ffmpeg.run(stderr=subprocess.PIPE)
74
+ logging.info(f"{stdout} {stderr}")
75
+ output=f"{ffmpeg.cmd}"
76
+ video=gr.update(label=output_file,value=output_file)
77
+
78
+ except Exception as e:
79
+ stderr=e
80
+ output=f"{ffmpeg.cmd} {stderr}"
81
+
82
+ return [output_file,output_file,video,output]
83
+
84
+
85
+
86
+ """Helper Functions for Processing """
87
+
88
+
89
+
90
+ def get_component_instance(inputs: gr.Blocks) -> list:
91
+ return [gr.components.get_component_instance(i, render=True) for i in inputs.children if not hasattr(i,"children")]
92
+
93
+ # names=[{x:i} for x in ["audioChannels","audioQualities"] for i in [[i.get("name") for i in data[x]]]]
94
+ with gr.Blocks(css="./styles.css") as dm:
95
+ gr.Markdown("Something")
96
+ with gr.Tabs():
97
+ with gr.TabItem("Format"):
98
+ # Input Buttons
99
+ with gr.Row():
100
+ with gr.Column() as inputs:
101
+ file_input = gr.File()
102
+ options = gr.Radio(
103
+ label="options", choices=containers,value=containers[0])
104
+
105
+ with gr.Row() as inputs_clip:
106
+ clip = gr.Dropdown(
107
+ choices=["None", "Enabled"], label="Clip:", value="None")
108
+ start_time = gr.Textbox(
109
+ label="Start Time:", placeholder="00:00", visible=False)
110
+ stop_time = gr.Textbox(
111
+ label="Stop Time:", placeholder="00:00", visible=False)
112
+ with gr.Row().style(mobile_collapse=False):
113
+ clearBtn = gr.Button("Clear")
114
+ convertBtn = gr.Button("Convert", variant="primary")
115
+
116
+ # Output Buttons
117
+ with gr.Column():
118
+ # media_output = gr.Audio(label="Output")
119
+ with gr.Row().style(mobile_collapse=False):
120
+ video_button=gr.Button("Video")
121
+ audio_button=gr.Button("Audio")
122
+ file_button=gr.Button("File")
123
+ media_output_audio = gr.Audio(label="Output",visible=True,interactive=False,source="filepath")
124
+ media_output_video = gr.Video(label="Output",visible=False,format="mp4")
125
+ media_output_file = gr.File(label="Output",visible=False)
126
+ output_textbox = gr.Textbox(elem_id="outputtext")
127
+
128
+ resetFormat=Clear(inputs,inputs_clip)
129
+ clearBtn.click(resetFormat.clear, inputs=resetFormat(), outputs=resetFormat())
130
+ convertBtn.click(convert, inputs=[file_input, options], outputs=[
131
+ media_output_audio,media_output_file,media_output_video, output_textbox])
132
+
133
+ with gr.TabItem("Video"):
134
+ with gr.Row() as video_inputs:
135
+ video_options = gr.Dropdown(
136
+ label="video", choices=video_codecs,value=video_codecs[-1])
137
+ preset_options = gr.Dropdown(choices=presets, label="presets",value=presets[-1])
138
+
139
+
140
+ with gr.Column():
141
+ clearBtn = gr.Button("Clear")
142
+ videoReset=Clear(video_inputs)
143
+ clearBtn.click(videoReset.clear, videoReset(), videoReset())
144
+
145
+ with gr.TabItem("Audio"):
146
+ with gr.Row().style(mobile_collapse=False) as audio_inputs:
147
+ # print(names[0])
148
+ audio_options = gr.Dropdown(
149
+ label="audio", choices=audio_codecs, value=audio_codecs[-1])
150
+ audio_bitrate=gr.Dropdown(choices=audio_quality, label="Audio Qualities",
151
+ value=audio_quality[0])
152
+ custom_bitrate=gr.Number(label="Audio Qualities",visible=False)
153
+ gr.Dropdown(choices=audio_channels,
154
+ label="Audio Channels", value=audio_channels[0])
155
+ gr.Dropdown(choices=audio_sample_rates,
156
+ label="Sample Rates", value=audio_sample_rates[0])
157
+
158
+
159
+ with gr.Column():
160
+ clearBtn = gr.Button("Clear")
161
+ audioReset=Clear(audio_inputs)
162
+ clearBtn.click(audioReset.clear, audioReset(), audioReset())
163
+
164
+ with gr.TabItem("Filters") as filter_inputs:
165
+ gr.Markdown("## Video")
166
+ with gr.Row().style(equal_height=True,mobile_collapse=False) as filter_inputs:
167
+ for i in vf:
168
+ # print(i.values())
169
+ # values = list(i.values())
170
+ values=list(i.values())[0]
171
+ choices=[j for lst in values for j in [lst.get("name")]]
172
+ a=gr.Dropdown(label=list(i.keys()),
173
+ choices=choices, value=choices[0])
174
+ gr.Markdown("## Audio")
175
+ with gr.Row() as filter_inputs_1:
176
+ acontrastSlider=gr.Slider(label="Acontrast", elem_id="aconstrast")
177
+
178
+ with gr.Column():
179
+ clearBtn = gr.Button("Clear")
180
+
181
+ filterReset=Clear(filter_inputs,filter_inputs_1)
182
+ clearBtn.click(filterReset.clear, filterReset(), filterReset())
183
+
184
+ """ Format Tab change functions"""
185
+ ffmpeg_commands=CommandBuilder(inputs_clip,video_inputs,audio_inputs,filter_inputs,filter_inputs_1)
186
+ ffmpeg_commands.do()
187
+ pprint(ffmpeg_commands.commands)
188
+ ffmpeg_commands.update(output_textbox)
189
+ file_input.change(fn=updateOutput,inputs=file_input,outputs=output_textbox)
190
+ clip.change(fn=change_clipbox, inputs=clip,
191
+ outputs=[start_time, stop_time])
192
+
193
+ options.change(supported_codecs,[options],[video_options,audio_options])
194
+ # options.change(mediaChange,[options],[media_output_audio,media_output_video])
195
+ # video_button.click(fn=videoChange,inputs=media_output_file,outputs=media_output_video)
196
+ audio_button.click(mediaChange,[audio_button],[media_output_audio,media_output_video,media_output_file])
197
+ video_button.click(mediaChange,[video_button],[media_output_audio,media_output_video,media_output_file])
198
+ # media_output_audio.change(lambda x:gr.update(value=x),[media_output_audio],[media_output_video])
199
+ file_button.click(mediaChange,[file_button],[media_output_audio,media_output_video,media_output_file])
200
+ """Video Tab change functions"""
201
+ video_options.change(supported_presets,[video_options],[preset_options])
202
+ """Audio Tab change functions"""
203
+ audio_bitrate.change(customBitrate,[audio_bitrate],[custom_bitrate])
204
+
205
+ dm.launch()
codecs.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "video": {
3
+ "x264": "libx264",
4
+ "x265": "libx265",
5
+ "h264_nvenc": "h264_nvenc",
6
+ "hevc_nvenc": "hevc_nvenc",
7
+ "vp8": "libvpx",
8
+ "vp9": "libvpx-vp9",
9
+ "av1": "libaom-av1",
10
+ "mpeg2": "mpeg2video",
11
+ "mpeg4": "mpeg4 -vtag xvid",
12
+ "theora": "libtheora"
13
+ },
14
+ "audio": {
15
+ "aac": "aac",
16
+ "alac": "alac",
17
+ "dts": "dca",
18
+ "ac3": "ac3",
19
+ "vorbis": "libvorbis",
20
+ "opus": "libopus"
21
+ },
22
+ "copy": "copy"
23
+ }
data.json ADDED
@@ -0,0 +1,1189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "protocols": [
3
+ {
4
+ "name": "File",
5
+ "value": "movie.mp4"
6
+ },
7
+ {
8
+ "name": "FTP",
9
+ "value": "ftp://[user[:password]@]server[:port]/path/to/remote/movie.mp4"
10
+ },
11
+ {
12
+ "name": "HTTP",
13
+ "value": "http://server:port/movie.mp4"
14
+ },
15
+ {
16
+ "name": "HTTPS",
17
+ "value": "https://server:port/movie.mp4"
18
+ },
19
+ {
20
+ "name": "RTMP",
21
+ "value": "rtmp://[username:password@]server[:port][/app][/instance][/playpath]"
22
+ },
23
+ {
24
+ "name": "SRT",
25
+ "value": "srt://hostname:port[?options]"
26
+ },
27
+ {
28
+ "name": "TCP",
29
+ "value": "tcp://hostname:port[?options]"
30
+ },
31
+ {
32
+ "name": "UDP",
33
+ "value": "udp://hostname:port[?options]"
34
+ }
35
+ ],
36
+ "containers": {
37
+ "video": [
38
+ {
39
+ "name": "MP4",
40
+ "value": "mp4"
41
+ },
42
+ {
43
+ "name": "MKV",
44
+ "value": "mkv"
45
+ },
46
+ {
47
+ "name": "WebM",
48
+ "value": "webm"
49
+ },
50
+ {
51
+ "name": "MPG",
52
+ "value": "mpg"
53
+ },
54
+ {
55
+ "name": "AVI",
56
+ "value": "avi"
57
+ },
58
+ {
59
+ "name": "OGV",
60
+ "value": "ogv"
61
+ },
62
+ {
63
+ "name": "FLV",
64
+ "value": "flv"
65
+ }
66
+ ],
67
+ "audio": [
68
+ {
69
+ "name": "MP3",
70
+ "value": "mp3"
71
+ },
72
+ {
73
+ "name": "M4A",
74
+ "value": "m4a"
75
+ },
76
+ {
77
+ "name": "OGG",
78
+ "value": "ogg"
79
+ },
80
+ {
81
+ "name": "FLAC",
82
+ "value": "flac"
83
+ },
84
+ {
85
+ "name": "WAV",
86
+ "value": "wav"
87
+ }
88
+ ]
89
+ },
90
+ "clip": [
91
+ {
92
+ "name": "None",
93
+ "value": false
94
+ },
95
+ {
96
+ "name": "Enabled",
97
+ "value": true
98
+ }
99
+ ],
100
+ "codecs": {
101
+ "video": [
102
+ {
103
+ "name": "x264",
104
+ "value": "x264",
105
+ "supported": [
106
+ "mp4",
107
+ "mkv",
108
+ "avi"
109
+ ]
110
+ },
111
+ {
112
+ "name": "x265",
113
+ "value": "x265",
114
+ "supported": [
115
+ "mp4",
116
+ "mkv",
117
+ "avi"
118
+ ]
119
+ },
120
+ {
121
+ "name": "h264_nvenc (Nvidia NVENC)",
122
+ "value": "h264_nvenc",
123
+ "supported": [
124
+ "mp4"
125
+ ]
126
+ },
127
+ {
128
+ "name": "hevc_nvenc (Nvidia NVENC)",
129
+ "value": "hevc_nvenc",
130
+ "supported": [
131
+ "mp4"
132
+ ]
133
+ },
134
+ {
135
+ "name": "AV1",
136
+ "value": "av1",
137
+ "supported": [
138
+ "mp4",
139
+ "mkv"
140
+ ]
141
+ },
142
+ {
143
+ "name": "VP8",
144
+ "value": "vp8",
145
+ "supported": [
146
+ "mp4",
147
+ "webm",
148
+ "mkv",
149
+ "avi"
150
+ ]
151
+ },
152
+ {
153
+ "name": "VP9",
154
+ "value": "vp9",
155
+ "supported": [
156
+ "mp4",
157
+ "webm",
158
+ "mkv",
159
+ "avi"
160
+ ]
161
+ },
162
+ {
163
+ "name": "copy",
164
+ "value": "copy",
165
+ "supported": null
166
+ }
167
+ ],
168
+ "audio": [
169
+ {
170
+ "name": "AAC",
171
+ "value": "aac",
172
+ "supported": [
173
+ "mp4",
174
+ "mp3",
175
+ "m4a",
176
+ "mkv",
177
+ "avi",
178
+ "flv"
179
+ ]
180
+ },
181
+ {
182
+ "name": "AC3",
183
+ "value": "ac3",
184
+ "supported": [
185
+ "mp4",
186
+ "mkv",
187
+ "avi"
188
+ ]
189
+ },
190
+ {
191
+ "name": "DTS",
192
+ "value": "dts",
193
+ "supported": [
194
+ "mp4",
195
+ "mkv",
196
+ "avi"
197
+ ]
198
+ },
199
+ {
200
+ "name": "Vorbis",
201
+ "value": "vorbis",
202
+ "supported": [
203
+ "mp4",
204
+ "mkv",
205
+ "ogg",
206
+ "webm"
207
+ ]
208
+ },
209
+ {
210
+ "name": "Opus",
211
+ "value": "opus",
212
+ "supported": [
213
+ "mp4",
214
+ "mkv",
215
+ "ogg",
216
+ "webm"
217
+ ]
218
+ },
219
+ {
220
+ "name": "LAME",
221
+ "value": "lame",
222
+ "supported": [
223
+ "mp3",
224
+ "mkv"
225
+ ]
226
+ },
227
+ {
228
+ "name": "ALAC",
229
+ "value": "alac",
230
+ "supported": [
231
+ "mp4",
232
+ "mkv",
233
+ "m4a",
234
+ "avi"
235
+ ]
236
+ },
237
+ {
238
+ "name": "FLAC",
239
+ "value": "flac",
240
+ "supported": [
241
+ "flac",
242
+ "mkv",
243
+ "avi"
244
+ ]
245
+ },
246
+ {
247
+ "name": "PCM",
248
+ "value": "pcm",
249
+ "supported": [
250
+ "mkv"
251
+ ]
252
+ },
253
+ {
254
+ "name": "Copy",
255
+ "value": "copy",
256
+ "supported": null
257
+ },
258
+ {
259
+ "name": "None",
260
+ "value": "none",
261
+ "supported": null
262
+ }
263
+ ]
264
+ },
265
+ "presets": [
266
+ {
267
+ "name": "Placebo",
268
+ "value": "placebo",
269
+ "supported": [
270
+ "x264",
271
+ "x265"
272
+ ]
273
+ },
274
+ {
275
+ "name": "Very Slow",
276
+ "value": "veryslow",
277
+ "supported": [
278
+ "x264",
279
+ "x265"
280
+ ]
281
+ },
282
+ {
283
+ "name": "Slower",
284
+ "value": "slower",
285
+ "supported": [
286
+ "x264",
287
+ "x265"
288
+ ]
289
+ },
290
+ {
291
+ "name": "Slow",
292
+ "value": "slow",
293
+ "supported": [
294
+ "x264",
295
+ "x265",
296
+ "h264_nvenc",
297
+ "hevc_nvenc"
298
+ ]
299
+ },
300
+ {
301
+ "name": "Medium",
302
+ "value": "medium",
303
+ "supported": [
304
+ "x264",
305
+ "x265",
306
+ "h264_nvenc",
307
+ "hevc_nvenc"
308
+ ]
309
+ },
310
+ {
311
+ "name": "Fast",
312
+ "value": "fast",
313
+ "supported": [
314
+ "x264",
315
+ "x265",
316
+ "h264_nvenc",
317
+ "hevc_nvenc"
318
+ ]
319
+ },
320
+ {
321
+ "name": "Faster",
322
+ "value": "faster",
323
+ "supported": [
324
+ "x264",
325
+ "x265"
326
+ ]
327
+ },
328
+ {
329
+ "name": "Very Fast",
330
+ "value": "veryfast",
331
+ "supported": [
332
+ "x264",
333
+ "x265"
334
+ ]
335
+ },
336
+ {
337
+ "name": "Super Fast",
338
+ "value": "superfast",
339
+ "supported": [
340
+ "x264",
341
+ "x265"
342
+ ]
343
+ },
344
+ {
345
+ "name": "Ultra Fast",
346
+ "value": "ultrafast",
347
+ "supported": [
348
+ "x264",
349
+ "x265"
350
+ ]
351
+ },
352
+ {
353
+ "name": "hp",
354
+ "value": "hp",
355
+ "supported": [
356
+ "h264_nvenc",
357
+ "hevc_nvenc"
358
+ ]
359
+ },
360
+ {
361
+ "name": "hq",
362
+ "value": "hq",
363
+ "supported": [
364
+ "h264_nvenc",
365
+ "hevc_nvenc"
366
+ ]
367
+ },
368
+ {
369
+ "name": "bd",
370
+ "value": "bd",
371
+ "supported": [
372
+ "h264_nvenc",
373
+ "hevc_nvenc"
374
+ ]
375
+ },
376
+ {
377
+ "name": "lossless",
378
+ "value": "lossless",
379
+ "supported": [
380
+ "h264_nvenc",
381
+ "hevc_nvenc"
382
+ ]
383
+ },
384
+ {
385
+ "name": "losslesshp",
386
+ "value": "losslesshp",
387
+ "supported": [
388
+ "h264_nvenc",
389
+ "hevc_nvenc"
390
+ ]
391
+ },
392
+ {
393
+ "name": "None",
394
+ "value": "none"
395
+ }
396
+ ],
397
+ "passOptions": [
398
+ {
399
+ "name": "CRF",
400
+ "value": "crf"
401
+ },
402
+ {
403
+ "name": "1 Pass",
404
+ "value": "1"
405
+ },
406
+ {
407
+ "name": "2 Pass",
408
+ "value": "2"
409
+ }
410
+ ],
411
+ "pixelFormats": [
412
+ {
413
+ "name": "auto",
414
+ "value": "auto"
415
+ },
416
+ {
417
+ "name": "gray",
418
+ "value": "gray"
419
+ },
420
+ {
421
+ "name": "gray10le",
422
+ "value": "gray10le"
423
+ },
424
+ {
425
+ "name": "nv12",
426
+ "value": "nv12"
427
+ },
428
+ {
429
+ "name": "nv16",
430
+ "value": "nv16"
431
+ },
432
+ {
433
+ "name": "nv20le",
434
+ "value": "nv20le"
435
+ },
436
+ {
437
+ "name": "nv21",
438
+ "value": "nv21"
439
+ },
440
+ {
441
+ "name": "yuv420p",
442
+ "value": "yuv420p"
443
+ },
444
+ {
445
+ "name": "yuv420p10le",
446
+ "value": "yuv420p10le"
447
+ },
448
+ {
449
+ "name": "yuv422p",
450
+ "value": "yuv422p"
451
+ },
452
+ {
453
+ "name": "yuv422p10le",
454
+ "value": "yuv422p10le"
455
+ },
456
+ {
457
+ "name": "yuv444p",
458
+ "value": "yuv444p"
459
+ },
460
+ {
461
+ "name": "yuv444p10le",
462
+ "value": "yuv444p10le"
463
+ },
464
+ {
465
+ "name": "yuvj420p",
466
+ "value": "yuvj420p"
467
+ },
468
+ {
469
+ "name": "yuvj422p",
470
+ "value": "yuvj422p"
471
+ },
472
+ {
473
+ "name": "yuvj444p",
474
+ "value": "yuvj444p"
475
+ }
476
+ ],
477
+ "frameRates": [
478
+ {
479
+ "name": "auto",
480
+ "value": "auto"
481
+ },
482
+ {
483
+ "name": "ntsc",
484
+ "value": "ntsc"
485
+ },
486
+ {
487
+ "name": "pal",
488
+ "value": "pal"
489
+ },
490
+ {
491
+ "name": "film",
492
+ "value": "film"
493
+ },
494
+ {
495
+ "name": "23.976",
496
+ "value": "24000/1001"
497
+ },
498
+ {
499
+ "name": "24",
500
+ "value": "24"
501
+ },
502
+ {
503
+ "name": "25",
504
+ "value": "25"
505
+ },
506
+ {
507
+ "name": "29.97",
508
+ "value": "30000/1001"
509
+ },
510
+ {
511
+ "name": "30",
512
+ "value": "30"
513
+ },
514
+ {
515
+ "name": "48",
516
+ "value": "48"
517
+ },
518
+ {
519
+ "name": "50",
520
+ "value": "50"
521
+ },
522
+ {
523
+ "name": "59.94",
524
+ "value": "60000/1001"
525
+ },
526
+ {
527
+ "name": "60",
528
+ "value": "60"
529
+ }
530
+ ],
531
+ "speeds": [
532
+ {
533
+ "name": "auto",
534
+ "value": "auto"
535
+ },
536
+ {
537
+ "name": "10%",
538
+ "value": "10*PTS"
539
+ },
540
+ {
541
+ "name": "25%",
542
+ "value": "4*PTS"
543
+ },
544
+ {
545
+ "name": "50%",
546
+ "value": "2*PTS"
547
+ },
548
+ {
549
+ "name": "75%",
550
+ "value": "1.33333*PTS"
551
+ },
552
+ {
553
+ "name": "150%",
554
+ "value": ".66667*PTS"
555
+ },
556
+ {
557
+ "name": "200%",
558
+ "value": ".5*PTS"
559
+ },
560
+ {
561
+ "name": "250%",
562
+ "value": ".4*PTS"
563
+ },
564
+ {
565
+ "name": "300%",
566
+ "value": ".33333*PTS"
567
+ },
568
+ {
569
+ "name": "500%",
570
+ "value": ".2*PTS"
571
+ }
572
+ ],
573
+ "tunes": [
574
+ {
575
+ "name": "None",
576
+ "value": "none"
577
+ },
578
+ {
579
+ "name": "Film",
580
+ "value": "film"
581
+ },
582
+ {
583
+ "name": "Animation",
584
+ "value": "animation"
585
+ },
586
+ {
587
+ "name": "Grain",
588
+ "value": "grain"
589
+ },
590
+ {
591
+ "name": "Still Image",
592
+ "value": "stillimage"
593
+ },
594
+ {
595
+ "name": "Fast Decode",
596
+ "value": "fastdecode"
597
+ },
598
+ {
599
+ "name": "Zero Latency",
600
+ "value": "zerolatency"
601
+ }
602
+ ],
603
+ "profiles": [
604
+ {
605
+ "name": "None",
606
+ "value": "none"
607
+ },
608
+ {
609
+ "name": "Baseline",
610
+ "value": "baseline"
611
+ },
612
+ {
613
+ "name": "Main",
614
+ "value": "main"
615
+ },
616
+ {
617
+ "name": "High",
618
+ "value": "high"
619
+ }
620
+ ],
621
+ "levels": [
622
+ {
623
+ "name": "None",
624
+ "value": "none"
625
+ },
626
+ {
627
+ "name": "1.0",
628
+ "value": "1.0"
629
+ },
630
+ {
631
+ "name": "1.1",
632
+ "value": "1.1"
633
+ },
634
+ {
635
+ "name": "1.2",
636
+ "value": "1.2"
637
+ },
638
+ {
639
+ "name": "1.3",
640
+ "value": "1.3"
641
+ },
642
+ {
643
+ "name": "2.0",
644
+ "value": "2.0"
645
+ },
646
+ {
647
+ "name": "2.1",
648
+ "value": "2.1"
649
+ },
650
+ {
651
+ "name": "2.2",
652
+ "value": "2.2"
653
+ },
654
+ {
655
+ "name": "3.0",
656
+ "value": "3.0"
657
+ },
658
+ {
659
+ "name": "3.1",
660
+ "value": "3.1"
661
+ },
662
+ {
663
+ "name": "3.2",
664
+ "value": "3.2"
665
+ },
666
+ {
667
+ "name": "4.0",
668
+ "value": "4.0"
669
+ },
670
+ {
671
+ "name": "4.1",
672
+ "value": "4.1"
673
+ },
674
+ {
675
+ "name": "4.2",
676
+ "value": "4.2"
677
+ },
678
+ {
679
+ "name": "5.0",
680
+ "value": "5.0"
681
+ },
682
+ {
683
+ "name": "5.1",
684
+ "value": "5.1"
685
+ },
686
+ {
687
+ "name": "5.2",
688
+ "value": "5.2"
689
+ }
690
+ ],
691
+ "fastStart": [
692
+ {
693
+ "name": "Enabled (faststart)",
694
+ "value": true
695
+ },
696
+ {
697
+ "name": "None",
698
+ "value": false
699
+ }
700
+ ],
701
+ "sizes": [
702
+ {
703
+ "name": "Source",
704
+ "value": "source"
705
+ },
706
+ {
707
+ "name": "8K",
708
+ "value": "8192"
709
+ },
710
+ {
711
+ "name": "8K UHD",
712
+ "value": "7680"
713
+ },
714
+ {
715
+ "name": "4K",
716
+ "value": "4096"
717
+ },
718
+ {
719
+ "name": "4K UHD",
720
+ "value": "3840"
721
+ },
722
+ {
723
+ "name": "2K",
724
+ "value": "2048"
725
+ },
726
+ {
727
+ "name": "1600p",
728
+ "value": "2560"
729
+ },
730
+ {
731
+ "name": "1440p",
732
+ "value": "2560"
733
+ },
734
+ {
735
+ "name": "1200p",
736
+ "value": "1920"
737
+ },
738
+ {
739
+ "name": "1080p",
740
+ "value": "1920"
741
+ },
742
+ {
743
+ "name": "900p",
744
+ "value": "1600"
745
+ },
746
+ {
747
+ "name": "720p",
748
+ "value": "1280"
749
+ },
750
+ {
751
+ "name": "576p",
752
+ "value": "1024"
753
+ },
754
+ {
755
+ "name": "480p",
756
+ "value": "720"
757
+ },
758
+ {
759
+ "name": "320p",
760
+ "value": "480"
761
+ },
762
+ {
763
+ "name": "240p",
764
+ "value": "320"
765
+ },
766
+ {
767
+ "name": "Custom",
768
+ "value": "custom"
769
+ }
770
+ ],
771
+ "formats": [
772
+ {
773
+ "name": "Widescreen",
774
+ "value": "widescreen"
775
+ },
776
+ {
777
+ "name": "Full Screen",
778
+ "value": "fullscreen"
779
+ }
780
+ ],
781
+ "aspects": [
782
+ {
783
+ "name": "Auto",
784
+ "value": "auto"
785
+ },
786
+ {
787
+ "name": "1:1",
788
+ "value": "1:1"
789
+ },
790
+ {
791
+ "name": "2.4:1",
792
+ "value": "2.4:1"
793
+ },
794
+ {
795
+ "name": "3:2",
796
+ "value": "3:2"
797
+ },
798
+ {
799
+ "name": "4:3",
800
+ "value": "4:3"
801
+ },
802
+ {
803
+ "name": "5:4",
804
+ "value": "5:4"
805
+ },
806
+ {
807
+ "name": "8:7",
808
+ "value": "8:7"
809
+ },
810
+ {
811
+ "name": "14:10",
812
+ "value": "14:10"
813
+ },
814
+ {
815
+ "name": "16:9",
816
+ "value": "16:9"
817
+ },
818
+ {
819
+ "name": "16:10",
820
+ "value": "16:10"
821
+ },
822
+ {
823
+ "name": "19:10",
824
+ "value": "19:10"
825
+ },
826
+ {
827
+ "name": "21:9",
828
+ "value": "21:9"
829
+ },
830
+ {
831
+ "name": "32:9",
832
+ "value": "32:9"
833
+ }
834
+ ],
835
+ "scalings": [
836
+ {
837
+ "name": "Auto",
838
+ "value": "auto"
839
+ },
840
+ {
841
+ "name": "Neighbor",
842
+ "value": "neighbor"
843
+ },
844
+ {
845
+ "name": "Area",
846
+ "value": "area"
847
+ },
848
+ {
849
+ "name": "Fast Bilinear",
850
+ "value": "fast_bilinear"
851
+ },
852
+ {
853
+ "name": "Bilinear",
854
+ "value": "bilinear"
855
+ },
856
+ {
857
+ "name": "Bicubic",
858
+ "value": "bicubic"
859
+ },
860
+ {
861
+ "name": "Experimental",
862
+ "value": "experimental"
863
+ },
864
+ {
865
+ "name": "Bicublin",
866
+ "value": "bicublin"
867
+ },
868
+ {
869
+ "name": "Gauss",
870
+ "value": "gauss"
871
+ },
872
+ {
873
+ "name": "Sinc",
874
+ "value": "sinc"
875
+ },
876
+ {
877
+ "name": "Lanczos",
878
+ "value": "lanczos"
879
+ },
880
+ {
881
+ "name": "Spline",
882
+ "value": "spline"
883
+ }
884
+ ],
885
+ "audioStreams": [
886
+ {
887
+ "name": "None",
888
+ "value": "none"
889
+ },
890
+ {
891
+ "name": "All",
892
+ "value": "all"
893
+ },
894
+ {
895
+ "name": "1",
896
+ "value": "1"
897
+ },
898
+ {
899
+ "name": "2",
900
+ "value": "2"
901
+ },
902
+ {
903
+ "name": "3",
904
+ "value": "3"
905
+ },
906
+ {
907
+ "name": "4",
908
+ "value": "4"
909
+ },
910
+ {
911
+ "name": "5",
912
+ "value": "5"
913
+ },
914
+ {
915
+ "name": "6",
916
+ "value": "6"
917
+ },
918
+ {
919
+ "name": "7",
920
+ "value": "7"
921
+ },
922
+ {
923
+ "name": "8",
924
+ "value": "8"
925
+ }
926
+ ],
927
+ "audioChannels": [
928
+ {
929
+ "name": "Source",
930
+ "value": "source"
931
+ },
932
+ {
933
+ "name": "Mono",
934
+ "value": "1"
935
+ },
936
+ {
937
+ "name": "Stereo",
938
+ "value": "2"
939
+ },
940
+ {
941
+ "name": "5.1",
942
+ "value": "6"
943
+ }
944
+ ],
945
+ "audioQualities": [
946
+ {
947
+ "name": "Auto",
948
+ "value": "auto"
949
+ },
950
+ {
951
+ "name": "400",
952
+ "value": "400k"
953
+ },
954
+ {
955
+ "name": "320",
956
+ "value": "320k"
957
+ },
958
+ {
959
+ "name": "256",
960
+ "value": "256k"
961
+ },
962
+ {
963
+ "name": "224",
964
+ "value": "224k"
965
+ },
966
+ {
967
+ "name": "192",
968
+ "value": "192k"
969
+ },
970
+ {
971
+ "name": "160",
972
+ "value": "160k"
973
+ },
974
+ {
975
+ "name": "128",
976
+ "value": "128k"
977
+ },
978
+ {
979
+ "name": "96",
980
+ "value": "96k"
981
+ },
982
+ {
983
+ "name": "Custom",
984
+ "value": "custom"
985
+ },
986
+ {
987
+ "name": "Mute",
988
+ "value": "mute"
989
+ }
990
+ ],
991
+ "sampleRates": [
992
+ {
993
+ "name": "Auto",
994
+ "value": "auto"
995
+ },
996
+ {
997
+ "name": "7.35k",
998
+ "value": "7350"
999
+ },
1000
+ {
1001
+ "name": "8k",
1002
+ "value": "8000"
1003
+ },
1004
+ {
1005
+ "name": "11.025k",
1006
+ "value": "11025"
1007
+ },
1008
+ {
1009
+ "name": "12k",
1010
+ "value": "12000"
1011
+ },
1012
+ {
1013
+ "name": "16k",
1014
+ "value": "16000"
1015
+ },
1016
+ {
1017
+ "name": "22.05k",
1018
+ "value": "22050"
1019
+ },
1020
+ {
1021
+ "name": "24k",
1022
+ "value": "24000"
1023
+ },
1024
+ {
1025
+ "name": "32k",
1026
+ "value": "32000"
1027
+ },
1028
+ {
1029
+ "name": "44.1k",
1030
+ "value": "44100"
1031
+ },
1032
+ {
1033
+ "name": "48k",
1034
+ "value": "48000"
1035
+ }
1036
+ ],
1037
+ "deband": [
1038
+ {
1039
+ "name": "None",
1040
+ "value": false
1041
+ },
1042
+ {
1043
+ "name": "Enabled",
1044
+ "value": true
1045
+ }
1046
+ ],
1047
+ "deshake": [
1048
+ {
1049
+ "name": "None",
1050
+ "value": false
1051
+ },
1052
+ {
1053
+ "name": "Enabled",
1054
+ "value": true
1055
+ }
1056
+ ],
1057
+ "deflicker": [
1058
+ {
1059
+ "name": "None",
1060
+ "value": false
1061
+ },
1062
+ {
1063
+ "name": "Enabled",
1064
+ "value": true
1065
+ }
1066
+ ],
1067
+ "dejudder": [
1068
+ {
1069
+ "name": "None",
1070
+ "value": false
1071
+ },
1072
+ {
1073
+ "name": "Enabled",
1074
+ "value": true
1075
+ }
1076
+ ],
1077
+ "denoise": [
1078
+ {
1079
+ "name": "None",
1080
+ "value": "none"
1081
+ },
1082
+ {
1083
+ "name": "Default",
1084
+ "value": "default"
1085
+ },
1086
+ {
1087
+ "name": "Light",
1088
+ "value": "light"
1089
+ },
1090
+ {
1091
+ "name": "Medium",
1092
+ "value": "medium"
1093
+ },
1094
+ {
1095
+ "name": "Heavy",
1096
+ "value": "heavy"
1097
+ }
1098
+ ],
1099
+ "deinterlace": [
1100
+ {
1101
+ "name": "None",
1102
+ "value": "none"
1103
+ },
1104
+ {
1105
+ "name": "Frame",
1106
+ "value": "frame"
1107
+ },
1108
+ {
1109
+ "name": "Field",
1110
+ "value": "field"
1111
+ },
1112
+ {
1113
+ "name": "Frame Nospatial",
1114
+ "value": "frame_nospatial"
1115
+ },
1116
+ {
1117
+ "name": "Field Nospatial",
1118
+ "value": "field_nospatial"
1119
+ }
1120
+ ],
1121
+ "extraOptions": [
1122
+ {
1123
+ "text": "Force output file format.",
1124
+ "value": "f"
1125
+ },
1126
+ {
1127
+ "text": "Overwrite output files without asking.",
1128
+ "value": "y"
1129
+ },
1130
+ {
1131
+ "text": "Do not overwrite output files, and exit immediately if a specified output file already exists.",
1132
+ "value": "n"
1133
+ },
1134
+ {
1135
+ "text": "Send program-friendly progress information to stdout.",
1136
+ "value": "progress"
1137
+ },
1138
+ {
1139
+ "text": "Suppress printing banner.",
1140
+ "value": "hide_banner"
1141
+ },
1142
+ {
1143
+ "text": "Dump full command line and log output to a file named program-YYYYMMDD-HHMMSS.log in the current directory.",
1144
+ "value": "report"
1145
+ }
1146
+ ],
1147
+ "logLevels": [
1148
+ {
1149
+ "name": "None",
1150
+ "value": "none"
1151
+ },
1152
+ {
1153
+ "name": "Quiet",
1154
+ "value": "quiet"
1155
+ },
1156
+ {
1157
+ "name": "Panic",
1158
+ "value": "panic"
1159
+ },
1160
+ {
1161
+ "name": "Fatal",
1162
+ "value": "fatal"
1163
+ },
1164
+ {
1165
+ "name": "Error",
1166
+ "value": "error"
1167
+ },
1168
+ {
1169
+ "name": "Warning",
1170
+ "value": "warning"
1171
+ },
1172
+ {
1173
+ "name": "Info",
1174
+ "value": "info"
1175
+ },
1176
+ {
1177
+ "name": "Verbose",
1178
+ "value": "verbose"
1179
+ },
1180
+ {
1181
+ "name": "Debug",
1182
+ "value": "debug"
1183
+ },
1184
+ {
1185
+ "name": "Trace",
1186
+ "value": "trace"
1187
+ }
1188
+ ]
1189
+ }
functions.py ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from pprint import pprint
3
+ from tempfile import _TemporaryFileWrapper
4
+
5
+ import gradio as gr
6
+
7
+
8
+ def parse(param: json) -> dict:
9
+ with open(param) as file:
10
+ return json.load(file)
11
+
12
+
13
+ data = parse("./data.json")
14
+ codecs = parse("./codecs.json")
15
+
16
+ """Video"""
17
+ containers=[j.get("name") for i in data["containers"] for j in data["containers"][i]]
18
+ video_containers = [i.get("name") for i in data["containers"]["video"]]
19
+ video_codecs = [i.get("name") for i in data["codecs"]["video"]]
20
+ video_aspect_ratio = [i.get("name") for i in data["aspects"]]
21
+ video_scaling = [i.get("name") for i in data["scalings"]]
22
+ """ Audio """
23
+ audio_containers = [i.get("name") for i in data["containers"]["audio"]]
24
+ audio_codecs = [i.get("name") for i in data["codecs"]["audio"]]
25
+ audio_channels = [i.get("name") for i in data["audioChannels"]]
26
+ audio_quality = [i.get("name") for i in data["audioQualities"]]
27
+ audio_sample_rates = [i.get("name") for i in data["sampleRates"]]
28
+
29
+ """ Video & Audio Filters """
30
+ # deband=[i.get("name") for i in data["deband"]]
31
+ # deflicker=[i.get("name") for i in data["deflicker"]]
32
+ # deshake=[i.get("name") for i in data["deshake"]]
33
+ # dejudder=[i.get("name") for i in data["dejudder"]]
34
+ # denoise=[i.get("name") for i in data["denoise"]]
35
+ # deinterlace=[i.get("name") for i in data["deinterlace"]]
36
+ filters = ["deband", "deflicker", "deshake",
37
+ "dejudder", "denoise", "deinterlace"]
38
+ vf = [{vFilter: names} for vFilter in filters for names in [
39
+ [i for i in data[vFilter]]]]
40
+
41
+ presets = [i.get("name") for i in data["presets"]]
42
+ profiles = [i.get("name") for i in data["profiles"]]
43
+ speeds = [i.get("name") for i in data["speeds"]]
44
+
45
+
46
+ outputMap = parse("./mappings.json")
47
+ """Output Mappings of commands to value
48
+ audioQuality -b:a 128k
49
+ """
50
+
51
+
52
+ class CommandBuilder():
53
+ def __call__(self, *args, **kwds):
54
+ return [i.value for i in self._component]
55
+
56
+ def do(self, *inputs, **kwds):
57
+ for comp in self._component:
58
+ if comp.label is not None:
59
+ self.startfunc(comp,"",comp.value)
60
+
61
+ def __init__(self, *inputs: gr.Blocks) -> None:
62
+ self.outputDict = {}
63
+ self.formatOutputDict = {"vf": {}, "af": {}}
64
+ # state=gr.Variable()
65
+ # state2=gr.Variable()
66
+
67
+ self._component: list[gr.components.Changeable] = []
68
+ self.vf, self.af, self.extra = ([] for _ in range(3))
69
+ self.commands = ""
70
+ if inputs is None:
71
+ return None
72
+ for i in inputs:
73
+ self._component += self._get_component_instance(i)
74
+ for comp in self._component:
75
+ state = gr.Variable()
76
+ state2 = gr.Variable()
77
+ if comp.label is not None:
78
+ state.value = comp
79
+ state2.value = comp.label
80
+ comp.change(fn=self.changefunc, inputs=[
81
+ state, state2, comp], outputs=[])
82
+
83
+
84
+
85
+ def update(self, Component: gr.components.IOComponent):
86
+ for comp in self._component:
87
+ comp.change(lambda: gr.update(
88
+ value=self.commands), [], [Component])
89
+
90
+ def _get_component_instance(self, inputs: gr.Blocks) -> "list[gr.components.Component]":
91
+ return [gr.components.get_component_instance(i, render=True) for i in inputs.children if not hasattr(i, "children")]
92
+
93
+ def setVideoFilters(self, options):
94
+ value = self.outputDict.get(options, "-")
95
+ filters = outputMap.get(options, None)
96
+ arg = ""
97
+ if options in ["deinterlace", "denoise"]:
98
+ value = "_".join(value.lower().split())
99
+ arg = filters.get(value, None)
100
+ # self.vf.append(arg)
101
+ self.formatOutputDict["vf"].update({options: arg})
102
+ return True
103
+ if options in ["deband", "deflicker", "deshake", "dejudder"]:
104
+ arg = filters
105
+ self.formatOutputDict["vf"].update({options: arg})
106
+ return True
107
+
108
+ return
109
+
110
+ def setAudioFilters(self, options):
111
+ value = self.outputDict.get(options, "-")
112
+ if options in ["acontrast"]:
113
+ value = int(value)/100
114
+ arg = f"{options}={value}"
115
+
116
+ self.formatOutputDict["af"].update({options: arg})
117
+ return True
118
+ return
119
+
120
+ def setFormat(self, options):
121
+ value = self.outputDict.get(options, "-")
122
+ filters = outputMap.get(options, None)
123
+ if options in ["video", "audio"]:
124
+ value = "".join([i.get("value", "None") for i in data.get(
125
+ "codecs").get(options) if i.get("name", None) == value])
126
+ arg = f"{filters} {value}"
127
+ self.formatOutputDict.update({options: arg})
128
+ return True
129
+ elif data.get(options) == None:
130
+ arg = f"{filters} {value}"
131
+ self.formatOutputDict.update({options: arg})
132
+ return True
133
+ elif options != "clip":
134
+ value = "".join([i.get("value", "None") for i in data.get(
135
+ options) if i.get("name", None) == value])
136
+ arg = f"{filters} {value}"
137
+ self.formatOutputDict.update({options: arg})
138
+
139
+ def build(self):
140
+ for i in self.outputDict:
141
+ if self.setVideoFilters(i):
142
+ continue
143
+ elif self.setAudioFilters(i):
144
+ continue
145
+ else:
146
+ self.setFormat(i)
147
+ lst_extra, vf, af = ([] for _ in range(3))
148
+ for val in self.formatOutputDict:
149
+ if val == "vf":
150
+ vf = self.formatOutputDict.get(val).values()
151
+ vf = ",".join(list(vf))
152
+ elif val == "af":
153
+ af = self.formatOutputDict.get(val).values()
154
+ af = ",".join(list(af))
155
+ else:
156
+ lst_extra.append(self.formatOutputDict.get(val))
157
+ # print(lst_extra, "temp x")
158
+ # if vf:self.vf=f"-vf '{vf}'"
159
+ # if af:self.af=f"-af '{af}'"
160
+ self.vf = f"-vf '{vf}'" if vf else ""
161
+ self.af = f"-af '{af}'" if af else ""
162
+ self.extra = " ".join(lst_extra)
163
+ self.commands = f"{self.vf} {self.af} {self.extra}"
164
+
165
+ def changefunc(self, input: gr.components.IOComponent, c_label="", newValue=""):
166
+ label, *_ = input.label.strip(": ").lower().split(
167
+ ) if type(input.label) != list else "".join(input.label).strip(": ").lower().split()
168
+ label += "".join(_).title()
169
+ if newValue not in [None, "Source", "Auto", "", "None",0]:
170
+ self.outputDict.update({label: newValue})
171
+ else:
172
+ self.outputDict.pop(label, "No Key Exists")
173
+ self.formatOutputDict["vf"].pop(label, "Key is None or similar")
174
+ self.formatOutputDict["af"].pop(label, "Key is None or similar")
175
+ self.formatOutputDict.pop(label, "Key is None or similar")
176
+ self.build()
177
+ print(self.commands," self.commands")
178
+ print(self.vf, self.af, self.extra)
179
+ def startfunc(self, input: gr.components.IOComponent, c_label="", newValue=""):
180
+ label, *_ = input.label.strip(": ").lower().split(
181
+ ) if type(input.label) != list else "".join(input.label).strip(": ").lower().split()
182
+ label += "".join(_).title()
183
+ if newValue not in [None, "Source", "Auto", "", "None",0]:
184
+ self.outputDict.update({label: newValue})
185
+ else:
186
+ self.outputDict.pop(label, "No Key Exists")
187
+ self.formatOutputDict["vf"].pop(label, "Key is None or similar")
188
+ self.formatOutputDict["af"].pop(label, "Key is None or similar")
189
+ self.formatOutputDict.pop(label, "Key is None or similar")
190
+ self.build()
191
+
192
+
193
+
194
+
195
+ def somefunc(input: gr.components.IOComponent, c_label=""):
196
+ label = ""
197
+ output={}
198
+ print(input, c_label)
199
+ label, *_ = input.label.strip(": ").lower().split(
200
+ ) if type(input.label) != list else "".join(input.label).strip(": ").lower().split()
201
+ label += "".join(_).title()
202
+ print(outputMap.get(label), label, c_label)
203
+ if c_label not in [None, "Source", "Auto", ""]:
204
+ print(input.value)
205
+ output.update({label: c_label})
206
+ else:
207
+ output.pop(label, "No Key Exists")
208
+ pprint(output)
209
+
210
+ # def mediaChange(option):
211
+ # no_=gr.update(visible=False)
212
+ # if option in video_containers:
213
+ # output=gr.update(visible=True)
214
+ # return [no_,output]
215
+ # elif option in audio_containers:
216
+ # output=gr.update(visible=True)
217
+ # return [output,no_]
218
+ # else:
219
+ # output=gr.update(visible=False)
220
+ # return [no_,no_]
221
+ def mediaChange(option):
222
+ no_=gr.update(visible=False)
223
+ output=gr.update(visible=True)
224
+ ops={"Audio":gr.update(visible=True)}
225
+ ops2={"Video":gr.update(visible=True)}
226
+ ops3={"File":gr.update(visible=True,interactive=False)}
227
+ # if option.lower()!="mp4" and option in video_containers:
228
+ # option="mp4"
229
+ chosen=lambda x:x.get(option,gr.update(visible=False))
230
+ print(chosen(ops2),ops2.get(option,no_))
231
+ return [chosen(ops),chosen(ops2),chosen(ops3)]
232
+ def videoChange(value):
233
+ print(value.name)
234
+
235
+ # if option in video_containers:
236
+ # output=gr.update(visible=True)
237
+ # return [no_,output]
238
+ # elif option in audio_containers:
239
+ # output=gr.update(visible=True)
240
+ # return [output,no_]
241
+ # else:
242
+ # output=gr.update(visible=False)
243
+ # return [no_,no_]
244
+
245
+
246
+ def customBitrate(choice):
247
+ if choice == "Custom":
248
+ return gr.update(visible=True, value=None)
249
+ else:
250
+ return gr.update(visible=False, value=None)
251
+
252
+
253
+ def supported_codecs(format: str, a=data):
254
+ # lst=[i for i in a["codecs"]["audio"]
255
+ # if i.get("supported")==None or "ogg" in i["supported"]]
256
+ if format:
257
+ format = format.lower()
258
+ video_lst = [val.get("name") for val in a["codecs"]["video"]
259
+ if val.get("supported") == None or format in val["supported"]]
260
+ audio_lst = [val.get("name") for val in a["codecs"]["audio"]
261
+ if val.get("supported") == None or format in val["supported"]]
262
+ return [gr.update(choices=video_lst), gr.update(choices=audio_lst)]
263
+
264
+
265
+ def supported_presets(format: str, a=data):
266
+ if format:
267
+ format = format.lower()
268
+ video_lst = [val.get("name") for val in a["presets"]
269
+ if val.get("supported") == None or format in val["supported"]]
270
+ print(format, video_lst)
271
+ return gr.update(choices=video_lst)
272
+
273
+
274
+ """Helper Functions for Processing """
275
+
276
+
277
+ def clear(*input):
278
+ print(input, " clear_func")
279
+ # for i in [inp for i in input for inp in i]:
280
+ # print(i, hasattr(i,"cleared_value"),type(i))
281
+ # a=default_clear(input_components)
282
+ def clear_func(x): return [component.cleared_value if hasattr(
283
+ component, "cleared_value") else None for component in x]
284
+ print(clear_func(input))
285
+ return clear_func(input)
286
+
287
+
288
+ def change_clipbox(choice):
289
+ print(gr.Dropdown().postprocess("clip test"))
290
+ if choice == "Enabled":
291
+ return [gr.update(visible=True, value="00:00"), gr.update(visible=True, value="00:10")]
292
+ else:
293
+ return [gr.update(visible=False, value=""), gr.update(visible=False, value="")]
294
+
295
+
296
+ def updateOutput(file: _TemporaryFileWrapper):
297
+ if file:
298
+ print(file.name)
299
+ return gr.update(value=file.name)
300
+
301
+
302
+ def get_component_instance(inputs: gr.Blocks) -> list:
303
+ return [gr.components.get_component_instance(i, render=True) for i in inputs.children]
304
+
305
+
306
+ class Clear(CommandBuilder):
307
+ def __call__(self, *args, **kwds):
308
+ return self._component
309
+
310
+ def __str__(self):
311
+ return f"{self._component} __clear__ class"
312
+
313
+ def __repr__(self):
314
+ return self._component
315
+
316
+ def __init__(self, *input_component: gr.Blocks()) -> None:
317
+ self._component = []
318
+ if input_component is not None:
319
+ for i in input_component:
320
+ self._component += super()._get_component_instance(i)
321
+
322
+ def __get_component_instance(self, inputs: gr.Blocks) -> list:
323
+ # print(inputs, " class instance")
324
+ # res=[]
325
+ # for i in inputs.children:
326
+ # print(hasattr(i,"children"))
327
+ # if not (hasattr(i,"children")):
328
+ # res.append(gr.components.get_component_instance(i,render=True))
329
+ # print(i)
330
+ # elif hasattr(i,"children"):
331
+ # continue
332
+ # return res
333
+ return [gr.components.get_component_instance(i, render=True) for i in inputs.children if not hasattr(i, "children")]
334
+
335
+ def add(self, *args):
336
+ print(args, type(args))
337
+ if args is not None:
338
+ for i in args:
339
+ self._component += self.__get_component_instance(i)
340
+ return self._component
341
+
342
+ def clear(self, *args):
343
+ def clear_func(x): return [component.cleared_value if hasattr(
344
+ component, "cleared_value") else component.value for component in x]
345
+ return clear_func(self._component)
mappings.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "protocols": "",
3
+ "startTime": "-ss",
4
+ "stopTime": "-to",
5
+
6
+ "video": "-c:v",
7
+ "audio": "-c:a",
8
+ "bitrate": "-b:v",
9
+ "minrate": "-minrate",
10
+ "maxrate": "-maxrate",
11
+ "bufsize": "-bufsize",
12
+ "gopsize": "-g",
13
+ "pixelFormat": "-pix_fmt",
14
+
15
+ "containers": {
16
+ "video": "-c:v",
17
+ "audio": "-c:a"
18
+ },
19
+ "clipping": {
20
+ "startTime": "-ss",
21
+ "stopTime": "-to"
22
+ },
23
+ "codecs": "",
24
+ "presets": "-preset",
25
+ "passOptions": "-pass",
26
+ "pixelformats": "",
27
+ "frameRates": "-r",
28
+ "speeds": "",
29
+ "tunes": "-tune",
30
+ "profiles": "-profile:v",
31
+ "levels": "",
32
+ "fastStart": "-movflags",
33
+ "sizes": "",
34
+ "formats": "",
35
+ "aspects": "-aspect",
36
+ "scalings": "",
37
+
38
+
39
+ "audioStreams": "",
40
+ "audioChannels": "-ac",
41
+ "audioQualities": "-b:a",
42
+ "sampleRates": "-ar",
43
+
44
+ "deband": "deband",
45
+ "deshake": "deshake",
46
+ "deflicker": "deflicker",
47
+ "dejudder": "dejudder",
48
+ "denoise": {
49
+ "light": "removegrain=22",
50
+ "medium": "vaguedenoiser=threshold=3:method=soft:nsteps=5",
51
+ "heavy": "vaguedenoiser=threshold=6:method=soft:nsteps=5",
52
+ "default": "removegrain=0"
53
+ },
54
+ "deinterlace": {
55
+ "frame": "yadif=0:-1:0",
56
+ "field": "yadif=1:-1:0",
57
+ "frame_nospatial": "yadif=2:-1:0",
58
+ "field_nospatial": "yadif=3:-1:0"
59
+ },
60
+ "extraOptions": "",
61
+ "logLevels": ""
62
+ }
output.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": {
3
+ "container": "mp4",
4
+ "clip": false
5
+ },
6
+ "video": {
7
+ "codec": "libx264",
8
+ "preset": "none",
9
+ "pass": "1",
10
+ "crf": 23,
11
+ "pixel_format": "auto",
12
+ "frame_rate": "auto",
13
+ "speed": "auto",
14
+ "tune": "none",
15
+ "profile": "none",
16
+ "level": "none",
17
+ "faststart": false,
18
+ "size": "source",
19
+ "width": "1080",
20
+ "height": "1920",
21
+ "format": "widescreen",
22
+ "aspect": "auto",
23
+ "scaling": "auto",
24
+ "codec_options": ""
25
+ },
26
+ "audio": {
27
+ "codec": "copy",
28
+ "channel": "source",
29
+ "quality": "auto",
30
+ "sampleRate": "auto",
31
+ "volume": "100"
32
+ },
33
+ "filter": {
34
+ "deband": false,
35
+ "deshake": false,
36
+ "deflicker": false,
37
+ "dejudder": false,
38
+ "denoise": "none",
39
+ "deinterlace": "none",
40
+ "brightness": "0",
41
+ "contrast": "1",
42
+ "saturation": "0",
43
+ "gamma": "0",
44
+ "acontrast": "33"
45
+ }
46
+ }
styles.css ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ #outputtext {
2
+ color: green;
3
+ }
4
+ #aconstrast {
5
+ width: 50%;
6
+ }