FFmpeg is a cross-platform, open source audio and video converter. It supports most industry standard codecs and can convert and transcode media files from one format to another. Vdx is an intuitive commandline wrapper to FFmpeg. It is an open source project written in NodeJS and released under MIT license.
Using Vdx, we can do most common audio and video encoding and transcoding operations as listed below:
- Crop the video to the specified dimension,
- Convert audio/video file to a different file format,
- Change the frame rate,
- Remove audio from a video file,
- Resize the videos to a specific dimension,
- Reverse the videos,
- Rotate videos to different angles,
- Change audio/video playback speed,
- Trim audio/video to the specified duration,
- Increase or decrease volume of audio/video,
- Run multiple operations on multiple files concurrently,
- Print the underlying FFmpeg command that is being used for a specific operation,
- And more to come.
Install vdx on Linux
As stated already , vdx uses FFmpeg under the hood for video encoding and is written in Nodejs. So make sure you have installed FFmpeg and Nodejs on your Linux box. The following guides helps you to install them on Linux.
After installing FFmpeg and Nodejs, run the following command to install vdx on your Linux system:
$ npm install --global vdx
How to use vdx (the commandline wrapper to FFmpeg) to process videos and audios
Vdx usage is as easy as ffmpeg's usage. The general syntax of vdx is:
$ vdx <pattern> [options]
Vdx supports various audio and video processing operations. Here are some examples to get started with vdx.
1. Crop videos
Vdx can crop a given video to specific height and width of your choice using
-c, --crop flag. For the example, the following command will crop the video.mkv file to 640 x 360 pixels:
$ vdx video.mkv --crop=640,360
The above command will crop the video to width 640 pixels, height 360 pixels.
Upon successful completion, you will see the following output:
✔ video.mkv › build/video.mkv
The processed video will be saved in a directory named "build" in your
$HOME directory. You can change this output location with
-o, --output flag like below.
$ vdx video.mkv --crop=640,360 --output=/home/ostechnix/Videos
You can even crop the videos from the specific positions i.e. coordinates.
For example, If you want to a video with a width of 640 pixels and a height of 360 pixels, starting from the position (20,15), use this command:
$ vdx video.mkv --crop=20,15,640,360
You can also process multiple videos of same type using wildcards. The following command will process all
.mkv format videos:
$ vdx '*.mkv' --crop=640,360
2. Convert files to different format
If you want to convert an audio or video to a different format, use
-f, --format flag.
$ vdx video.mkv --format mp4
This command converts the video format
3. Change frame rate
Frame rate is the amount of individual video frames that your camera captures, per second. To change the frame rate of a video, use
-fp, --fps flag:
$ vdx video.mkv --fps=30
The higher the frame rate, the smoother the video will be.
4. Remove audio from videos
To strip the audio from a video, use
-na, --no-audio flag.
$ vdx video.mkv --no-audio
I don't know why the developers doesn't give us an option to add audio to videos. It could be useful to create videos with our favorite song or music.
5. Resize videos
To resize a video to specific dimension, use
-r, --resize flag.
$ vdx video.mkv --resize=360,640
This command will resize the given video to width 360, height 640.
If you want to the aspect ratio of the video, set either
For example, to set
width to 360 and maintain the aspect ratio, use the following command:
$ vdx video.mkv --resize=360,-1
Similarly, to set
height to 640, maintaining the aspect ration, the command would be:
$ vdx video.mkv --resize=-1,640
6. Reverse videos
The videos can be reversed using
-rv, --reverse flag.
$ vdx video.mkv --reverse
If you the resulting video, it will play from the end to start i.e. backwards.
7. Rotate videos
Vdx can able to rotate given videos to specific angles using
-ro, --rotate flag. The supported angles are 90 degrees clockwise. 90 degrees counter-clockwise and 180 degrees.
To rotate the given video to 90 degrees clockwise, use the following command:
$ vdx video.mkv --rotate=90
Rotate a video to 90 degrees counter-clockwise:
$ vdx video.mkv --rotate=-90
Rotate a video to 180 degrees:
$ vdx video.mkv --rotate=180
8. Change playback speed
The playback speed of the given audio/video file can be adjusted using
-s, --speed flag.
To halve the playback speed, use:
$ vdx video.mkv --speed=0.5
To double the playback speed:
$ vdx video.mkv --speed=2
9. Trim media files
Sometimes, you might want to cut a part from an audio or video file using starting and ending time. If so, you can trim the audio or video file using
-t, --trim flag.
If you want to trim the given video from time 1:30 to the end of the video file, use this command:
$ vdx video.mkv --trim=1:30
You can also specify both starting and ending time like below:
$ vdx video.mkv --trim=1:30,2:30
10. Increase or decrease volume
Just like playback speed, we can increase or decrease the volume of the video file(s) using
-vo, --volume flag.
To decrease the volume by half from a video file, run:
$ vdx video.mkv --volume=0.5
Double the volume of a video file:
$ vdx video.mkv --volume=2
11. Run multiple operations on multiple files concurrently
Vdx can process multiple media files with multiple different options simultaneously.
$ vdx '*.mkv' --format=mp4 --fps=30 --resize=360,640 --volume=2 --trim=1:30,2:30 --rotate=90
The above command will convert all .mkv format files to .mp4 format, change the frame rate to 30 fps, resize them to width 360 and height 640, double the volume, trim down them from time 1:30 to 2:30 and rotate them to 90 degrees clockwise.
12. Print the underlying FFmpeg command that vdx uses
As stated already vdx is just the wrapper to FFmpeg program. Under the hood, Vdx uses FFmpeg for video processing. If you want to know what FFmpeg command that vdx uses while performing a specific operation, use
-d, --debug flag.
$ vdx video.mkv --no-audio --debug
/usr/bin/ffmpeg -i 'video.mkv' -an -codec:v copy -y 'build/video.mkv' ✔ video.mkv › build/video.mkv
As you can see in the above output, the actual FFmepg command that vdx for stripping the audio from a video is:
ffmpeg -i 'video.mkv' -an -codec:v copy -y 'build/video.mkv'
To know the general usage of vdx utility and all available options, refer the help section by running the following command:
$ vdx --help
Vdx supports only a dozen basic options. FFmpeg has a lot of options to perform all sorts of advanced video processing operations. I have compiled most commonly and frequently used 20+ FFmpeg commands. If you are interested to learn about FFmpeg commands, refer the following guide:
If you only require a basic video encoding tasks, vdx is more than enough!