Trim mp4 files without encoding it

I have a .mp4 video file, I need to trim it, however, no matter how I do it, the cropped video is encoded again, which leads to a noisy video.

What I tried:

  • Open the video with Matlab, read the frames and write only the frames that I want to have in the cropped video, I use the 'MPEG-4' parameter.

  • Trim video using Windows Movie Maker.

  • Trim video using VirtualDub.

In the first two scenarios, the original mp4 movie is again encoded after being cropped. I was unable to open mp4 files in VirtualDub.

So, what would be the easiest way to crop a video without re-encdong?

+6
source share
2 answers

You can split and transcode 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 
+3
source

I solved it with the following commands:

 ffmpeg.exe -ss 48.101 -t 19.358 -i in.mp4 -an out_part1.mp4 ffmpeg.exe -ss 76.178 -t 10.221 -i in.mp4 -an out_part2.mp4 ffmpeg.exe -ss 112.140 -t 12.891 -i in.mp4 -an out_part3.mp4 ffmpeg -i out_part1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intrmdt1.ts ffmpeg -i out_part2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intrmdt2.ts ffmpeg -i out_part3.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intrmdt3.ts ffmpeg -i "concat:intrmdt1.ts|intrmdt2.ts|intrmdt3.ts" -c copy out_merged.mp4 

And some explanation:

  • Providing the -ss (start time) and -t (duration) options before the -i (input) option avoids unnecessary decoding.
  • Do not use -c copy provides transcoding, therefore, the result is more accurate (it came from here ).
  • I used -an because I don't need sound, if you need sound, just omit this option.
  • Before concatenating the received cropped videos, I had to transcode them into mpeg transport streams in order to achieve lossless concatenation (for more detailed information you can see here link ).
+2
source

All Articles