|
|
@@ -1,28 +1,33 @@
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
import os
|
|
|
+import sys
|
|
|
from db import db,file_info
|
|
|
from subprocess import Popen,PIPE
|
|
|
-from constants import RAW_PATH,INCOMING_PATH
|
|
|
+from constants import RAW_PATH
|
|
|
|
|
|
d=db()
|
|
|
-for fname in os.listdir(INCOMING_PATH):
|
|
|
- if fname.endswith("flv"):
|
|
|
- out_fname=os.path.join(RAW_PATH, os.path.basename(fname).replace('flv','mp4'))
|
|
|
- in_fname=os.path.join(INCOMING_PATH, fname)
|
|
|
- if os.path.isfile(out_fname):
|
|
|
- #exists
|
|
|
- continue
|
|
|
- process=[ 'ffmpeg',
|
|
|
- '-loglevel', 'error',
|
|
|
- '-i', in_fname,
|
|
|
- '-c', 'copy',
|
|
|
- '-movflags', '+faststart',
|
|
|
- '-f','mp4',
|
|
|
- out_fname
|
|
|
- ]
|
|
|
+if len(sys.argv) != 2:
|
|
|
+ print("Arg: file")
|
|
|
+ sys.exit()
|
|
|
|
|
|
- print(" ".join(process))
|
|
|
- proc=Popen(process, universal_newlines=True)
|
|
|
- proc.wait()
|
|
|
- d.insert_raw(file_info(out_fname))
|
|
|
+fname=sys.argv[1]
|
|
|
+if fname.endswith("flv"):
|
|
|
+ out_fname=os.path.join(RAW_PATH, os.path.basename(fname).replace('flv','mp4'))
|
|
|
+ in_fname=fname
|
|
|
+ if os.path.isfile(out_fname):
|
|
|
+ print("file out exists")
|
|
|
+ sys.exit()
|
|
|
+ process=[ 'ffmpeg',
|
|
|
+ '-loglevel', 'error',
|
|
|
+ '-i', in_fname,
|
|
|
+ '-c', 'copy',
|
|
|
+ '-movflags', '+faststart',
|
|
|
+ '-f','mp4',
|
|
|
+ out_fname
|
|
|
+ ]
|
|
|
+
|
|
|
+ print(" ".join(process))
|
|
|
+ proc=Popen(process, universal_newlines=True)
|
|
|
+ proc.wait()
|
|
|
+ d.insert_raw(file_info(out_fname))
|