Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim mp4 files without encoding it again

I have a .mp4 video file, I need to trim it, however no matter how I do it, trimmed video is being encoded again which results in noisy video.

What I've tried:

  1. Open video with Matlab, read frames and write only the frames that I want to have in trimmed video, I use 'MPEG-4' option.

  2. Trim video using Windows Movie Maker.

  3. Trim video using VirtualDub.

In first 2 scenarios original mp4 movie is encoded again after trimming it. I couldn't get mp4 files open in VirtualDub.

So what would be the easiest way to trim a video without re-encdong it?

like image 863
guneykayim Avatar asked Feb 01 '16 17:02

guneykayim


1 Answers

You can do the split and re-encode in one command.

Create a text file, list.txt,

like this

file 'in.mp4'
inpoint 48.101
outpoint 67.459
file 'in.mp4'
inpoint 76.178
outpoint 86.399
file 'in.mp4'
inpoint 112.140
outpoint 125.031

then run,

ffmpeg -f concat -i list.txt -an -crf 18 out_merged.mp4
like image 156
Gyan Avatar answered Oct 23 '22 03:10

Gyan