-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoCamera.py
56 lines (52 loc) · 1.45 KB
/
autoCamera.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from qcloud_vod.vod_upload_client import VodUploadClient
from qcloud_vod.model import VodUploadRequest
import time
from picamera import PiCamera
from time import sleep
import os,sys,stat
def getFileName():
localtime = time.localtime(time.time());
timeStr = time.strftime("%Y%m%d%H%M%S",localtime);
newFileName = 'wbq'+timeStr+'.h264';
return newFileName;
def getCamera(fileName):
try:
camera = PiCamera();
camera.start_preview();
camera.start_recording(fileName);
sleep(30);
camera.stop_recording();
camera.stop_preview();
os.chmod(fileName,stat.S_IRWXU|stat.S_IXOTH);
except Exception as err:
print(err)
return
def convert_to_mp4(source_path):
HFOMAT=".h264";
MFOMAT=".mp4";
target_path = source_path;
target_path = target_path.replace(HFOMAT,MFOMAT);
print target_path;
print source_path;
cmod='MP4Box'+' -add '+source_path+' '+target_path;
execute_state = os.system(cmod);
print(cmod)
print(execute_state)
if execute_state==0:
return target_path;
else:
return
def mp4LoadTXVod(mpFileName,vodID,vodKey,vodArea,vodAppId):
client = VodUploadClient(vodID,vodKey)
request = VodUploadRequest()
request.MediaFilePath = mpFileName;
request.StorageRegion = vodArea;
request.SubAppId = vodAppId;
try:
response = client.upload(vodArea,request)
print(response.FileId)
print(response.MediaUrl)
return response.MediaUrl
except Exception as err:
print(err)
return ""