lazarusking commited on
Commit
0a40676
1 Parent(s): a75af1e

mapped codecs

Browse files
Files changed (5) hide show
  1. .gitignore +1 -0
  2. app.py +4 -7
  3. codecs.json +3 -1
  4. functions.py +6 -3
  5. new_mappings.json +1 -1
.gitignore CHANGED
@@ -2,4 +2,5 @@ __pycache__/
2
  *.pyc
3
  flagged/
4
  .venv
 
5
  requirements.txt
 
2
  *.pyc
3
  flagged/
4
  .venv
5
+ docs/
6
  requirements.txt
app.py CHANGED
@@ -13,8 +13,6 @@ from functions import (Clear, CommandBuilder, audio_channels, audio_codecs,
13
 
14
  logging.basicConfig(level=logging.INFO)
15
 
16
- choices = ["mp3", "ogg", "flac", "wav"]
17
-
18
 
19
  logging.info(msg=f"{video_containers}")
20
 
@@ -35,14 +33,14 @@ def convert(file: _TemporaryFileWrapper, options: str):
35
  print(ffmpeg)
36
  print(ffmpeg.cmd)
37
 
38
- stdout, stderr=ffmpeg.run(stderr=subprocess.PIPE)
39
- logging.info(f"{stdout} {stderr}")
40
  output=f"{ffmpeg.cmd}"
41
  # video=gr.update(label=output_file,value=output_file)
42
 
43
  except Exception as e:
44
  stderr=e
45
- output=f"{ffmpeg.cmd} {stderr}"
46
  return [None,None,None,output]
47
 
48
  return [output_file,output_file,output_file,output]
@@ -80,7 +78,7 @@ with gr.Blocks(css="./styles.css") as dm:
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.JSON(elem_id="outputtext")
84
 
85
  resetFormat=Clear(inputs,inputs_clip)
86
  clearBtn.click(resetFormat.clear, inputs=resetFormat(), outputs=resetFormat())
@@ -143,7 +141,6 @@ with gr.Blocks(css="./styles.css") as dm:
143
  # ffmpeg_commands.do()
144
  dm.load(fn=ffmpeg_commands.reset,inputs=[],outputs=[])
145
  pprint(ffmpeg_commands.commands)
146
- state=gr.Variable()
147
  ffmpeg_commands.update(output_textbox)
148
  # file_input.change(fn=updateOutput,inputs=file_input,outputs=output_textbox)
149
  clip.change(fn=change_clipbox, inputs=clip,
 
13
 
14
  logging.basicConfig(level=logging.INFO)
15
 
 
 
16
 
17
  logging.info(msg=f"{video_containers}")
18
 
 
33
  print(ffmpeg)
34
  print(ffmpeg.cmd)
35
 
36
+ ffmpeg.run(stderr=subprocess.PIPE)
37
+ # pprint(f"{stdout} {stderr}")
38
  output=f"{ffmpeg.cmd}"
39
  # video=gr.update(label=output_file,value=output_file)
40
 
41
  except Exception as e:
42
  stderr=e
43
+ output=f"{stderr}"
44
  return [None,None,None,output]
45
 
46
  return [output_file,output_file,output_file,output]
 
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())
 
141
  # ffmpeg_commands.do()
142
  dm.load(fn=ffmpeg_commands.reset,inputs=[],outputs=[])
143
  pprint(ffmpeg_commands.commands)
 
144
  ffmpeg_commands.update(output_textbox)
145
  # file_input.change(fn=updateOutput,inputs=file_input,outputs=output_textbox)
146
  clip.change(fn=change_clipbox, inputs=clip,
codecs.json CHANGED
@@ -17,7 +17,9 @@
17
  "dts": "dca",
18
  "ac3": "ac3",
19
  "vorbis": "libvorbis",
20
- "opus": "libopus"
 
 
21
  },
22
  "copy": "copy"
23
  }
 
17
  "dts": "dca",
18
  "ac3": "ac3",
19
  "vorbis": "libvorbis",
20
+ "opus": "libopus",
21
+ "lame":"libmp3lame",
22
+ "pcm":"pcm_s16le"
23
  },
24
  "copy": "copy"
25
  }
functions.py CHANGED
@@ -106,7 +106,6 @@ class CommandBuilder():
106
  label += "".join(_).title()
107
  key = newoutputMap.get(label)
108
  lst_extra, vf, af = ([] for _ in range(3))
109
-
110
  if newValue not in [None, "Source", "Auto", "", "None", "none", 0]:
111
  self.setVf(label, newValue)
112
  self.setAf(label, newValue)
@@ -157,7 +156,11 @@ class CommandBuilder():
157
  """
158
  if newoutputMap.get(label):
159
  key = newoutputMap.get(label)
160
- if label in ["video", "audio", "startTime", "stopTime"]:
 
 
 
 
161
  self.outputDict.update({key: newValue})
162
  else:
163
  value = "".join([i.get("value", "None") for i in data.get(
@@ -357,7 +360,7 @@ def mediaChange(option:str)-> List[Component]:
357
 
358
  def customBitrate(choice:int)-> Component:
359
  """
360
- Toggle acomponent for custom Audio Quality
361
  visible/none
362
  Args:
363
  choice : Custom audio quality
 
106
  label += "".join(_).title()
107
  key = newoutputMap.get(label)
108
  lst_extra, vf, af = ([] for _ in range(3))
 
109
  if newValue not in [None, "Source", "Auto", "", "None", "none", 0]:
110
  self.setVf(label, newValue)
111
  self.setAf(label, newValue)
 
156
  """
157
  if newoutputMap.get(label):
158
  key = newoutputMap.get(label)
159
+ if label in ["video", "audio"]:
160
+ value=codecs.get(label).get(newValue,newValue)
161
+ print(value)
162
+ self.outputDict.update({key:value})
163
+ elif label in ["startTime", "stopTime"]:
164
  self.outputDict.update({key: newValue})
165
  else:
166
  value = "".join([i.get("value", "None") for i in data.get(
 
360
 
361
  def customBitrate(choice:int)-> Component:
362
  """
363
+ Toggle a component for custom Audio Quality
364
  visible/none
365
  Args:
366
  choice : Custom audio quality
new_mappings.json CHANGED
@@ -18,7 +18,7 @@
18
  }
19
  },
20
  "af": {
21
- "acontrast": 0
22
  },
23
  "protocols": "",
24
  "startTime": "-ss",
 
18
  }
19
  },
20
  "af": {
21
+ "acontrast": "0"
22
  },
23
  "protocols": "",
24
  "startTime": "-ss",