Skip to content

Instantly share code, notes, and snippets.

@LuoZijun
Last active April 10, 2019 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuoZijun/9d76191b610e05c1c15b59c317527b55 to your computer and use it in GitHub Desktop.
Save LuoZijun/9d76191b610e05c1c15b59c317527b55 to your computer and use it in GitHub Desktop.
星际争霸2:虚空之遗 - 亚顿之茅 过场动画

星际争霸2:虚空之遗 - 亚顿之矛 过场动画

Date

2019/03/18

地址

https://www.youtube.com/watch?v=i12P7e31gmA

开始时间

00:15:26

结束时间

00:17:10

脚本代码:

sudo apt install ffmpeg libav-tools youtube-dl

# format code  extension  resolution note
# 251          webm       audio only DASH audio  141k , opus @160k, 39.03MiB
# 140          m4a        audio only DASH audio  130k , m4a_dash container, mp4a.40.2@128k, 39.62MiB
# 
# 248          webm       1920x1080  1080p 2747k , vp9, 30fps, video only, 588.20MiB
# 298          mp4        1280x720   720p60 3537k , avc1.4d4020, 60fps, video only, 670.32MiB
# 137          mp4        1920x1080  1080p 4361k , avc1.640028, 30fps, video only, 738.92MiB
# 303          webm       1920x1080  1080p60 4479k , vp9, 60fps, video only, 922.08MiB
# 299          mp4        1920x1080  1080p60 5804k , avc1.64002a, 60fps, video only, 1.13GiB
#
# Opus@160k Audio 
youtube-dl --format 251 "https://www.youtube.com/watch?v=i12P7e31gmA"
# AVC1 Video
youtube-dl --format 299 "https://www.youtube.com/watch?v=i12P7e31gmA"

ffmpeg -ss "00:15:26" \
    -i "StarCraft 2 星际争霸2 -虚空之遗 CG合集 1080P-i12P7e31gmA.f299.mp4" \
    -t "00:01:44" -acodec copy -vcodec copy -movflags faststart \
    "video.mp4"

# NOTE: FFMPEG 在处理 OPUS 音频的时候会有些问题,所以我们使用 avconv
#       音频开始时间相对于视频要晚大概一秒钟。
avconv -ss "00:15:27" \
    -i "StarCraft 2 星际争霸2 -虚空之遗 CG合集 1080P-i12P7e31gmA.webm" \
    -t "00:01:44" -acodec copy -vcodec copy -movflags faststart \
    "audio.opus"

# NOTE: FFMPEG 在处理 AAC 音频时需要额外的库来支持,所以我们使用 avconv
avconv -i "audio.opus" "audio.aac"

# 合并视频和音频
ffmpeg -i "video.mp4" -i "audio.aac" \
    -ss "00:00:01.180" \
    -c:v copy -c:a copy -movflags faststart \
    "星际争霸2 - 虚空之遗 - 亚顿之矛过场动画.mp4" -y;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment