[Discuss] Please help edit an mp4 file

John Abreau abreauj at gmail.com
Tue Mar 2 15:46:37 EST 2021


For the BLU meetings, I use ffmpeg on the commandline to cut videos at
specified timecodes and to transcode between different container formats.

I usually just trim off the beginning and the end of the video file. If I
need to cut a chunk out of the middle, I first transcode the video to an
mkv file, then cut with ffmpeg and rejoin the pieces with mkvmerge. A
graphical video editor, even a rudimentary one, is a huge overkill for a
simple edit like this.

I use mplayer to find the timecodes where I want to make the cuts. For
example, if I have a 2-hour video and I want to chop out a 5-minute segment
in the middle, I'd do the following:

1. Play the video with mplayer and identify the timecodes where the
corruption begins and ends:

    mplayer orig.mp4

Type a lowercase "o" to toggle the timecode display; it toggles between 4
states.
To skip around, the left/right arrows skip a few seconds, the up/down
arrows skip a minute, and the PgUp/PhDown keys skip 10 minutes. Space bar
toggles pause/play.

Let's say the corruption begins at timecode 01:22:20 and ends at 01:24:38.
You'd want to extract two parts:
    a. Everything from the start of the video to 01:22:20, which is 1h 22m
20s, or 3600+1320+20s == 4940 seconds
    b. Everything from 01:24:38 to the end of the video

2. Extract the two parts of the video file, transcoding them and saving to
an mkv file:

    ffmpeg -i orig.mp4 -t 4940 -acodec ac3 -vcodec libx264 -ab 256k
part1.mkv
    ffmpeg -i orig.mp4 -ss 01:24:38 -acodec ac3 -vcodec libx264 -ab 256k
part2.mkv

3. Merge the two parts together:

    mkvmerge -o fixed.mkv part1.mkv +part2.mkv

4. Optionally, convert back to mp4:

    ffmpeg -i fixed.mkv -acodec copy -vcodec copy fixed.mp4



On Tue, Mar 2, 2021 at 2:31 PM E. William Horne <malassimilation at gmail.com>
wrote:

> My Quaker meeting has been having get-togethers via Zoom video
> conferencing, and our host recorded a recent meeting on the subject of
> de jure segregation.
>
> However, part of a video that the host streamed into the Zoom video
> conference was defective, so I'm looking for open-source software that I
> can use to cut that part out of the .mp4 recording of the meeting.
>
> All leads appreciated, and all suggestions welcome. Thank you for your
> time.
>
> Bill Horne
>
> _______________________________________________
> Discuss mailing list
> Discuss at lists.blu.org
> http://lists.blu.org/mailman/listinfo/discuss
>


-- 
John Abreau / Executive Director, Boston Linux & Unix
Email: abreauj at gmail.com / WWW http://www.abreau.net / PGP-Key-ID 0x920063C6
PGP-Key-Fingerprint A5AD 6BE1 FEFE 8E4F 5C23  C2D0 E885 E17C 9200 63C6


More information about the Discuss mailing list