Spaces:
Sleeping
Sleeping
lazarusking
commited on
Commit
·
4e9ce92
1
Parent(s):
3b2d2d7
internal layout change and src state
Browse files- app.py +27 -21
- styles.css +4 -1
app.py
CHANGED
|
@@ -17,7 +17,7 @@ logging.basicConfig(level=logging.INFO)
|
|
| 17 |
logging.info(msg=f"{video_containers}")
|
| 18 |
|
| 19 |
|
| 20 |
-
def convert(file: _TemporaryFileWrapper, options: str):
|
| 21 |
stderr=""
|
| 22 |
stdout=""
|
| 23 |
output_file=""
|
|
@@ -43,7 +43,9 @@ def convert(file: _TemporaryFileWrapper, options: str):
|
|
| 43 |
output=f"{stderr}"
|
| 44 |
return [None,None,None,output]
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
with gr.Blocks(css="./styles.css") as dm:
|
|
@@ -56,34 +58,37 @@ with gr.Blocks(css="./styles.css") as dm:
|
|
| 56 |
options = gr.Radio(
|
| 57 |
label="options", choices=containers,value=containers[0])
|
| 58 |
with gr.Row():
|
| 59 |
-
clip = gr.Dropdown(
|
| 60 |
-
choices=["None", "Enabled"], label="Clip:", value="None")
|
| 61 |
with gr.Row() as inputs_clip:
|
|
|
|
|
|
|
| 62 |
start_time = gr.Textbox(
|
| 63 |
-
label="Start Time:", placeholder="00:00", visible=False)
|
| 64 |
stop_time = gr.Textbox(
|
| 65 |
label="Stop Time:", placeholder="00:00", visible=False)
|
| 66 |
-
with gr.Row()
|
| 67 |
clearBtn = gr.Button("Clear")
|
| 68 |
convertBtn = gr.Button("Convert", variant="primary")
|
| 69 |
|
| 70 |
# Output Buttons
|
| 71 |
with gr.Column():
|
| 72 |
# media_output = gr.Audio(label="Output")
|
| 73 |
-
with gr.Row()
|
| 74 |
video_button=gr.Button("Video")
|
| 75 |
audio_button=gr.Button("Audio")
|
| 76 |
file_button=gr.Button("File")
|
| 77 |
-
media_output_audio = gr.Audio(label="Output",visible=True,interactive=False,source="filepath")
|
| 78 |
media_output_video = gr.Video(label="Output",visible=False,format="mp4")
|
| 79 |
media_output_file = gr.File(label="Output",visible=False)
|
| 80 |
with gr.Row() as command_output:
|
| 81 |
-
output_textbox = gr.Textbox(elem_id="outputtext")
|
| 82 |
|
| 83 |
resetFormat=Clear(inputs,inputs_clip)
|
|
|
|
|
|
|
|
|
|
| 84 |
clearBtn.click(resetFormat.clear, inputs=resetFormat(), outputs=resetFormat())
|
| 85 |
-
convertBtn.click(convert, inputs=[file_input, options], outputs=[
|
| 86 |
-
media_output_audio,media_output_file,media_output_video, output_textbox])
|
| 87 |
|
| 88 |
with gr.TabItem("Video"):
|
| 89 |
with gr.Row() as video_inputs:
|
|
@@ -92,13 +97,14 @@ with gr.Blocks(css="./styles.css") as dm:
|
|
| 92 |
preset_options = gr.Dropdown(choices=presets, label="presets",value=presets[-1])
|
| 93 |
|
| 94 |
|
| 95 |
-
with gr.
|
| 96 |
-
|
|
|
|
| 97 |
videoReset=Clear(video_inputs)
|
| 98 |
clearBtn.click(videoReset.clear, videoReset(), videoReset())
|
| 99 |
|
| 100 |
with gr.TabItem("Audio"):
|
| 101 |
-
with gr.Row()
|
| 102 |
# print(names[0])
|
| 103 |
audio_options = gr.Dropdown(
|
| 104 |
label="audio", choices=audio_codecs, value=audio_codecs[-1])
|
|
@@ -111,7 +117,7 @@ with gr.Blocks(css="./styles.css") as dm:
|
|
| 111 |
label="Sample Rates", value=audio_sample_rates[0])
|
| 112 |
|
| 113 |
|
| 114 |
-
with gr.Column():
|
| 115 |
clearBtn = gr.Button("Clear")
|
| 116 |
audioReset=Clear(audio_inputs)
|
| 117 |
clearBtn.click(audioReset.clear, audioReset(), audioReset())
|
|
@@ -127,10 +133,10 @@ with gr.Blocks(css="./styles.css") as dm:
|
|
| 127 |
a=gr.Dropdown(label=list(i.keys()),
|
| 128 |
choices=choices, value=choices[0])
|
| 129 |
gr.Markdown("## Audio")
|
| 130 |
-
with gr.Row() as filter_inputs_1:
|
| 131 |
-
acontrastSlider=gr.Slider(label="Acontrast", elem_id="
|
| 132 |
|
| 133 |
-
with gr.Column():
|
| 134 |
clearBtn = gr.Button("Clear")
|
| 135 |
|
| 136 |
filterReset=Clear(filter_inputs,filter_inputs_1)
|
|
@@ -149,10 +155,10 @@ with gr.Blocks(css="./styles.css") as dm:
|
|
| 149 |
options.change(supported_codecs,[options],[video_options,audio_options])
|
| 150 |
# options.change(mediaChange,[options],[media_output_audio,media_output_video])
|
| 151 |
# video_button.click(fn=videoChange,inputs=media_output_file,outputs=media_output_video)
|
| 152 |
-
audio_button.click(mediaChange,[audio_button],[media_output_audio,media_output_video,media_output_file])
|
| 153 |
-
video_button.click(mediaChange,[video_button],[media_output_audio,media_output_video,media_output_file])
|
| 154 |
# media_output_audio.change(lambda x:gr.update(value=x),[media_output_audio],[media_output_video])
|
| 155 |
-
file_button.click(mediaChange,[file_button],[media_output_audio,media_output_video,media_output_file])
|
| 156 |
"""Video Tab change functions"""
|
| 157 |
video_options.change(supported_presets,[video_options],[preset_options])
|
| 158 |
"""Audio Tab change functions"""
|
|
|
|
| 17 |
logging.info(msg=f"{video_containers}")
|
| 18 |
|
| 19 |
|
| 20 |
+
def convert(file: _TemporaryFileWrapper, options: str,state):
|
| 21 |
stderr=""
|
| 22 |
stdout=""
|
| 23 |
output_file=""
|
|
|
|
| 43 |
output=f"{stderr}"
|
| 44 |
return [None,None,None,output]
|
| 45 |
|
| 46 |
+
state=output_file
|
| 47 |
+
|
| 48 |
+
return [output_file,output_file,output_file,output,state]
|
| 49 |
|
| 50 |
|
| 51 |
with gr.Blocks(css="./styles.css") as dm:
|
|
|
|
| 58 |
options = gr.Radio(
|
| 59 |
label="options", choices=containers,value=containers[0])
|
| 60 |
with gr.Row():
|
|
|
|
|
|
|
| 61 |
with gr.Row() as inputs_clip:
|
| 62 |
+
clip = gr.Dropdown(
|
| 63 |
+
choices=["None", "Enabled"], label="Clip:", value="None")
|
| 64 |
start_time = gr.Textbox(
|
| 65 |
+
label="Start Time:", placeholder="00:00", visible=False,interactive=True)
|
| 66 |
stop_time = gr.Textbox(
|
| 67 |
label="Stop Time:", placeholder="00:00", visible=False)
|
| 68 |
+
with gr.Row():
|
| 69 |
clearBtn = gr.Button("Clear")
|
| 70 |
convertBtn = gr.Button("Convert", variant="primary")
|
| 71 |
|
| 72 |
# Output Buttons
|
| 73 |
with gr.Column():
|
| 74 |
# media_output = gr.Audio(label="Output")
|
| 75 |
+
with gr.Row():
|
| 76 |
video_button=gr.Button("Video")
|
| 77 |
audio_button=gr.Button("Audio")
|
| 78 |
file_button=gr.Button("File")
|
| 79 |
+
media_output_audio = gr.Audio(type="filepath",label="Output",visible=True,interactive=False,source="filepath")
|
| 80 |
media_output_video = gr.Video(label="Output",visible=False,format="mp4")
|
| 81 |
media_output_file = gr.File(label="Output",visible=False)
|
| 82 |
with gr.Row() as command_output:
|
| 83 |
+
output_textbox = gr.Textbox(label="command",elem_id="outputtext")
|
| 84 |
|
| 85 |
resetFormat=Clear(inputs,inputs_clip)
|
| 86 |
+
print(inputs_clip.children)
|
| 87 |
+
print(resetFormat)
|
| 88 |
+
state=gr.Variable()
|
| 89 |
clearBtn.click(resetFormat.clear, inputs=resetFormat(), outputs=resetFormat())
|
| 90 |
+
convertBtn.click(convert, inputs=[file_input, options,state], outputs=[
|
| 91 |
+
media_output_audio,media_output_file,media_output_video, output_textbox,state])
|
| 92 |
|
| 93 |
with gr.TabItem("Video"):
|
| 94 |
with gr.Row() as video_inputs:
|
|
|
|
| 97 |
preset_options = gr.Dropdown(choices=presets, label="presets",value=presets[-1])
|
| 98 |
|
| 99 |
|
| 100 |
+
with gr.Row(elem_id="button"):
|
| 101 |
+
with gr.Column():
|
| 102 |
+
clearBtn = gr.Button("Clear")
|
| 103 |
videoReset=Clear(video_inputs)
|
| 104 |
clearBtn.click(videoReset.clear, videoReset(), videoReset())
|
| 105 |
|
| 106 |
with gr.TabItem("Audio"):
|
| 107 |
+
with gr.Row() as audio_inputs:
|
| 108 |
# print(names[0])
|
| 109 |
audio_options = gr.Dropdown(
|
| 110 |
label="audio", choices=audio_codecs, value=audio_codecs[-1])
|
|
|
|
| 117 |
label="Sample Rates", value=audio_sample_rates[0])
|
| 118 |
|
| 119 |
|
| 120 |
+
with gr.Column(elem_id="button"):
|
| 121 |
clearBtn = gr.Button("Clear")
|
| 122 |
audioReset=Clear(audio_inputs)
|
| 123 |
clearBtn.click(audioReset.clear, audioReset(), audioReset())
|
|
|
|
| 133 |
a=gr.Dropdown(label=list(i.keys()),
|
| 134 |
choices=choices, value=choices[0])
|
| 135 |
gr.Markdown("## Audio")
|
| 136 |
+
with gr.Row(elem_id="acontrast") as filter_inputs_1:
|
| 137 |
+
acontrastSlider=gr.Slider(label="Acontrast", elem_id="acontrast")
|
| 138 |
|
| 139 |
+
with gr.Column(elem_id="button"):
|
| 140 |
clearBtn = gr.Button("Clear")
|
| 141 |
|
| 142 |
filterReset=Clear(filter_inputs,filter_inputs_1)
|
|
|
|
| 155 |
options.change(supported_codecs,[options],[video_options,audio_options])
|
| 156 |
# options.change(mediaChange,[options],[media_output_audio,media_output_video])
|
| 157 |
# video_button.click(fn=videoChange,inputs=media_output_file,outputs=media_output_video)
|
| 158 |
+
audio_button.click(mediaChange,[audio_button,state],[media_output_audio,media_output_video,media_output_file])
|
| 159 |
+
video_button.click(mediaChange,[video_button,state],[media_output_audio,media_output_video,media_output_file])
|
| 160 |
# media_output_audio.change(lambda x:gr.update(value=x),[media_output_audio],[media_output_video])
|
| 161 |
+
file_button.click(mediaChange,[file_button,state],[media_output_audio,media_output_video,media_output_file])
|
| 162 |
"""Video Tab change functions"""
|
| 163 |
video_options.change(supported_presets,[video_options],[preset_options])
|
| 164 |
"""Audio Tab change functions"""
|
styles.css
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
#outputtext {
|
| 2 |
color: green;
|
| 3 |
}
|
| 4 |
-
#
|
| 5 |
width: 50%;
|
| 6 |
}
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#outputtext {
|
| 2 |
color: green;
|
| 3 |
}
|
| 4 |
+
#acontrast {
|
| 5 |
width: 50%;
|
| 6 |
}
|
| 7 |
+
#button{
|
| 8 |
+
width: 30%
|
| 9 |
+
}
|