Toggle navigation
Toggle navigation
This project
Loading...
Sign in
cse437_e
/
smartdoorlock-backend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김유현
2020-11-21 22:11:10 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
62a24c3c1ce6578ee3d1ada00c98f9fb0bf1bc45
62a24c3c
1 parent
d7ee8ac6
Change video format
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
api/views.py
videorecord.py
api/views.py
View file @
62a24c3
...
...
@@ -210,7 +210,7 @@ class VideoList(APIView) :
s3
=
session
.
client
(
's3'
)
target
=
Video
.
objects
.
get
(
vid_name
=
request_id
)
s3
.
delete_object
(
Bucket
=
S3_STORAGE_BUCKET_NAME
,
Key
=
str
(
target
.
vid_name
)
+
'.
h26
4'
)
s3
.
delete_object
(
Bucket
=
S3_STORAGE_BUCKET_NAME
,
Key
=
str
(
target
.
vid_name
)
+
'.
mp
4'
)
s3
.
delete_object
(
Bucket
=
S3_STORAGE_BUCKET_NAME
,
Key
=
str
(
target
.
vid_name
)
+
'_thumb.jpg'
)
target
.
delete
()
return
Response
(
status
=
status
.
HTTP_200_OK
)
...
...
@@ -227,7 +227,7 @@ class VideoDownload(APIView) :
request_id
=
vid_name
if
request_id
==
'None'
:
raise
FieldDoesNotExist
download_url
=
S3_ACCESS_URL
+
str
(
request_id
)
+
'.
h26
4'
# S3 다운로드 링크 변환
download_url
=
S3_ACCESS_URL
+
str
(
request_id
)
+
'.
mp
4'
# S3 다운로드 링크 변환
if
not
download_url
:
raise
ObjectDoesNotExist
res
=
{
...
...
videorecord.py
View file @
62a24c3
...
...
@@ -5,7 +5,7 @@ import time
import
datetime
import
django
import
sys
import
json
import
subprocess
sys
.
path
.
append
(
'/home/pi/Desktop/smartdoorlock-backend'
)
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'src.settings'
)
...
...
@@ -49,10 +49,12 @@ def record() :
start_time
=
time
.
time
()
vid_name
=
now
.
strftime
(
'
%
Y
%
m
%
d-
%
H
%
M
%
S'
)
vid_path
=
path
+
'/'
+
vid_name
+
'.h264'
vid_path
=
path
+
'/'
+
vid_name
h264_vid_path
=
vid_path
+
'.h264'
mp4_vid_path
=
vid_path
+
'.h264'
thumbnail_path
=
path
+
'/'
+
vid_name
+
'.jpg'
camera
.
start_recording
(
output
=
vid_path
)
camera
.
start_recording
(
output
=
h264_
vid_path
)
time
.
sleep
(
1
)
camera
.
capture
(
thumbnail_path
)
while
GPIO
.
input
(
pir_pin
)
:
...
...
@@ -60,12 +62,14 @@ def record() :
time
.
sleep
(
2
)
camera
.
stop_recording
()
camera
.
stop_preview
()
result
=
subprocess
.
check_output
(
"MP4Box -add {} {}"
.
format
(
h264_vid_path
,
mp4_vid_path
),
shell
=
True
)
print
(
result
)
vid_time
=
time
.
strftime
(
"
%
M:
%
S"
,
time
.
gmtime
(
time
.
time
()
-
start_time
))
# s3 upload
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
)
s3
.
upload_file
(
Filename
=
vid_path
,
Bucket
=
S3_STORAGE_BUCKET_NAME
,
Key
=
vid_name
+
'.
h26
4'
)
s3
.
upload_file
(
Filename
=
vid_path
,
Bucket
=
S3_STORAGE_BUCKET_NAME
,
Key
=
vid_name
+
'.
mp
4'
)
s3
.
upload_file
(
Filename
=
thumbnail_path
,
Bucket
=
S3_STORAGE_BUCKET_NAME
,
Key
=
vid_name
+
'_thumb.jpg'
)
uploadVideo
=
{}
...
...
Please
register
or
login
to post a comment