Skip to content

Instantly share code, notes, and snippets.

@PeterGottesman
Created November 4, 2015 21:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeterGottesman/3410e22b851da63190ed to your computer and use it in GitHub Desktop.
Save PeterGottesman/3410e22b851da63190ed to your computer and use it in GitHub Desktop.
ffmpeg recording script python
#!/usr/bin/python3
import argparse
from subprocess import call
from sys import argv
def main():
parser = argparse.ArgumentParser("Recording video and audio using ffmpeg\nMade by Peter Gottesman\n")
parser.add_argument("output", help="Set output file")
parser.add_argument("--vcodec", help="Set video codec")
parser.add_argument("--acodec", help="Set the audio codec. Setting this will enable audio, if it is not set no audio will be recorded")
parser.add_argument("-ox", "--offsetx", type=int, default=1680, help="Set the x offset")
parser.add_argument("-oy", "--offsety", type=int, help="Set the y offset")
parser.add_argument("-r", "--fps", type=int, default=30, help="Set the y offset")
parser.add_argument("-W", "--width", type=int, default=1920, help="Set the y offset")
parser.add_argument("-H", "--height", type=int, default=1080, help="Set the y offset")
parser.add_argument("-ac", "--audio_channels", type=int, default=2, help="Set the y offset")
args = parser.parse_args()
record(args)
def record(args):
output="Unedited/" + args.output
vcodec=args.vcodec
acodec=args.acodec
offsetx=str(args.offsetx)
offsety=str(args.offsety)
fps=str(args.fps)
width=str(args.width)
height=str(args.height)
ac=str(args.audio_channels)
print(args)
cmdstr = "ffmpeg -n -f x11grab -s " + width + "x" + height + " -i :0.0+" + offsetx + "," + offsety + " -ac " + ac + " -f alsa -i pulse -acodec libmp3lame " + output
call(cmdstr, shell=True)
if __name__ == "__main__":
main()
#ffmpeg -f oss -f x11grab -s 1680x1050 -r 60 -i :0.0 -ac 2 -f alsa -i pulse -acodec libmp3lame output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment