Showing
2 changed files
with
12 additions
and
4 deletions
| ... | @@ -13,13 +13,21 @@ def maiddn(): | ... | @@ -13,13 +13,21 @@ def maiddn(): |
| 13 | def upload_file(): | 13 | def upload_file(): |
| 14 | params = json.loads(request.get_data(), encoding='utf-8') | 14 | params = json.loads(request.get_data(), encoding='utf-8') |
| 15 | data=params['datas'] | 15 | data=params['datas'] |
| 16 | + timeData=params['timeData'] | ||
| 16 | print(len(data)) | 17 | print(len(data)) |
| 17 | - make_wav_file(data) | 18 | + print(timeData) |
| 19 | + make_wav_file(data, timeData) | ||
| 18 | return send_file("test.wav", attachment_filename='test.wav', as_attachment=True) | 20 | return send_file("test.wav", attachment_filename='test.wav', as_attachment=True) |
| 19 | 21 | ||
| 20 | 22 | ||
| 21 | -def make_wav_file(data): | 23 | +def make_wav_file(data, timeData): |
| 22 | print('convert is loading') | 24 | print('convert is loading') |
| 25 | + print(len(data)) | ||
| 26 | + print(timeData) | ||
| 27 | + print(len(data) / timeData) | ||
| 28 | + hz = int(len(data) / timeData) | ||
| 29 | + print("hz=") | ||
| 30 | + print(hz) | ||
| 23 | eng = matlab.engine.start_matlab() | 31 | eng = matlab.engine.start_matlab() |
| 24 | l1=[] | 32 | l1=[] |
| 25 | for t in data: | 33 | for t in data: |
| ... | @@ -29,8 +37,9 @@ def make_wav_file(data): | ... | @@ -29,8 +37,9 @@ def make_wav_file(data): |
| 29 | print(t) | 37 | print(t) |
| 30 | l2 = [n/10000 for n in l1] | 38 | l2 = [n/10000 for n in l1] |
| 31 | data = matlab.double(l2) | 39 | data = matlab.double(l2) |
| 40 | + | ||
| 32 | filename = 'test.wav' | 41 | filename = 'test.wav' |
| 33 | - eng.audiowrite(filename, data, 1000, nargout=0) | 42 | + eng.audiowrite(filename, data, hz, nargout=0) |
| 34 | eng.quit() | 43 | eng.quit() |
| 35 | 44 | ||
| 36 | @app.route('/combine', methods=['POST']) | 45 | @app.route('/combine', methods=['POST']) |
| ... | @@ -40,7 +49,6 @@ def combineMp4Wav(): | ... | @@ -40,7 +49,6 @@ def combineMp4Wav(): |
| 40 | print("error") | 49 | print("error") |
| 41 | return "error" | 50 | return "error" |
| 42 | file = request.files['Video'] | 51 | file = request.files['Video'] |
| 43 | - print(file) | ||
| 44 | file.save("video.mp4") | 52 | file.save("video.mp4") |
| 45 | os.system("ffmpeg -i video.mp4 -i test.wav -c:v copy -c:a aac -strict experimental -vcodec libx264 -map 0:v:0 -map 1:a:0 -y output.mp4") | 53 | os.system("ffmpeg -i video.mp4 -i test.wav -c:v copy -c:a aac -strict experimental -vcodec libx264 -map 0:v:0 -map 1:a:0 -y output.mp4") |
| 46 | return "Success" | 54 | return "Success" | ... | ... |
No preview for this file type
-
Please register or login to post a comment