How to add "special effects" to videos in Linux using VLC commands

Create trippy videos using VLC shell commands.

linux vlc commands
Credit: Stephen Glasskeys/Kuba and Alek Tarkowski (CC)

Most of us already know VLC is a capable media player. Aside from its incredible ability to play virtually every type of media, it can also apply video or stream filters. These are often used to create "special effects" movies from locally saved video files. 

And, like most Linux media players, VLC also permits power users to run it in a non-GUI, "dummy interface" mode so its full feature set can be applied to media files via terminal commands or automated with shell scripts.

But automating and running VLC from shell scripts is a dark art, mainly because of a lack clear documentation. Linux command examples for certain VLC features are hard to find, or simply don't work as advertised.

So I got to work and tried different VLC "special effects" commands, tested each one successfully in Linux, and used them to create the video capture images shown below.

Conversion and transcoding

Along with its ability to play multiple video formats, VLC can also be used to convert or transcode them.

To start, I use the cvlc command to run VLC in "dummy interface" or shell friendly mode.  Since VLC doesn't always terminate and return to the shell prompt as cleanly as it should, after a bit of experimentation I discovered that the --play-and-exit parameter solves this problem nicely.

For most conversion tasks, I use one "base" command, then change a handful of parameters depending on the input video and desired output type: input file parameter, vcodec (visual codec), acodec (audio codec), and mux (audio/video multiplexing).

To illustrate this concept, use this command to convert MP4 files to MPG files:

cvlc input.mp4 --play-and-exit --sout "#transcode{vcodec=mp1v,acodec=mpga,ab=128,channels=2,samplerate=44100}:std{access=file,mux=mpeg1,dst=output.mpg}"

Likewise, this command converts DIVX to MP4:

cvlc input.divx --play-and-exit --sout "#transcode{vcodec=mp4v,acodec=mp4a,ab=128,channels=2,samplerate=44100}:std{access=file,mux=mp4,dst=output.mp4}" 

And this works nicely to convert AVI files to H264 format:

cvlc input.avi --play-and-exit --sout "#transcode{vcodec=h264,acodec=mp4a,ab=128,channels=2,samplerate=44100}:std{access=file,mux=mp4,dst=output.mp4}"

For other video types, consult the VLC codec page for a full list of supported codec and mux values.

Simple filter effects

Now for the special effects. To create new special effect or filtered videos, use a conversion command listed above, with two additional parameters: --video-filter and vfilter.

For example, this command reads a video file named input.mpg and applies the ripple effect to create a new MPG video named output.mpg.   

cvlc input.mpg --play-and-exit --video-filter=ripple --sout "#transcode{vcodec=mp1v,acodec=mpga,ab=128,vfilter=ripple,deinterlace}:std{access=file,mux=mpeg1,dst=output.mpg}"

Linux VLC commands simple filter command Stephen Glasskeys

Use a similar command to create a wave special effect video:

cvlc input.mpg --play-and-exit --video-filter=wave --sout "#transcode{vcodec=mp1v,acodec=mpga,ab=128,vfilter=wave,deinterlace}:std{access=file,mux=mpeg1,dst=output.mpg}"
Linux VLC commands wave effect Stephen Glasskeys

The strings passed to these filter parameters are actually VLC module names. Other special effect modules I've tested and created videos successfully with the command above are motionblur, invert, mirror, motiondetect, and psychedelic. To see the full list of VLC's installed modules, use the vlc -l command in terminal.

Rotate video

If you enjoy watching movies sideways -- you're in luck -- because VLC allows you to rotate video to the Nth degree.

cvlc input.mpg --play-and-exit --video-filter=rotate --sout "#transcode{vcodec=mp1v,acodec=mpga,ab=128,vfilter=rotate{angle=45},deinterlace}:std{access=file,mux=mpeg1,dst=output.mpg}"

Linux VLC commands rotate video effect Stephen Glasskeys

Marquee text

Create videos with marquee (marq module) text. Additional marquee parameters can be used to specify a screen position, color, font size, timeout, or opacity level.

This chart shows the numeric values assigned to marq-position screen locations:

Use this chart when setting position values Stephen Glasskeys

The following command was used to create the video captured below. To show marquee text for the entire duration of a video, use a --marq-timeout value of 0, otherwise assign this duration in milliseconds. And, unlike other effects mentioned thus far, marquee text requires the sfilter parameter (stream filter).

cvlc input.mpg --play-and-exit --marq-marquee="MARQUEE TEXT" --marq-position=0 --marq-color=0xC0C0C0 --marq-size=64 --marq-timeout=0 -marq-opacity=128 --sout "#transcode{vcodec=mp1v,acodec=mpga,ab=128,sfilter=marq,deinterlace}:std{access=file,mux=mpeg1,dst=output.mpg}"
 
Linux VLC commands marquee text Stephen Glasskeys

Adding logos

Finally, VLC also supports embedded logo images, as long as your logo image is a PNG file. I used Photoshop to create this logo with a transparent background:

Transparent logo Stephen Glasskeys
cvlc input.mpg --sub-filter logo --logo-file="logo.png" --logo-opacity=164 --logo-position=10 --play-and-exit --sout "#transcode{vcodec=mp1v,acodec=mpga,sfilter=logo}:standard{access=file,mux=mp4,dst=output.mpg}"

Linux VLC commands logo with transparency Stephen Glasskeys

Similar to marquee text, logos can also be positioned with numeric --logo-position values. You can also "alpha blend" your logo, tweaking a parameter known as  --logo-opacity. For more information regarding the logo module and its parameters, consult VLC's logo wiki.

This article is published as part of the IDG Contributor Network. Want to Join?

ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon