Created
December 19, 2023 15:06
-
-
Save camb416/61f34928a4b290a84c0ea6a9a7a7cd7b to your computer and use it in GitHub Desktop.
Add a label to a video in Colab with ffmpeg
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
#@title Add Label to a Video | |
def generate_label_command(inpath,outpath,label): | |
# assumes 720x540 video with black border on bottom of 40px | |
cmd = "ffmpeg -y -i {0} -c:v libx264 -vf \"pad=width=720:height=580:x=0:y=1:color=black,drawtext=../../data/fonts/DMSans_18pt-Medium.ttf:text='{2}':fontcolor=white:fontsize=18:x=18:y=(h-30)\" {1}".format(inpath,outpath,label) | |
return cmd | |
cmd = generate_label_command('infile.mp4', 'outfile.mp4','label string') | |
# os.system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment