Skip to content

Instantly share code, notes, and snippets.

@ps173
Last active May 4, 2021 16:19
Show Gist options
  • Save ps173/74f1efc146aea1b6652fc0ae8e96416b to your computer and use it in GitHub Desktop.
Save ps173/74f1efc146aea1b6652fc0ae8e96416b to your computer and use it in GitHub Desktop.
A converter for webm format (requires ffmpeg)
#-*- coding:utf-8 -*-
# Webm converter for audio streams and video streams (can only convert audio to audio and video to video)
import subprocess
import sys
def convert_to_audio(filename):
command = ['ffmpeg', '-i', filename , 'out.mp3']
subprocess.run(command,stdout=subprocess.PIPE,stdin=subprocess.PIPE)
def convert_to_video(filename):
command = ['ffmpeg', '-i', filename , 'out.mp4']
subprocess.run(command,stdout=subprocess.PIPE,stdin=subprocess.PIPE)
def main():
ask = input("what conversion do you want ? (mp3 or mp4 are option)")
if ask == "mp4":
file = input("what is file path ??\n")
convert_to_video(file)
if ask == "mp3":
file = input("what is file path ??\n")
convert_to_audio(file)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment