<commit_before>import subprocess

AUDIO, VIDEO, SCREEN = 0, 1, 2
LINUX, MAC, WINDOWS = 0, 1, 2

# src: http://stackoverflow.com/a/377028/1044366
def which(program):
    import os
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None

def detectPlatform():
    import sys
    if sys.platform.startswith('linux'):
        return LINUX
    elif sys.platform.startswith('win') or sys.platform.startswith('cyg'):
        return WINDOWS
    elif sys.platform.startswith('darwin'):
        return MAC
    else:
        return None

class FFmpeg(object):
    def __init__(self):
        # check if ffmpeg is installed on the system
        if not which('ffmpeg'):
            raise Exception('FFmpeg is not installed!')

        self.pid = 0

        self.formats = {
            LINUX: 'video4linux2',
            MAC: 'avfoundation',
            WINDOWS: ''
        }

        self.audioDevices = {
            LINUX: '', # TODO
            MAC: 'none:0'
        }

        self.videoDevices = {
            LINUX: '/dev/video0',  # try to detect this,
            MAC: '0:0'
        }

        self.screenDevices = {
            LINUX: '', # TODO
            MAC: '1:none'
        }

        platform = detectPlatform()

        self.cmds = {
            AUDIO: [
                ('-f', self.formats[platform]),
                ('-i', self.audioDevices[platform]),
                ('-y',),
                ('-vn',),
                ('-c:a', 'aac')
            ],
            # VIDEO: [
            #     ('-f', self.formats[platform]),
            #     ('-c:v', 'rawvideo'),
            #     ('-i', self.videoDevices[platform]),
            #     ('-qscale:v', '5'),
            #     ('-y',),
            #     ('-f', 'mp4'),
            #     ('-c:v', 'mpeg4'),
            #     ('-c:a', 'aac') 
            # ],
            VIDEO: [
                ('-r', '30'),
                ('-f', self.formats[platform]),
                ('-i', self.videoDevices[platform])
            ],
            SCREEN: [
                ('-r', '30'),
                ('-f', self.formats[platform]),
                ('-c:v', 'rawvideo'),
                ('-an',),
                ('-i', self.screenDevices[platform]),<commit_msg>fix camera upload on capture.py<commit_after>import subprocess

AUDIO, VIDEO, SCREEN = 0, 1, 2
LINUX, MAC, WINDOWS = 0, 1, 2

# src: http://stackoverflow.com/a/377028/1044366
def which(program):
    import os
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None

def detectPlatform():
    import sys
    if sys.platform.startswith('linux'):
        return LINUX
    elif sys.platform.startswith('win') or sys.platform.startswith('cyg'):
        return WINDOWS
    elif sys.platform.startswith('darwin'):
        return MAC
    else:
        return None

class FFmpeg(object):
    def __init__(self):
        # check if ffmpeg is installed on the system
        if not which('ffmpeg'):
            raise Exception('FFmpeg is not installed!')

        self.pid = 0

        self.formats = {
            LINUX: 'video4linux2',
            MAC: 'avfoundation',
            WINDOWS: ''
        }

        self.audioDevices = {
            LINUX: '', # TODO
            MAC: 'none:0'
        }

        self.videoDevices = {
            LINUX: '/dev/video0',  # try to detect this,
            MAC: '0:0'
        }

        self.screenDevices = {
            LINUX: '', # TODO
            MAC: '1:none'
        }

        platform = detectPlatform()

        self.cmds = {
            AUDIO: [
                ('-f', self.formats[platform]),
                ('-i', self.audioDevices[platform]),
                ('-y',),
                ('-vn',),
                ('-c:a', 'aac')
            ],
            # VIDEO: [
            #     ('-f', self.formats[platform]),
            #     ('-c:v', 'rawvideo'),
            #     ('-i', self.videoDevices[platform]),
            #     ('-qscale:v', '5'),
            #     ('-y',),
            #     ('-f', 'mp4'),
            #     ('-c:v', 'mpeg4'),
            #     ('-c:a', 'aac') 
            # ],
            VIDEO: [
                ('-r', '30'),
                ('-f', self.formats[platform]),
                ('-i', self.videoDevices[platform]),
                ('-y')
            ],
            SCREEN: [
                ('-r', '30'),
                ('-f', self.formats[platform]),
                ('-c:v', 'rawvideo'),
                ('-an',),
                ('-i', self.screenDevices[platform]),
{'fraction_non_alphanumeric': 0.1555683122847302, 'fraction_numerical': 0.013011863758132415, 'mean_word_length': 1.3502697841726619, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1829981', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1612, 'n_words': 334}