Advertisement
Typhoon

FFMPEG Encoding v.1

Jul 13th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import datetime
  4. import os
  5. import subprocess
  6.  
  7. path = '/opt/data/encoding/'
  8. tv = ["joj", "stv", "markiza", "ta3"]
  9. now = datetime.datetime.now()
  10.  
  11.  
  12. def media_detect(filename):
  13.     for tv_station in tv:
  14.         if tv_station in filename.lower():
  15.             return "TV"
  16.  
  17.  
  18. for subdir, dirs, files in os.walk(path):
  19.     for file in files:
  20.         file_name = os.path.splitext(file)[0]
  21.         outfile_name = path + file_name + ".mp3"
  22.         # assert file.lower().endswith( '.ts' )
  23.         print "#####################"
  24.         print "Start Time: " + now.strftime("%Y-%m-%d %H:%M")
  25.         print file
  26.         if media_detect(file) == "TV":
  27.             print file_name
  28.             print "Televizia"
  29.             # subprocess.call(["ls", "-l", path + file])
  30.         else:
  31.             print file_name
  32.             print "Radio"
  33.             cmd = 'ffmpeg -i %s -ab 32k %s' % (path + file, outfile_name)
  34.             print cmd
  35.             subprocess.call([cmd, "-y"], shell=True)
  36.             print "Stop Time: " + now.strftime("%Y-%m-%d %H:%M")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement