forked from solvespace/solvespace-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvidencode.sh
More file actions
executable file
·27 lines (21 loc) · 1.1 KB
/
videncode.sh
File metadata and controls
executable file
·27 lines (21 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh -ex
INPUT="$1"
# Web video is an utter disaster. A fractal of incompatibility.
# Basically unusable. A very abridged version is that browsers
# effectively support only the yuv420p colorspace (whether with
# VP8 or H.264), and we have videos in the rgb colorspace, and
# in order to not lose chroma information to subsampling we have
# to upsample the video itself first. Also, half of the browsers
# supports only H.264, and a few others supports only WebM,
# so we're stuck converting and serving everything twice.
UPSAMPLE="-vf scale=iw*2:ih*2 -pix_fmt yuv420p \
-sws_flags full_chroma_inp+full_chroma_int+bitexact+neighbor"
WEBM="-c:v libvpx -crf:v 25"
H264="-c:v libx264 -profile:v main -preset slow -crf:v 25"
# Some of the original WMV videos have tbr/tbn/tbc values
# that imply a bizarre 1000fps framerate, which doesn't
# do much harm with webm, but completely cripples the h264
# encoder. Recompute the timestamps using the correct fps.
TSFIX="-fflags +genpts -r 8"
ffmpeg -y -i ${INPUT} ${TSFIX} ${UPSAMPLE} ${WEBM} ${INPUT%.*}.webm
ffmpeg -y -i ${INPUT} ${TSFIX} ${UPSAMPLE} ${H264} ${INPUT%.*}.mp4