diff --git a/README.md b/README.md index 18db686..b00c90d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ X Window Recording Tool ffmpeg configuration -------------------- -The ffmpeg configuration requires the following for xcorder to work properly: -> --extra-libs=-lasound -> --enable-x11grab +The ffmpeg build configuration requires the following for xcorder to work properly: +> `--extra-libs=-lasound` or `--enable-libpulse` + +and + +> `--enable-x11grab` diff --git a/audio.py b/audio.py index aaf8525..3d1ace6 100644 --- a/audio.py +++ b/audio.py @@ -22,6 +22,20 @@ def __init__(self): self._devices = list() self._device = Device() + args = 'ffmpeg -formats -v 0' + popen = subprocess.Popen(args, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + alsa = pulse = False + for line in popen.stdout: + if "alsa" in line: + alsa = True + elif "pulse" in line: + pulse = True + + if not alsa and not pulse: + raise Exception("available ffmpeg installation have not lasound or libpulse enabled") + args = 'pacmd list-sources' popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -34,7 +48,10 @@ def __init__(self): device.name = line.split(':', 1)[1].strip() elif line.startswith('device.api = '): - device.api = line.split('=', 1)[1].strip().strip('"') + api = line.split('=', 1)[1].strip().strip('"') + if api == "alsa" and not alsa: + api = "pulse" + device.api = api elif line.startswith('alsa.subdevice = '): device.subdevice = line.split('=', 1)[1].strip().strip('"') @@ -87,7 +104,8 @@ def __init__(self, name=None, api=None, subdevice=None, card=None, # ========================================================================= @property def source(self): - + if self.api == "pulse": + return '{deviceName}'.format(deviceName=self.name[1:-1]) return 'plughw:{c},{s}'.format(c=self.card, s=self.subdevice) # ========================================================================= diff --git a/exporter.py b/exporter.py index 1bce828..a142cfb 100644 --- a/exporter.py +++ b/exporter.py @@ -15,6 +15,9 @@ # ============================================================================= # CLASSES # ============================================================================= +import os + + class Exporter(object): # ========================================================================= @@ -27,6 +30,7 @@ def __init__(self, workDir=None, exportFile=None): # ========================================================================= def start(self): + print self.args self.makeFileList() if not self._proc: self._proc = subprocess.Popen(self.args, shell=True, @@ -53,7 +57,7 @@ def makeFileList(self): with open(self.fileList, 'w') as fileList: for segmentFile in segmentFiles: - fileList.write("file '{f}'\n".format(f=segmentFile)) + fileList.write("file '{f}'\n".format(f=os.path.basename(segmentFile))) # ========================================================================= @property diff --git a/xcorder b/xcorder index 57a5948..aa20387 100755 --- a/xcorder +++ b/xcorder @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/bin/env python2 # ============================================================================= # Module: xcorder # Contacts: Edward Li (drawdeil@gmail.com)