Last active
January 31, 2016 08:23
-
-
Save davidjmerritt/46e9cab1c709e15cafcb to your computer and use it in GitHub Desktop.
Requires ffmpeg, mediainfo
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/sh | |
date_and_time=`date` | |
input_file=${1} | |
output_file=${2} | |
start_second=5 | |
stop_second=25 | |
framerate_in=`mediainfo -i ${input_file} | grep "Frame rate " | awk -F " " {'print $4'}` | |
framerate_out=29.97 | |
framerate=`echo $framerate_in-$framerate_out+$framerate_in` | |
stop_time_relative_to_origial_media_in_seconds=`echo $stop_second-$start_second | bc` | |
fadein_duration_in_seconds_fraction=0.75 | |
fadeout_duration_in_seconds_fraction=1.5 | |
start_time_in_frames=`echo $start_second*$framerate | bc` | |
fadein_duration_in_frames=`echo $fadein_duration_in_seconds_fraction*$framerate | bc` | |
fadeout_duration_in_frames=`echo $fadeout_duration_in_seconds_fraction*$framerate | bc` | |
fade_start_time_relative_to_origial_media_in_frames=`echo $stop_time_relative_to_origial_media_in_seconds*$framerate-$fadeout_duration_in_frames | bc` | |
# ADD TRIM AND ADD FADE | |
# ffmpeg \ | |
# -y \ | |
# -ss ${start_second} \ | |
# -i ${input_file} \ | |
# -to ${stop_time_relative_to_origial_media_in_seconds} \ | |
# -filter_complex "[0:v]fade=in:0:${fadein_duration_in_frames},fade=out:${fade_start_time_relative_to_origial_media_in_frames}:${fadeout_duration_in_frames}[v]" \ | |
# -filter_complex "[0:a]afade=t=in:ss=0:d=${fadein_duration_in_seconds_fraction},afade=t=out:st=${fade_start_time_relative_to_origial_media_in_frames}[a]" \ | |
# -map "[v]" \ | |
# -map "[a]" \ | |
# -r $framerate_out \ | |
# -b:v 5000k \ | |
# -maxrate 5000k \ | |
# -bufsize 2000k \ | |
# -c:v libx264 \ | |
# -c:a libfdk_aac \ | |
# ${output_file} | |
# ADD TITLE CARD | |
# ffmpeg -i Input.mov -f lavfi -i "color=c=black:s=720x576:r=25:sar=1050/720" -filter_complex \ | |
# "[0:v] setpts=PTS-STARTPTS [main]; \ | |
# [1:v] trim=end=10,setpts=PTS-STARTPTS [pre]; \ | |
# [1:v] trim=end=30,setpts=PTS-STARTPTS [post]; \ | |
# [pre][main][post] concat=n=3:v=1:a=0 [out]" \ | |
# -map "[out]" -vcodec mpeg2video -maxrate 30000k -b:v 30000k Output.mpg | |
title=${date_and_time} | |
title_safe=`%{expr\\:title}` | |
ffmpeg \ | |
-y \ | |
-f lavfi \ | |
-i color=c=black:s=1920x1080:d=4.0 \ | |
-vf "drawtext=fontfile=/Library/Fonts/Arial\ Narrow.ttf:text='${title_safe}':fontsize=30:fontcolor=white:x=(w-text_w)/2:y=(h-text_h-line_h)/2:" \ | |
~/Desktop/title_card.mp4 | |
echo "Job's done! ${title_safe}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment