Friday, April 5, 2013

Trim MP4

Use the following command to trim a MP4 file.

ffmpeg -ss 00:02:45 -t 00:04:00 -i source.mp4 -c copy output.mp4

Explanation:

-ss 00:02:45 : You can trim the video from beginning ( set this parameter to 00:00:00)  or in the middle. In this example, the output will start from 2mins and 45 seconds from the original video.

-t 00:04:00 : duration that need. In this example, the output will start from 02:45 of the source video and stop at 06:45.

-c copy : use the same codec with the source file

Convert FLV to MP4

Use the following command to convert FLV file to MP4.

ffmpeg -i source.flv output.mp4

If you received error (Codec is experimental but experimental codecs are not enabled, try -strict -2) when trying to use the command above, you can try

ffmpeg -i source.flv -strict -2 output.mp4

If you would like to change the bit rate, you can add in ar option.

ffmpeg -i source.flv -ar 22050 output.mp4