"""
prog_bin = "ffmpeg"
- info_prog_bin = "ffprobe"
log_file = 'log/FFmpegThumbExtractor.log'
'FFmpeg created an empty file.')
def get_video_duration(self):
- args = self.info_prog_bin + ' -show_format "' \
- + self.input_file + '"'
+ return FFmpegAVInfo.get_video_duration(self.input_file)
+
+
+class FFmpegAVInfo(base.BaseAVInfo):
+
+ prog_bin = "ffprobe"
+
+ @staticmethod
+ def get_video_duration(input_file):
+ args = FFmpegAVInfo.prog_bin + ' -show_format "' \
+ + input_file + '"'
# READ handler for process's output.
p = subprocess.Popen(args, shell=True,
if exit_code > 0:
raise api_exceptions.ThumbExtractionException( \
'FFmpeg exited with code ' + str(exit_code) + '.')
-
return n_thumbs_extracted
- def get_video_duration(self):
- """
- Returns the number of seconds of a video (int/float).
- """
- pass
-
def get_output_file_name(self, index):
""" Returns the name required as output file name based on index. """
output_file_name = self.dest_path + self.name \
+ '_t' + ("%02d" % index) + '.jpg'
return output_file_name
+ def get_video_duration(self):
+ pass
+
class BaseFileTransferer:
"""
Class's destructor calls this method.
"""
pass
+
+
+class BaseAVInfo:
+ @staticmethod
+ def get_video_duration(input_file):
+ """
+ Returns the number of seconds of a video (int/float).
+ """
+ pass
def close(self):
if self.ftp is not None:
- self.ftp.quit()
+ try:
+ self.ftp.quit()
+ except:
+ pass
import sys
import config
+#
+# !! Imports required for create_torrent
+#
+from BaseLib.Core.API import *
+#
+#
+#
+
+def create_torrent(input_):
+ tdef = TorrentDef()
+ tdef.add_content(input_, config.AVINFO_CLASS.get_video_duration(input_))
+ tdef.set_tracker(config.BT_TRACKER)
+
+ tdef.set_piece_length(32768)
+
+ tdef.finalize()
+ tdef.save(input_ + ".tstream")
+
+ print 'READY!', config.BT_TRACKER, config.AVINFO_CLASS.get_video_duration(input_)
if __name__ == '__main__':
+ pass
# transcoder = config.TRANSCODER_CLASS(sys.argv[1])
# transcoder.transcode('webm', "vorbis", "vp8", a_bitrate="128k", a_samplingrate=22050, a_channels=2, v_bitrate="256k", v_framerate=15, v_resolution="320x240", v_dar="4:3")
# #thumb_extractor.extract_random_thumb()
# print thumb_extractor.extract_summary_thumbs(5)
- file_transfer = config.FILE_TRANSFERER_CLASS()
- file_transfer.get(['vim_config.tar.gz'])
- file_transfer.close()
+# file_transfer = config.FILE_TRANSFERER_CLASS()
+# file_transfer.get(['vim_config.tar.gz'])
+# #file_transfer.put(['cisd.py'])
+# file_transfer.close()
+
+ create_torrent(sys.argv[1])
from api import avhandling
from api import file_transfer
+# BitTorrent configurations.
+BT_TRACKER = "http://p2p-next-10.grid.pub.ro:6969/announce"
+
# External programs API classes.
+AVINFO_CLASS = avhandling.FFmpegAVInfo
TRANSCODER_CLASS = avhandling.FFmpegTranscoder
THUMB_EXTRACTOR_CLASS = avhandling.FFmpegThumbExtractor
-BT_CLIENT_CLASS = None # TODO
FILE_TRANSFERER_CLASS = file_transfer.FTPFileTransferer
# External programs binary file. None means default.
TRANSCODER_BIN = None
THUMB_EXTRACTER_BIN = None
-BT_CLIENT_BIN = None
FILE_TRANSFERER_BIN = None