Skip to content

Instantly share code, notes, and snippets.

Created August 8, 2019 03:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
This file lets you record using ffmpeg on a raspberry pi, in swift!
// curl -s | sudo bash
// sudo apt-get install swift-lite-rpi
// swift-lite-build raspberry-pi-ffmpeg.swift
// ./raspberry-pi-ffmpeg.swapp
import Foundation
func shell(_ args: String...) -> Process {
let task = Process()
task.executableURL = URL(string: "/usr/bin/env")!
task.arguments = args
//return task.terminationStatus
return task
var ffmpeg: Process?
ffmpeg = shell("ffmpeg",
"-f", "v4l2",
"-i", "/dev/video0",
"-s", "1024x576",
"-c:v", "h264_omx",
"-b:v", "5000k",
"-pix_fmt", "yuv420p",
"-profile:v", "high",
"-c:a", "copy",
"-tune", "zerolatency",
"-vsync", "1",
"-g", "30",
"-y", "/home/pi/Desktop/output.mp4")
DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment