Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

修接影片的問題 #20

Merged
merged 5 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ sudo: true
dist: trusty
language: python
python:
- '3.4'
- '3.5'
env:
- TOX_ENV=tan1uan5
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:latest
FROM ubuntu:16.04
MAINTAINER sih4sing5hong5

RUN apt-get update #20180423
RUN apt-get update
RUN apt-get install -y python3 g++ python3-dev
RUN apt-get install -y libav-tools
RUN apt-get install -y locales
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.5'

services:
gunicorn:
build: .
command: gunicorn siunn1ua2ah4.wsgi --log-level DEBUG -w 2 -b 0.0.0.0:8000
volumes:
- ./hok8_bu7/local.py:/usr/local/hok8-bu7/hok8_bu7/local.py
expose:
- "8000"
environment:
VIRTUAL_HOST: "xn--iwqtoz61h.xn--v0qr21b.xn--kpry57d"
VIRTUAL_PORT: 8000
62 changes: 26 additions & 36 deletions 鬥做伙/做影片.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from itertools import zip_longest
import json
from os.path import join
from shutil import copyfile
from tempfile import TemporaryDirectory
from urllib.parse import quote
import ssl
Expand Down Expand Up @@ -54,42 +53,33 @@ def 收著資料(cls, 腔口參數, 圖陣列, 聲陣列, 字陣列, 存檔所
@classmethod
def 敆做伙(cls, 圖陣列, 聲陣列, 字陣列, 存檔所在):
with TemporaryDirectory() as 目錄:
全部結果檔 = []
for 第幾个, (圖, 聲, 字) in enumerate(zip(圖陣列, 聲陣列, 字陣列)):
結果檔 = join(目錄, 'output{}.mkv'.format(第幾个))
暫時圖 = join(目錄, 'jpg{}.jpg'.format(第幾个))
cls._走指令([
'convert',
圖,
暫時圖,
])
cls._走指令([
'avconv',
'-i', 暫時圖, '-i', 聲, '-vf', 'subtitles={}'.format(字),
'-s', 'svga', '-y', 結果檔,
])
全部結果檔.append(結果檔)
敆做伙結果檔 = join(目錄, 'result.mkv')
敆做伙指令 = ['mkvmerge']
敆做伙指令.append('-o')
敆做伙指令.append(敆做伙結果檔)
for 結果檔 in 全部結果檔:
敆做伙指令.append(結果檔)
敆做伙指令.append('+')
敆做伙指令.pop()
cls._走指令(敆做伙指令)

敆做伙轉換檔 = join(目錄, 'result.mp4')
上尾轉換指令 = ['avconv']
上尾轉換指令.append('-i')
上尾轉換指令.append(敆做伙結果檔)
# 上尾轉換指令.append('-c')
# 上尾轉換指令.append('copy')
上尾轉換指令.append('-y')
上尾轉換指令.append(敆做伙轉換檔)
cls._走指令(上尾轉換指令)
全部結果表 = join(目錄, 'tuan.pio')
with open(全部結果表, 'w') as 表:
for 第幾个, (圖, 聲, 字) in enumerate(zip(圖陣列, 聲陣列, 字陣列)):
結果檔 = join(目錄, 'output{}.mp4'.format(第幾个))
暫時圖 = join(目錄, 'jpg{}.jpg'.format(第幾个))
cls._走指令([
'convert',
圖,
暫時圖,
])
cls._走指令([
'avconv',
'-i', 暫時圖, '-i', 聲, '-vf', 'subtitles={}'.format(字),
'-s', 'svga', '-y', 結果檔,
])
print("file '{}'".format(結果檔), file=表)

copyfile(敆做伙轉換檔, 存檔所在)
敆做伙指令 = [
'ffmpeg',
'-f', 'concat',
'-safe', '0',
'-i', 全部結果表,
'-c', 'copy',
'-y',
存檔所在
]
cls._走指令(敆做伙指令)

@classmethod
def 轉文本資料(cls, 腔口參數, 文字陣列, 目錄):
Expand Down