Showing
2 changed files
with
10 additions
and
6 deletions
... | @@ -210,7 +210,7 @@ class VideoList(APIView) : | ... | @@ -210,7 +210,7 @@ class VideoList(APIView) : |
210 | s3 = session.client('s3') | 210 | s3 = session.client('s3') |
211 | 211 | ||
212 | target = Video.objects.get(vid_name = request_id) | 212 | target = Video.objects.get(vid_name = request_id) |
213 | - s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '.h264') | 213 | + s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '.mp4') |
214 | s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '_thumb.jpg') | 214 | s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '_thumb.jpg') |
215 | target.delete() | 215 | target.delete() |
216 | return Response(status = status.HTTP_200_OK) | 216 | return Response(status = status.HTTP_200_OK) |
... | @@ -227,7 +227,7 @@ class VideoDownload(APIView) : | ... | @@ -227,7 +227,7 @@ class VideoDownload(APIView) : |
227 | request_id = vid_name | 227 | request_id = vid_name |
228 | if request_id == 'None' : | 228 | if request_id == 'None' : |
229 | raise FieldDoesNotExist | 229 | raise FieldDoesNotExist |
230 | - download_url = S3_ACCESS_URL + str(request_id) + '.h264' # S3 다운로드 링크 변환 | 230 | + download_url = S3_ACCESS_URL + str(request_id) + '.mp4' # S3 다운로드 링크 변환 |
231 | if not download_url : | 231 | if not download_url : |
232 | raise ObjectDoesNotExist | 232 | raise ObjectDoesNotExist |
233 | res = { | 233 | res = { | ... | ... |
... | @@ -5,7 +5,7 @@ import time | ... | @@ -5,7 +5,7 @@ import time |
5 | import datetime | 5 | import datetime |
6 | import django | 6 | import django |
7 | import sys | 7 | import sys |
8 | -import json | 8 | +import subprocess |
9 | 9 | ||
10 | sys.path.append('/home/pi/Desktop/smartdoorlock-backend') | 10 | sys.path.append('/home/pi/Desktop/smartdoorlock-backend') |
11 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') | 11 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') |
... | @@ -49,10 +49,12 @@ def record() : | ... | @@ -49,10 +49,12 @@ def record() : |
49 | start_time = time.time() | 49 | start_time = time.time() |
50 | 50 | ||
51 | vid_name = now.strftime('%Y%m%d-%H%M%S') | 51 | vid_name = now.strftime('%Y%m%d-%H%M%S') |
52 | - vid_path = path + '/' + vid_name + '.h264' | 52 | + vid_path = path + '/' + vid_name |
53 | + h264_vid_path = vid_path + '.h264' | ||
54 | + mp4_vid_path = vid_path + '.h264' | ||
53 | thumbnail_path = path + '/' + vid_name + '.jpg' | 55 | thumbnail_path = path + '/' + vid_name + '.jpg' |
54 | 56 | ||
55 | - camera.start_recording(output=vid_path) | 57 | + camera.start_recording(output=h264_vid_path) |
56 | time.sleep(1) | 58 | time.sleep(1) |
57 | camera.capture(thumbnail_path) | 59 | camera.capture(thumbnail_path) |
58 | while GPIO.input(pir_pin) : | 60 | while GPIO.input(pir_pin) : |
... | @@ -60,12 +62,14 @@ def record() : | ... | @@ -60,12 +62,14 @@ def record() : |
60 | time.sleep(2) | 62 | time.sleep(2) |
61 | camera.stop_recording() | 63 | camera.stop_recording() |
62 | camera.stop_preview() | 64 | camera.stop_preview() |
65 | + result = subprocess.check_output("MP4Box -add {} {}".format(h264_vid_path, mp4_vid_path), shell=True) | ||
66 | + print(result) | ||
63 | 67 | ||
64 | vid_time = time.strftime("%M:%S", time.gmtime(time.time()-start_time)) | 68 | vid_time = time.strftime("%M:%S", time.gmtime(time.time()-start_time)) |
65 | 69 | ||
66 | # s3 upload | 70 | # s3 upload |
67 | s3 = boto3.client('s3', region_name = 'ap-northeast-2', aws_access_key_id=S3_ACCESS_KEY_ID, aws_secret_access_key=S3_SECRET_ACCESS_KEY) | 71 | s3 = boto3.client('s3', region_name = 'ap-northeast-2', aws_access_key_id=S3_ACCESS_KEY_ID, aws_secret_access_key=S3_SECRET_ACCESS_KEY) |
68 | - s3.upload_file(Filename = vid_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '.h264') | 72 | + s3.upload_file(Filename = vid_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '.mp4') |
69 | s3.upload_file(Filename = thumbnail_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '_thumb.jpg') | 73 | s3.upload_file(Filename = thumbnail_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '_thumb.jpg') |
70 | 74 | ||
71 | uploadVideo = {} | 75 | uploadVideo = {} | ... | ... |
-
Please register or login to post a comment