Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
PKH_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Yoonjunhyeon
2020-05-28 15:04:31 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
636be6165aae4a28180fdd2e034da4dec465d149
636be616
1 parent
600f08ea
비디오 길이 계산 모듈 추가
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
web/backend/api/views.py
web/backend/runMediaPipe.sh
web/frontend/src/views/Home.vue
web/backend/api/views.py
View file @
636be61
...
...
@@ -12,11 +12,21 @@ from django.shortcuts import get_object_or_404, render
from
api.models
import
Video
,
VideoFile
from
api.serializers
import
VideoSerializer
,
VideoFileSerializer
from
api
import
file_upload_path
import
subprocess
import
shlex
import
json
# Create your views here.
def
with_ffprobe
(
filename
):
result
=
subprocess
.
check_output
(
f
'ffprobe -v quiet -show_streams -select_streams v:0 -of json "{filename}"'
,
shell
=
True
)
.
decode
()
fields
=
json
.
loads
(
result
)[
'streams'
][
0
]
duration
=
int
(
float
(
fields
[
'duration'
]))
return
duration
def
index
(
request
):
return
render
(
request
,
template_name
=
'index.html'
)
...
...
@@ -39,7 +49,7 @@ class VideoFileUploadView(APIView):
def
post
(
self
,
req
,
*
args
,
**
kwargs
):
# 동영상 길이
runTime
=
126
runTime
=
0
# 요청된 데이터를 꺼냄( QueryDict)
new_data
=
req
.
data
.
dict
()
...
...
@@ -48,7 +58,6 @@ class VideoFileUploadView(APIView):
# 저장될 파일의 풀path를 생성
new_file_full_name
=
file_upload_path
(
file_name
.
name
)
print
(
new_file_full_name
)
# 새롭게 생성된 파일의 경로
file_path
=
'-'
.
join
(
new_file_full_name
.
split
(
'-'
)[
0
:
-
1
])
...
...
@@ -62,7 +71,9 @@ class VideoFileUploadView(APIView):
if
file_serializer
.
is_valid
():
file_serializer
.
save
()
print
(
file_serializer
.
data
)
# 동영상 길이 출력
runTime
=
with_ffprobe
(
'/'
+
file_serializer
.
data
[
'file_save_name'
])
print
(
runTime
)
process
=
subprocess
.
Popen
([
'./runMediaPipe.sh
%
s
%
s'
%
(
file_serializer
.
data
[
'file_save_name'
],
runTime
,)],
shell
=
True
)
process
.
wait
()
...
...
web/backend/runMediaPipe.sh
View file @
636be61
...
...
@@ -13,5 +13,3 @@ GLOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/youtube8m/extract_yt8m_f
--calculator_graph_config_file
=
mediapipe/graphs/youtube8m/feature_extraction.pbtxt
\
--input_side_packets
=
input_sequence_example
=
/tmp/mediapipe/metadata.pb
\
--output_side_packets
=
output_sequence_example
=
/tmp/mediapipe/features.pb
python convertPb2Tfrecord.py
\ No newline at end of file
...
...
web/frontend/src/views/Home.vue
View file @
636be61
...
...
@@ -2,7 +2,7 @@
<v-sheet>
<v-overlay v-model="loadingProcess">
<v-progress-circular :size="120" width="10" color="primary" indeterminate></v-progress-circular>
<div style="color: #ffffff; font-size:
18px; margin-top: 10px
">Analyzing Your Video...</div>
<div style="color: #ffffff; font-size:
22px; margin-top: 20px; margin-left: -30px;
">Analyzing Your Video...</div>
</v-overlay>
<v-layout justify-center>
<v-flex xs12 sm8 md6 lg4>
...
...
@@ -127,6 +127,7 @@ export default {
this.loadingProcess = true;
const formData = new FormData();
formData.append('file', files[0]);
console.log(files[0]);
this.$axios.post('/upload', formData, { headers: { 'Content-Type': 'multipart/form-data' } })
.then((r) => {
this.loadingProcess = false;
...
...
Please
register
or
login
to post a comment