How to remove unwanted content in Videos using ffmpeg?

When we record videos on cameras and mobile phones, we will be ending up with some unwanted content in the video like camera shake, speaker sneezes, someone came in the middle.

When recording videos, it is better keep on rolling so that the recording is done in a single shot. We can always remove the unwanted content using Video editors.

OpenShot, ShotCut are good open source video editors. Still I love command line based tools for any task. They give immense power of automation.

FFMPEG is a awesome command line video editor. Let us see here how can we use ffmpeg to remove some content in a video.

Here is the situation.

Total video time : 20 m
Remove time start – 2.26
Remove time end – 10.5

All we need is ffmpeg and MP4Box. Install them using below command.

sudo apt install gpac ffmpeg

Create a clip of video. From video start time to Remove start time.

ffmpeg -i create_ebooks.mp4 -ss 00:00:00 -t 00:02:25 -async 1 -c copy 1.mp4

Create a clip of video. From Remove end time to Video end time.

ffmpeg -i create_ebooks.mp4 -ss 00:10:05 -t 00:42:54 -async 1 -c copy 2.mp4

Now, we have two clips. Merge them both with MP4Box

MP4Box -add 1.mp4 -cat 2.mp4 newvideo.mp4

Thats all. The new video is there, only with desired content.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s