Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Sunday, May 10, 2020

Create ISO Image From Directory

Occasionally it's useful to create a CD/DVD ISO image from a list of files contained in a directory. For instance, if you're interested in archiving a bunch of files to be later burned to a CD/DVD.
This can be done by using the mkisofs command which stands for 'make ISO filesystem'.

If you have a list of directories like the following:
user@debian:/media/ehd/tmp$ ls -ltotal 2802468drwxr-xr-x 3 root root 4096 2009-12-29 13:01 disc01drwxr-xr-x 3 root root 4096 2009-12-29 13:01 disc02drwxr-xr-x 3 root root 4096 2009-12-29 13:02 disc03drwxr-xr-x 3 root root 4096 2009-12-29 13:03 disc04drwxr-xr-x 3 root root 4096 2009-12-29 13:05 disc05drwxr-xr-x 3 root root 4096 2009-12-29 13:06 disc06drwxr-xr-x 3 root root 4096 2009-12-29 13:08 disc07drwxr-xr-x 3 root root 4096 2009-12-29 13:09 disc08drwxr-xr-x 3 root root 4096 2009-12-29 13:10 disc09drwxr-xr-x 3 root root 4096 2009-12-29 13:10 disc10drwxr-xr-x 3 root root 4096 2009-12-29 13:12 disc11user@debian:/media/ehd/tmp$

You can create individual ISO images for each directory by issuing the following command:
$ mkisofs -o disc02.iso -J disc02

The ISO image will preserve the directory structures and file names found under disc02.

Cheers

Sunday, August 4, 2019

Adding Watermark To Video With FFMpeg

A pretty popular question concerning video editing is 'how do I add a watermark'? 

Overlaying a video with your logo or name is a way to get your brand out, identify your work, and get eyes on your identity.

Relatively simple to do with Ffmpeg.  You'll need as inputs a video and a suitably sized graphic.  One sweep of your FFMpeg magic wand and 'Bob's Your Uncle', pure video magic.

Lets get started:

I've referenced in past blog posts that FFMpeg and Make are a great combination for video editing, so all the steps we'll be performing can be accomplished by the following makefile:

$ cat -n Makefile 
     1 all: output.mp4
     2
     3 input.mp4 :
     4 ${SH} youtube-dl https://www.youtube.com/watch?v=Td1lyPwiM0Y -o $@
     5
     6 watermarklogo.png:
     7 ${SH} convert /mnt/svn/mal/main/trunk/FSK/Media/Graphics/logos/logo/final.gif -resize 100x100 $@
     8
     9 output.mp4: input.mp4 watermarklogo.png
    10 ${SH} ffmpeg -i $< -vf "movie=watermarklogo.png [watermark]; [in] [watermark] overlay=main_w-overlay_w-10:10 [out]" -strict -2 $@
    11
    12
    13 clean:
    14 ${RM} *.mp4 *.png

But, we'll walk through the steps individually.

Grab your video; I'm using a YouTube downloading utility to grab one of my previous videos:
$ youtube-dl https://www.youtube.com/watch?v=Td1lyPwiM0Y -o input.mp4

The video is ~47 seconds long, 640x480.


Next, find or create a 100x100 image.  I'm resizing one using ImageMagick:
$ convert final.gif -resize 100x100 watermarklogo.png



Now,  our final step is to overlay the image on the video 10 pixels from the top/right corners:

$ ffmpeg -i $< -vf "movie=watermarklogo.png [watermark]; [in] [watermark] overlay=main_w-overlay_w-10:10 [out]" -strict -2 output.mp4

abbrabracadabra


Now, go make something cool.


Sunday, February 10, 2019

Applying Image Overlay to Video

Overlaying an image atop a video is a good way to add content to an informative video, or a means to apply a watermark.

In it's simplest form, the command takes the form of:
- specifying two input files, a video file and an image file
- image scaling size
- image overlay location


$ cat go

#!/bin/bash

VidFile=/tmp/foo.mp4
ImgFile=/tmp/image.png
OutVidFile=/tmp/output.mp4
ffmpeg -y -i ${VidFile} -i ${ImgFile} -filter_complex "[1] scale=w=100:h=100 [tmp]; [0][tmp] overlay=x=10:y=10" -an ${OutVidFile}
mplayer ${OutVidFile}

If you want to have the overlay fade in/out the command is slightly more complex, the filter requires a fade in timestamp and a fade out timestamp.  The following command has the image fade in at 5 seconds, and begins fading out at the 10 second mark:


$ cat go

#!/bin/bash

VidFile=/tmp/foo.mp4
ImgFile=/tmp/image.png
OutVidFile=/tmp/output.mp4

ffmpeg -y -i ${VidFile} -loop 1 -i ${ImgFile} -filter_complex "[1:v]fade=t=in:st=5:d=1,fade=t=out:st=10:d=1[over];[0:v][over]overlay=x=10:y=10" -t 20 -an ${OutVidFile}

mplayer ${OutVidFile}
The end result: