Created
February 5, 2018 20:44
-
-
Save TheMatt2/75220f2e9246d259382ae8f8f035226b to your computer and use it in GitHub Desktop.
Musher is a collection of ffmpeg commands that I in trying to prepare the ffmpeg commands for spaceRAID. Hopefully someone will find this half useful, though it is really just badly commented bits of code. Feel free to use.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Website Links Useful | |
# https://stackoverflow.com/questions/7362130/getting-video-dimension-from-ffmpeg-i | |
# https://trac.ffmpeg.org/wiki/Encode/H.264 | |
# https://superuser.com/questions/483232/make-exact-mp4-h264-format-for-uploading-to-youtube | |
# https://github.com/yihui/animation/issues/74 | |
# https://askubuntu.com/questions/110264/how-to-find-frames-per-second-of-any-video-file | |
# https://stackoverflow.com/questions/14306205/do-ffmpeg-h264-compression-presets-affect-the-video-quality | |
# http://www.bugcodemaster.com/article/get-information-video-file-using-ffmpeg | |
# https://superuser.com/questions/326629/how-can-i-make-ffmpeg-be-quieter-less-verbose | |
# https://video.stackexchange.com/questions/16356/how-to-use-ffprobe-to-obtain-certain-information-about-mp4-h-264-files | |
# /usr/local/Cellar/ffmpeg/3.4.1/bin/ffmpeg -i test_output2.mp4 -i "Greater DC Event 2017 Practice 3 of 78 sponsored by Accenture CHS District.mp4" -filter_complex "[0]drawtext=enable=between(t\,3\,9):fontcolor=white:fontfile=/Library/Fonts/Trebuchet MS.ttf:fontsize=36:text=Hello:x=text_w/16:y=(h-text_h)/2[s0];[s0]scale=512:288:force_original_aspect_ratio=1[s1];[s1]pad=512:288:(ow-iw)/2:(oh-ih)/2[s2];[s2][1]concat=n=2[s3]" -map [s3] mushed.mp4 -y | |
# import ffmpeg | |
# infile1 = ffmpeg.input("test_output2.mp4") | |
# infile2 = ffmpeg.input("Greater DC Event 2017 Practice 3 of 78 sponsored by Accenture CHS District.mp4") | |
# text = "Hello" | |
# x=(ffmpeg | |
# .concat( | |
# infile1.drawtext(text = text, | |
# fontfile="/Library/Fonts/Trebuchet MS.ttf", | |
# fontsize = 36, | |
# fontcolor = "white", | |
# x = "text_w/16", | |
# y = "(h-text_h)/2", | |
# enable = "between(t,3,9)") | |
# .filter_("scale", "512:288", force_original_aspect_ratio = 1) | |
# .filter_("pad", "512:288:(ow-iw)/2:(oh-ih)/2"), | |
# infile2) | |
# .output("mushed.mp4") | |
# ) | |
# -preset medium | |
# intermediate1.mp4 bit_rate=200949 | |
# intermediate2.mp4 bit_rate=237883 | |
# mushed.mp4 bit_rate=234788 | |
# user 2m48.646s | |
# sys 0m3.211s | |
# -preset fast | |
# intermediate1.mp4 bit_rate=202338 | |
# intermediate2.mp4 bit_rate=235118 | |
# mushed.mp4 bit_rate=235870 | |
# user 2m18.231s | |
# sys 0m2.900s | |
# -preset superfast | |
# intermediate1.mp4 bit_rate=383901 | |
# intermediate2.mp4 bit_rate=451244 | |
# mushed.mp4 bit_rate=437028 | |
# user 1m5.189s | |
# sys 0m2.048s | |
# -preset ultrafast | |
# intermediate1.mp4 bit_rate=718129 | |
# intermediate2.mp4 bit_rate=793732 | |
# mushed.mp4 bit_rate=795494 | |
# user 0m47.797s | |
# sys 0m1.684s | |
#ffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 "$2" | |
#ffprobe -v error -select_streams 0 -show_entries stream=r_frame_rate -of csv=p=0 "$1" | |
#ffprobe -v error -select_streams 0 -show_entries stream=r_frame_rate,bit_rate -of default=noprint_wrappers=1 "$1" | |
#ffprobe -v error -select_streams 0 -show_entries stream=width,height,r_frame_rate,bit_rate -of default=noprint_wrappers=1 "$2" | |
#Change the size and shape of the intro. | |
ffmpeg -v error -y -i "$1" -vf "drawtext=fontfile=/Library/Fonts/Trebuchet MS.ttf:text=$1: enable='between(t,3,9)':fontcolor=white:fontsize=36:x=text_w/16:y=(h-text_h)/2,scale=512:288:force_original_aspect_ratio=1,pad=512:288:(ow-iw)/2:(oh-ih)/2" -c:v libx264 -preset ultrafast -r 30000/1001 -crf 18 -c:a libmp3lame -b:a 320k intermediate1.mp4 | |
echo intermediate1.mp4 `ffprobe -v error -select_streams 0 -show_entries stream=bit_rate -of default=noprint_wrappers=1 intermediate1.mp4` | |
#Change codec of the other video, maybe can be skipped. | |
ffmpeg -v error -y -i "$2" -c:v libx264 -preset ultrafast -crf 18 -c:a libmp3lame -b:a 320k intermediate2.mp4 | |
echo intermediate2.mp4 `ffprobe -v error -select_streams 0 -show_entries stream=bit_rate -of default=noprint_wrappers=1 intermediate2.mp4` | |
# Combine the two. | |
ffmpeg -v error -y -i intermediate1.mp4 -i intermediate2.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -r 30000/1001 -c:v libx264 -preset ultrafast -crf 18 -c:a libmp3lame -b:a 320k mushed.mp4 | |
echo mushed.mp4 `ffprobe -v error -select_streams 0 -show_entries stream=bit_rate -of default=noprint_wrappers=1 mushed.mp4` | |
# -preset veryfast ultrafast | |
# -preset ultrafast | |
# FINAL | |
/usr/local/Cellar/ffmpeg/3.4.1/bin/ffmpeg -i test_output2.mp4 -i "Greater DC Event 2017 Practice 3 of 78 sponsored by Accenture CHS District.mp4" -filter_complex "[0]drawtext=enable=between(t\,3\,9):fontcolor=white:fontfile=/Library/Fonts/Trebuchet MS.ttf:fontsize=36:text=Hello:x=text_w/16:y=(h-text_h)/2[s0];[s0]scale=512:288:force_original_aspect_ratio=1[s1];[s1]pad=512:288:(ow-iw)/2:(oh-ih)/2[s2];[s2][1]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -r 30000/1001 -preset ultrafast mushed.mp4 -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Input test_output2.mp4 "Greater DC Event 2017 Practice 3 of 78 sponsored by Accenture CHS District.mp4" | |
/usr/local/Cellar/ffmpeg/3.4.1/bin/ffmpeg -y -i "$1" -i "$2" -filter_complex "\ | |
[0:v]drawtext=enable=between(t\,3\,9): | |
fontcolor=white:fontfile=/Library/Fonts/Trebuchet MS.ttf: | |
fontsize=36:text=Greater DC Event 2017 | |
Practice 3 of 78 sponsored | |
by Accenture CHS District: | |
x=text_w/16: | |
y=(h-text_h)/2[v1]; | |
[0:a][1:a]concat=n=2:v=0:a=1[outa]; | |
[v1]scale=512:288:force_original_aspect_ratio=1[v2]; | |
[v2]pad=512:288:(ow-iw)/2:(oh-ih)/2[v3]; | |
[v3][1:v]concat=n=2[outv] | |
" -map "[outv]" -map "[outa]" -r 30000/1001 -preset ultrafast mushed2.mp4 | |
# [0:a]afifo[a1];\ | |
# [s0]scale=512:288:force_original_aspect_ratio=1[s1];\ | |
# [s1]pad=512:288:(ow-iw)/2:(oh-ih)/2[s2];\ | |
# [s1][1]concat=n=2[s3]\ | |
# ffmpeg -i "$1" -i "$2" -filter_complex "\ | |
# [0]drawtext=enable=between(t\,3\,9):\ | |
# fontcolor=white:\ | |
# fontfile=/Library/Fonts/Trebuchet MS.ttf:\ | |
# fontsize=36:\ | |
# text=Hello:\ | |
# x=text_w/16:\ | |
# y=(h-text_h)/2[s0];\ | |
# [s0]scale=512:288:\ | |
# force_original_aspect_ratio=1[s1];\ | |
# [s1]pad=512:288:(ow-iw)/2:\ | |
# (oh-ih)/2[s2];\ | |
# [s2][1]concat=n=2:\ | |
# v=1:\ | |
# a=1[outv][outa]" -map "[outv]" -map "[outa]" -r 30000/1001 -preset ultrafast mushed.mp4 -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# time ./musher3 ../Video\ Intro.mov Saturday\ 3-11-17_ND/Qualification\ 37\ of\ 78.mp4 | |
# test_output2.mp4 "Greater DC Event 2017 Practice 3 of 78 sponsored by Accenture CHS District.mp4" | |
/usr/local/Cellar/ffmpeg/3.4.1/bin/ffmpeg -y -nostdin -nostats -i "$1" -i "$2" -filter_complex "\ | |
[0:v]drawtext=enable=between(t\,3\,9): | |
fontcolor=white:fontfile=/Library/Fonts/Trebuchet MS.ttf: | |
fontsize=36:text='Greater DC Event 2017 | |
Practice 3 of 78 sponsored | |
by Accenture CHS District':x=text_w/16:y=(h-text_h)/2[i1]; | |
[0:a][1:a]concat=n=2:v=0:a=1[outa]; | |
[i1][1:v]scale2ref[i2][v2]; | |
[i2][v2]concat=n=2[outv] | |
" -map "[outv]" -map "[outa]" -r 30000/1001 -preset ultrafast mushed3.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment