Log in

View Full Version : mencoder and start frame


Jamesb
23rd July 2009, 16:32
Hello,

This is one of my first posts so please be lenient with me. So I have a little problem with mencoder and its parameters. I need precision in the start and end positions of movies otherwise the sound could be out of sync. I have to cut some parts of the video to edit two of these with something like AfterEffect and one have effects that mencoder has already.

So I would need to cut in 3 parts, like this (example) :
part1: frames 0 - 275
part2: frames 275 - 355
part3: frames 355 - 400

Note: all these frames are keyframes (on purpose).
I could use the -ss option but I read at many place it isn't very effective and I need to calculate it with floating numbers :( Anyway frame number is more precise, no floating only integer. Did I forget something in mencoder ?
Thank you for your help in advance.

nm
23rd July 2009, 17:12
This is one of my first posts so please be lenient with me. So I have a little problem with mencoder and its parameters. I need precision in the start and end positions of movies otherwise the sound could be out of sync. I have to cut some parts of the video to edit two of these with something like AfterEffect and one have effects that mencoder has already.
Wouldn't it be easier to do all the editing and effects with some other program if you need to use one anyway? MEncoder is a rather bad tool for cutting video or applying filters to specific scenes.

I could use the -ss option but I read at many place it isn't very effective and I need to calculate it with floating numbers :( Anyway frame number is more precise, no floating only integer. Did I forget something in mencoder ?
I dont think there is a way to seek by frame number with MEncoder.

Tack
23rd July 2009, 21:59
Check the man page for -edlout, -edl, and -hr-edl-seek. EDL files are specified in timestamps, but the precision is sufficient such that you should be able to cut at specific frames.

Unfortunately -hr-edl-seek only works with certain demuxers.

Jamesb
24th July 2009, 00:02
Check the man page for -edlout, -edl, and -hr-edl-seek. EDL files are specified in timestamps, but the precision is sufficient such that you should be able to cut at specific frames.

Unfortunately -hr-edl-seek only works with certain demuxers.

Thank you, I think I'll use this solution with EDL. But anyway I think I should make a patch to mencoder to have an option (why not -begframe). I'll give a try with EDL as an example. I'll tell you if I make it working right. Do you think it's a good idea ?

Jamesb
24th July 2009, 20:55
Hello again,

I've done a patch for SVN-r29435-4.3.2 and seems to work well. I need some feedbacks to know if it works for other people too. I posted it there: http://pastebin.com/md999c39 . I added a switch option named -startframe and you need to specify the frame number where to begin the encoding at. It'll scan the frames and start encoding when mencoder reaches it. You can encode even if it's a non-keyframe (but not in avc copy of course). Note that it's working only with mencoder at the moment.

Example: mencoder video.avi -startframe 10 -o video-o.avi -ovc x264 -x264encopts ....

I need your opinions.

Edit1: Changed the patch link because it was the wrong one.
Edit2: Modified the patch for the current 2009-07-24 snapshot version OK

microchip8
24th July 2009, 21:05
@ Jamesb

Better submit this patch for review to the mencoder-users mailing list or to mplayer-dev one. No one from the mencoder devs (the few of them left) will notice your patch here

Jamesb
24th July 2009, 23:09
Better submit this patch for review to the mencoder-users mailing list or to mplayer-dev one. No one from the mencoder devs (the few of them left) will notice your patch here

Yes I think it's better to publish a patch but I won't do it now because there are conditions to send them one (good quality, doc etc...). I would prefer to know the opinion of non mplayer developpers first. If it isn't good and useful why to post it to dev maillist and why to do efforts for nothing.

Dinominant
25th July 2009, 00:46
You can do this by changing the framerate of your video to 1fps. Then -ss <frame_number> -frames <frame_count> will do the trick. When all the encoding is done you can change the framerate back with -ovc copy and -oac copy.

Dinominant
25th July 2009, 08:39
You can do this by changing the framerate of your video to 1fps. Then -ss <frame_number> -frames <frame_count> will do the trick. When all the encoding is done you can change the framerate back with -ovc copy and -oac copy.

Looks like spoke before actually testing the code. It appears that -ss will only seek to keyframes. EDL's will do what you want:

1. Change the FPS of your video to 1fps so you can seek with perfect integer precision.
2. Create 3 EDL's, one for each part.
3. Encode your EDL's. You can speed up the encode by specifying how many frames to encode with -frames

part1.edl
276 400 0

part2.edl
0 277 0
356 400 0

part3.edl
0 356 0

microchip8
25th July 2009, 13:06
Yes I think it's better to publish a patch but I won't do it now because there are conditions to send them one (good quality, doc etc...). I would prefer to know the opinion of non mplayer developpers first. If it isn't good and useful why to post it to dev maillist and why to do efforts for nothing.

you can't assume or know that it won't be useful to mencoder users who never come to doom9 or know what it is for that matter. There are probably thousands out there that only use mencoder and don't come here at all. For me personally, I can live without this functionality but that doesn't mean others can too and may very well want/need it ;)

If the patch does not follow coding standards, then diego will tell you how to improve it before inclusion. He'll also tell you which part of the docs/man pages need updating if patch inclusion is granted

Also you obviously didn't do efforts for nothing since you made the patch in the first place due to you needing something. Others may also want/need it but there's a much bigger mencoder userbase outside of doom9 and these people will never know such a patch exists (unless they come here), even if they may need such functionality.

Jamesb
25th July 2009, 15:42
Looks like spoke before actually testing the code. It appears that -ss will only seek to keyframes. EDL's will do what you want:

1. Change the FPS of your video to 1fps so you can seek with perfect integer precision.
2. Create 3 EDL's, one for each part.
3. Encode your EDL's. You can speed up the encode by specifying how many frames to encode with -frames

Thank you for this workaround. I didn't think like that so thank you. But this is kind of complicated you need to do 1 output at 1 fps after you need to make with right fps etc... So I think my patch make it really easier and faster (in some way)

you can't assume or know that it won't be useful to mencoder users who never come to doom9 or know what it is for that matter. There are probably thousands out there that only use mencoder and don't come here at all. For me personally, I can live without this functionality but that doesn't mean others can too and may very well want/need it ;)

If the patch does not follow coding standards, then diego will tell you how to improve it before inclusion. He'll also tell you which part of the docs/man pages need updating if patch inclusion is granted

Also you obviously didn't do efforts for nothing since you made the patch in the first place due to you needing something. Others may also want/need it but there's a much bigger mencoder userbase outside of doom9 and these people will never know such a patch exists (unless they come here), even if they may need such functionality.

Thank you for your opinion. You are absolutely right ! I'll try to send it to the maillist and thank you for your encouragement. :)