def setUp(self): remove_tmp_file() self._id = str(add_file(open("./tmp.mov").read(), content_type="video/quicktime", filename="tmp.mov", )) update("fs.files",{"_id": self._id}, {"uuid": self._id}) self.task_id = insert("TaskData", { "converd": False, "entryList":[{ "fieldType":"Video", "uuid": self._id, "converdid": "", }] })
def convert_file_2_flv(_id): """ @todo: 把视频音频转为FLV格式 @param _id: 文件ID """ file_obj = get_file_by_id(_id) open("/tmp/tmp", "w").write(file_obj.get("content")) print "------------------king is king " os.system( "ffmpeg -i /tmp/tmp -y -ab 56\ -ar 22050 -b 500 -qscale 1 -s 320*240 /tmp/tmp.flv" ) stream = open("/tmp/tmp.flv").read() converd_id = add_file(stream, content_type="video/x-flv", filename=str(_id) + ".flv") remove_tmp_file() return str(converd_id)
def convert_file_2_flv(_id): """ @todo: 把视频音频转为FLV格式 @param _id: 文件ID """ file_obj = get_file_by_id(_id) open("/tmp/tmp", "w").write(file_obj.get("content")) print "------------------king is king " os.system("ffmpeg -i /tmp/tmp -y -ab 56\ -ar 22050 -b 500 -qscale 1 -s 320*240 /tmp/tmp.flv") stream = open("/tmp/tmp.flv").read() converd_id = add_file(stream, content_type="video/x-flv", filename=str(_id) + ".flv") remove_tmp_file() return str(converd_id)
def setUp(self): remove_tmp_file() self._id = str( add_file( open("./tmp.mov").read(), content_type="video/quicktime", filename="tmp.mov", )) update("fs.files", {"_id": self._id}, {"uuid": self._id}) self.task_id = insert( "TaskData", { "converd": False, "entryList": [{ "fieldType": "Video", "uuid": self._id, "converdid": "", }] })
def save_file(file, content_type, filename): return add_file(file, content_type, filename)