Skip to content

Instantly share code, notes, and snippets.

@camb416
Created December 19, 2023 15:06
Show Gist options
  • Save camb416/61f34928a4b290a84c0ea6a9a7a7cd7b to your computer and use it in GitHub Desktop.
Save camb416/61f34928a4b290a84c0ea6a9a7a7cd7b to your computer and use it in GitHub Desktop.
Add a label to a video in Colab with ffmpeg
Display the source blob
Display the rendered blob
Raw
#@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