Yoonjunhyeon

비디오 길이 계산 모듈 추가

......@@ -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()
......
......@@ -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
......
......@@ -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;
......