[MPlayer-users] Using ffmpeg or mencoder to edit files with a edit list

James Board jpboard2 at yahoo.com
Sat Jul 13 22:53:12 CEST 2013

 From: houghi <houghi at houghi.org>
To: "MPlayer usage questions, feature requests, bug reports" <mplayer-users at mplayerhq.hu> 
Sent: Saturday, July 13, 2013 11:51 AM
Subject: Re: [MPlayer-users] Using ffmpeg or mencoder to edit files with a edit list

On Sat, Jul 13, 2013 at 07:03:40AM -0700, James Board wrote:
> My input file is in a raw frame-by-frame format: there's no MPEG
> encoding or groups of pictures.  Each frame is stored by itself.  I'd
> like to do frame-exact editing on the file.  For example: remove
> commercials in an hour long show.

OK, so for frame 1 - 10.000 you only want to show e.g. 1 -5.000 and
5.500 - 8.000  and then 8.500 to 10.000 (Yeah 10.000 is made up)
Or just show 0:00:00 to 0:15:00 and 0:20:00 to 0:40:00 and then 0:45:00 to
1:00:00 ?

> I have an edit list, which is a text file.  It consists of a list of start and
> end frame for each sequence of frames of the input file that I would
> like to include in the output file.  Alternatively, I could generate a list 
> of sequences that I would like to delete from the output file.

OK, so you have frames.

> This seems like a simple thing to do, but I'm not sure if it's common 
> enough for it to have been coded into ffmpeg.  Is there a way, with
> ffmpeg or mencoder, to somehow produce the output file with only
> the desired sequences?  I didn't see this is in the documentation, but 
> then I only searched on 'edit' and didn't find what I wanted.

When you have frames and the frames per second, you can calculate the
time. e.g. mplayer -ss 600 -endpos 1300
That you can output to a file and then join the different files.
Same goes with ffmpeg:
ffmpeg -i in.mp4 -ss [start] -t [duration]

Yet another method could be melt. Melt works with frames, so with the
first example you would get:
melt file.raw in=1 out=5000 \
    file.raw in=5500 out=8000 \
    file.raw in=8500 out=10000

Adding -consumer and other things will see to the output.

melt is more precise, because it is per frame. It is also much, much

What I do is something similar. Instead of doing a timelapse for a
roadtrip (1 frame per X time) I take 1 second per X time. Part one of the
script looks like this:
for I in `seq 0 60 3600` #3600 is 1 hour
    MIN=$(printf %06d $I)
    mencoder -ss $MIN -endpos 60 -nosound -noskip \
    -mc 0 -ovc copy movie.mp4 -o movie.$MIN.mp4

The second part looks like:
FILES=$(ls -1 $DIR/out.*.mp4|sort)
mencoder -really-quiet -nosound -noskip -mc 0 -ovc copy -o seconds.mp4 $FILES

Hopefully this is enough to get you going.

"Other than the fact Linux has a cool name, could someone explain why I should
use Linux over BSD? No. That's it. The cool name, that is. We worked very hard
on creating a name that would appeal to the majority of people, and it
certainly paid off [...]                                     -- Linus Torvalds
MPlayer-users mailing list
MPlayer-users at mplayerhq.hu

It sounds like what you are suggesting is that I run ffmpeg once
for each continuous segment, and then concatenate them together.
Is that right?  Does you audio stay in sync?  What if you have one 
hundred segments?

Anyway, I'd rather not do it that way.  The man page on mencoder lets
you do this with a single option: -edl.  Since mencodre is supposed to
be obsolete, and ffmepg replaces it, I was looking for the equivalent
way of doing it in ffmpeg.

I have no idea what your script does.

More information about the MPlayer-users mailing list