Skip to content

Commit

Permalink
Added supprt for avconv; python 2.7 compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-r committed Nov 24, 2014
1 parent b74246d commit de5bcfb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
13 changes: 5 additions & 8 deletions dr14tmeter/audio_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,22 @@
import re
import wave
import numpy
import shutil


from io import StringIO

from dr14tmeter.out_messages import print_msg, dr14_log_info
from _ftdi1 import NONE
from dr14tmeter.dr14_global import get_ffmpeg_cmd

#from _ftdi1 import NONE

# ffmpeg -i example.m4a -f wav pipe:1 > test.wav

class AudioFileReader:

def __init__(self):

if shutil.which( "ffmpeg" ) != None :
self.__ffmpeg_cmd = "ffmpeg"
elif shutil.which( "avconv" ) != None :
self.__ffmpeg_cmd = "avconv"
else :
self.__ffmpeg_cmd == ""
self.__ffmpeg_cmd = get_ffmpeg_cmd()

if sys.platform.startswith('win'):
self.__cmd = ".\\decoder\\%s " % self.get_cmd()
Expand Down
20 changes: 19 additions & 1 deletion dr14tmeter/dr14_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import sys
import re
import threading
import subprocess

from dr14tmeter.out_messages import print_msg

Expand All @@ -36,6 +37,8 @@

lock_ver = threading.Lock()

ffmpeg_cmd = None


def dr14_version():
global v_major
Expand All @@ -49,12 +52,27 @@ def min_dr() :
def get_exe_name():
return "dr14_tmeter"

def get_ffmpeg_cmd():

global ffmpeg_cmd

if ffmpeg_cmd == None :
ffmpeg_f = subprocess.call("type " + "ffmpeg" , shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) == 0
avconv_f = subprocess.call("type " + "avconv" , shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) == 0

if ffmpeg_f :
ffmpeg_cmd = "ffmpeg"
elif avconv_f :
ffmpeg_cmd = "avconv"

return ffmpeg_cmd


class TestVer(threading.Thread):
def run(self):
_dr14_get_latest_version()



def _dr14_get_latest_version():

global l_major
Expand Down
7 changes: 3 additions & 4 deletions dr14tmeter/read_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import sys
import os
import re
import shutil


from dr14tmeter.audio_decoder import AudioDecoder
from dr14tmeter.dr14_global import get_ffmpeg_cmd

# Test example !!!!!
# a = subprocess.check_output( [ "ffprobe" , "-show_format" , "/media/esterno_xfs/data/Musica/Musica/aavv/01-blitzkrieg_bop_160_lame_abr.mp3" ] , stderr=subprocess.STDOUT , shell=False )
Expand All @@ -35,9 +34,9 @@ def __init__( self ):
self._artist = {}
self._tracks = {}

if shutil.which( "ffprobe" ) :
if get_ffmpeg_cmd() == "ffmpeg" :
self.__ffprobe_cmd = "ffprobe"
elif shutil.which( "avprobe" ) :
elif get_ffmpeg_cmd() == "avconv" :
self.__ffprobe_cmd = "avprobe"


Expand Down

0 comments on commit de5bcfb

Please sign in to comment.