diff options
Diffstat (limited to 'dot/local')
-rwxr-xr-x | dot/local/bin/twmp4 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/dot/local/bin/twmp4 b/dot/local/bin/twmp4 new file mode 100755 index 0000000..9b80425 --- /dev/null +++ b/dot/local/bin/twmp4 | |||
@@ -0,0 +1,34 @@ | |||
1 | #!/bin/sh | ||
2 | INPUT=$1 | ||
3 | set -ex | ||
4 | |||
5 | [ -f "$INPUT" ] | ||
6 | case "$INPUT" in | ||
7 | *.mp4) OUTPUT=${INPUT%.mp4}.twitter.mp4 ;; | ||
8 | *.*) OUTPUT=${INPUT%.*}.twitter.mp4 ;; | ||
9 | *) OUTPUT=${INPUT}.twitter.mp4 ;; | ||
10 | esac | ||
11 | |||
12 | # source: https://gist.github.com/nikhan/26ddd9c4e99bbf209dd7 | ||
13 | |||
14 | if [ ! -e "$OUTPUT" ] | ||
15 | then | ||
16 | ffmpeg -i "$INPUT" -vcodec libx264 \ | ||
17 | -vf 'scale=640:trunc(ow/a/2)*2' \ | ||
18 | -acodec aac \ | ||
19 | -vb 1024k \ | ||
20 | -minrate 1024k -maxrate 1024k \ | ||
21 | -bufsize 1024k -ar 44100 \ | ||
22 | -strict experimental \ | ||
23 | -r 30 \ | ||
24 | "$OUTPUT" | ||
25 | fi | ||
26 | |||
27 | # source: https://unix.stackexchange.com/questions/1670/how-can-i-use-ffmpeg-to-split-mpeg-video-into-10-minute-chunks/212518#212518 | ||
28 | |||
29 | CHUNKS=${OUTPUT%.mp4}.%03d.mp4 | ||
30 | ffmpeg -i "$OUTPUT" \ | ||
31 | -c copy \ | ||
32 | -map 0 \ | ||
33 | -segment_time 2:15 -f segment -reset_timestamps 1 "$CHUNKS" | ||
34 | |||