We can customize our video, audio or image file with help of tools like FFmpeg , ImageMagick
FFmpeg is very useful command-line tool that converts audio or video formats.
ImageMagick is a tool which can be used to edit, create, compose, or convert bitmap images.
- Command to change the orientation of a video.
ffmpeg -i inputvideo -vf "transpose=1" outputvideo
The above command will rotate the input video clockwise 90 degree
Other parameters for transpose are as below:
- For 90 degree anti clockwise and vertical flip (which is default) put transpose = 0.
- For 90 degree clockwise put transpose = 1.
- For 90 degree anti clockwise put transpose = 2.
- For 90 degree clockwise and vertical flip transpose = 3.
- Cutting video file into a smaller clips
You can use the time offset parameter (-ss) to specify the start time stamp in HH:MM:SS.ms format while the -t parameter is for specifying the actual duration of the clip in seconds.
ffmpeg -i <input.mp4> -ss 00:00:50.0 -codec copy -t 20 <output.mp4>
- Converting videos from .mov format to .mp4 format.
For converting videos in .mov format into .mp4 we use a command as below:
Make sure the path of FFmpeg tool is also wirten before writing the below line.
ffmpeg -i <input> -c:v libx264 -profile:v baseline -filter:v scale=640:-1 -c:a libfaac -ar 44100 -ac 2 -b:a 128k -movflags faststart <output>
Note: One should be very careful of spaces while writing the commands. Also make sure that what- ever options we want to implement on the output file we should place it after the input option (i.e. -i input).
- Creating cropped thumbnail without changing the Aspect Ratio of thumbnail with black background that will fill the sides of the thumbnail.
Aspect Ratio can be defined as an attribute of an image that describes the proportionality between the width and height of an image. This is a done using ImagicMagic command as below:
convert <inputfile> \( +clone -background black -rotate 90 -size 240x140 \) -gravity north -compose Src -composite <outputfile>
- Cutting video file into a smaller clip
We can use the time offset parameter (-ss) to specify the start time stamp in HH:MM:SS.ms format while the -t parameter is for specifying the actual duration of the clip in seconds.
ffmpeg -i <input.mp4> -ss 00:00:50.0 -codec copy -t 20 <output.mp4>
- Remove the audio component from a video
Use the -an parameter to disable the audio portion of a video stream.
ffmpeg -i video.mp4 -an mute-video.mp4
- Getting the audio from video
The -vn switch extracts the audio portion from a video and we are using the -ab switch to save the audio as a 256kbps MP3 audio file.
ffmpeg -i myVideo.mp4 -vn -ab 256 myAudio.mp3
- Get an image frame from a video
The following command will extract the video frame at the 25s mark and saves it as a 700px wide JPEG image.
ffmpeg -ss 00:00:15 -i video.mp4 -vf scale=800:-1 -vframes 1 image.jpg
0 Comment(s)