From patchwork Thu Jun 13 05:30:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 13521 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6191C449374 for ; Thu, 13 Jun 2019 08:32:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4DE90680679; Thu, 13 Jun 2019 08:32:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 95B46680223 for ; Thu, 13 Jun 2019 08:32:31 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2019 22:32:29 -0700 X-ExtLoop1: 1 Received: from yguo18-skl-u1604.sh.intel.com ([10.239.13.25]) by orsmga003.jf.intel.com with ESMTP; 12 Jun 2019 22:32:27 -0700 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jun 2019 13:30:52 +0800 Message-Id: <1560403852-9735-1-git-send-email-yejun.guo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH V3 3/3] tools/python: move .py scripts from tools to tools/python X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" so, all the .py scripts will be under tools/python/ Signed-off-by: Guo, Yejun --- tools/normalize.py | 33 --------------------------------- tools/python/normalize.py | 33 +++++++++++++++++++++++++++++++++ tools/python/zmqshell.py | 26 ++++++++++++++++++++++++++ tools/zmqshell.py | 26 -------------------------- 4 files changed, 59 insertions(+), 59 deletions(-) delete mode 100755 tools/normalize.py create mode 100755 tools/python/normalize.py create mode 100755 tools/python/zmqshell.py delete mode 100755 tools/zmqshell.py diff --git a/tools/normalize.py b/tools/normalize.py deleted file mode 100755 index 7d87c5e..0000000 --- a/tools/normalize.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python2 - -import sys, subprocess - -if len(sys.argv) > 2: - ifile = sys.argv[1] - encopt = sys.argv[2:-1] - ofile = sys.argv[-1] -else: - print 'usage: %s [encode_options] ' % sys.argv[0] - sys.exit(1) - -analysis_cmd = 'ffprobe -v error -of compact=p=0:nk=1 ' -analysis_cmd += '-show_entries frame_tags=lavfi.r128.I -f lavfi ' -analysis_cmd += "amovie='%s',ebur128=metadata=1" % ifile -try: - probe_out = subprocess.check_output(analysis_cmd, shell=True) -except subprocess.CalledProcessError, e: - sys.exit(e.returncode) -loudness = ref = -23 -for line in probe_out.splitlines(): - sline = line.rstrip() - if sline: - loudness = sline -adjust = ref - float(loudness) -if abs(adjust) < 0.0001: - print 'No normalization needed for ' + ifile -else: - print "Adjust %s by %.1fdB" % (ifile, adjust) - norm_cmd = ['ffmpeg', '-i', ifile, '-af', 'volume=%fdB' % adjust] - norm_cmd += encopt + [ofile] - print ' => %s' % ' '.join(norm_cmd) - subprocess.call(norm_cmd) diff --git a/tools/python/normalize.py b/tools/python/normalize.py new file mode 100755 index 0000000..7d87c5e --- /dev/null +++ b/tools/python/normalize.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python2 + +import sys, subprocess + +if len(sys.argv) > 2: + ifile = sys.argv[1] + encopt = sys.argv[2:-1] + ofile = sys.argv[-1] +else: + print 'usage: %s [encode_options] ' % sys.argv[0] + sys.exit(1) + +analysis_cmd = 'ffprobe -v error -of compact=p=0:nk=1 ' +analysis_cmd += '-show_entries frame_tags=lavfi.r128.I -f lavfi ' +analysis_cmd += "amovie='%s',ebur128=metadata=1" % ifile +try: + probe_out = subprocess.check_output(analysis_cmd, shell=True) +except subprocess.CalledProcessError, e: + sys.exit(e.returncode) +loudness = ref = -23 +for line in probe_out.splitlines(): + sline = line.rstrip() + if sline: + loudness = sline +adjust = ref - float(loudness) +if abs(adjust) < 0.0001: + print 'No normalization needed for ' + ifile +else: + print "Adjust %s by %.1fdB" % (ifile, adjust) + norm_cmd = ['ffmpeg', '-i', ifile, '-af', 'volume=%fdB' % adjust] + norm_cmd += encopt + [ofile] + print ' => %s' % ' '.join(norm_cmd) + subprocess.call(norm_cmd) diff --git a/tools/python/zmqshell.py b/tools/python/zmqshell.py new file mode 100755 index 0000000..a7d1126 --- /dev/null +++ b/tools/python/zmqshell.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python2 + +import sys, zmq, cmd + +class LavfiCmd(cmd.Cmd): + prompt = 'lavfi> ' + + def __init__(self, bind_address): + context = zmq.Context() + self.requester = context.socket(zmq.REQ) + self.requester.connect(bind_address) + cmd.Cmd.__init__(self) + + def onecmd(self, cmd): + if cmd == 'EOF': + sys.exit(0) + print 'Sending command:[%s]' % cmd + self.requester.send(cmd) + message = self.requester.recv() + print 'Received reply:[%s]' % message + +try: + bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:5555" + LavfiCmd(bind_address).cmdloop('FFmpeg libavfilter interactive shell') +except KeyboardInterrupt: + pass diff --git a/tools/zmqshell.py b/tools/zmqshell.py deleted file mode 100755 index a7d1126..0000000 --- a/tools/zmqshell.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python2 - -import sys, zmq, cmd - -class LavfiCmd(cmd.Cmd): - prompt = 'lavfi> ' - - def __init__(self, bind_address): - context = zmq.Context() - self.requester = context.socket(zmq.REQ) - self.requester.connect(bind_address) - cmd.Cmd.__init__(self) - - def onecmd(self, cmd): - if cmd == 'EOF': - sys.exit(0) - print 'Sending command:[%s]' % cmd - self.requester.send(cmd) - message = self.requester.recv() - print 'Received reply:[%s]' % message - -try: - bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:5555" - LavfiCmd(bind_address).cmdloop('FFmpeg libavfilter interactive shell') -except KeyboardInterrupt: - pass