Blog Archives

Fade-in / Fade-out using FFMPEG

The following examples show how you can use FFMPEG to do fade-in fade-out for audio and/or video. ffmpeg -i input.mp4 -vf “fade=t=in:st=0:d=10,fade=t=out:st=10:d=5” -c:a copy output.mp4 The example above applies both fade-in and fade-out effects for video, but not for audio.

Posted in FFmpeg, Tips & Tricks

Overlay Videos

You can try the following if you would like to overlay a video onto a master (background) video, without re-encoding. ffmpeg.exe -i master_video.mp4 -vf “movie=smaller_inner_video.mp4[inner];[in][inner] overlay=70:70 [out]” completed.mp4 where 70:70 in this example are the positions that you would like

Posted in FFmpeg, Tips & Tricks

Crop a Video

The following example shows how you can use FFMPEG to crop a video without re-encoding. ffmpeg -i input.mp4 -filter:v “crop=1280:200:0:500” -c:a copy output.mp4 where 1280 and 200 are the output size (width and height) of the cropped video, 0 and

Posted in FFmpeg, Tips & Tricks

Extract Audio and Adjust Volume

The following are two common usages of FFMPEG. The first command extracts an audio track from a video file in the exact format that it was multiplexed info the video file. The second example shows how you can adjust the

Posted in FFmpeg, Tips & Tricks

Converting MP4 Videos to MPEG

The following command converts an MP4 video to an MPEG video with high quality: ffmpeg -i input.mp4 -c:v mpeg2video -q:v 5 -c:a mp2 -f vob output.mpg

Posted in FFmpeg, Tips & Tricks

Converting a Video without Re-encoding

FFMPEG can be used to convert a video from one format to another. Very often, the video itself to be converted is already encoded in an appropriate format. You just want to convert the container format. In the following example,

Posted in FFmpeg, Tips & Tricks

Extracting a Portion of Video using FFMPEG

If you would like to extract a portion of a video without re-encoding, consider using FFMPEG. The following example illustrates a command to extract a video from the 24th minute line and for 4 minutes 8 seconds, keeping all audio

Posted in FFmpeg, Tips & Tricks

Setting the default audio stream using FFMPEG

Here is another use case for FFMPEG. In some projects, after you mixed and matched video and audio streams from different files, the resultant file may not have the default audio stream as desired. You can use the following command

Posted in FFmpeg, Tips & Tricks

Changing resolution of a video using FFMPEG

Very often you would like to change the not-so-standard resolution of a video to some more common formats, e.g. 4:3 or 16:9. You can try using the following FFMPEG command to achieve this. ffmpeg -i video_1920.mp4 -vf scale=640:480,setdar=4:3 video_640x480.mp4 -hide_banner

Posted in FFmpeg, Tips & Tricks

Replacing an Audio Stream using FFMPEG

This is another example of using FFMPEG to manipulate video and audio files. In this case, one would like to replace the second audio stream in a video file by another audio file. Here is the command you may want

Posted in FFmpeg, Tips & Tricks