Guest User

Simple script to remerge soundfiles

a guest
Nov 26th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import subprocess, shlex, re
  2.  
  3. if __name__ == '__main__':
  4.     file = input("Filename:").replace('"','')
  5.     info = re.search(r'(.+)\[sound=(\S+\.(\S+))\]\.(\S+)', file, flags=re.I)
  6.     original_name = info.group(1).strip()
  7.     url = info.group(2).replace("%2F","/").replace("%3A",":")
  8.     if not re.match("http", url):
  9.         url = "https://" + url
  10.     sound_ext = info.group(3)
  11.     video_ext = info.group(4)
  12.     a_codec = "copy" if sound_ext in ['ogg', 'opus', 'webm'] else "libopus"
  13.     v_codec = "copy" if video_ext == 'webm' else "libvpx-vp9 -pix_fmt yuv420p"
  14.     subprocess.run(shlex.split(r'ffmpeg.exe -i "' + file + r'" -i "' + url + r'" -c:v ' + v_codec + r' -c:a ' + a_codec + r' -y "' + original_name + r'.webm"'))
Add Comment
Please, Sign In to add comment