Ticket #49 (new enhancement)

Opened 3 years ago

Last modified 12 months ago

[PATCH] Enable Single Step Backward in Video

Reported by: oflebbe Owned by:
Priority: normal Milestone:
Component: General Version: devel
Severity: minor Keywords: seek step single backwards
Cc: hhielscher@… Platform: All

Description

Hi,

A lot of users want to be able to single frame backward in time.

You can find several enhancement requests for vlc and mplayer, which have been stalled because of technical difficulties. This has been a killer feature for xanim (ehem...) in the past.

Thanks to the new precise positioning in mplayer2 it is now possible to single step backwards, even on non-key frames. I chose ',' for the key.

Since the single Step Forward '.' does not work reliable for some codecs I added a single step forward the same way as backwards (Key ';'), just in case.

Unfortunatly the OSD is displayed when seeking. Can we turn this off non-globally for these seeks, since it is annoying?

Attachments

PATCH.txt Download (1.5 KB) - added by oflebbe 3 years ago.
patch relative to 2.0.0

Change History

Changed 3 years ago by oflebbe

patch relative to 2.0.0

comment:1 follow-up: ↓ 4 Changed 3 years ago by harklu

I think the problem with this patch is that not all videos have a fixed framerate, so it won't always work reliably.

But maybe you could simply store the timestamp of the previous frame while doing playback. Then you could always seek back one frame exactly.

Unfortunately you can't do this if you just did a seek (this includes stepping backwards multiple times at once). For this case, you could try to create a unique frame ID out of the position of the frame into the file, and then do the following:

  • seek backward by a small arbitrary amount
  • keep decoding until you find the frame ID of the frame you started seeking from
  • seek to the frame before that frame (since you just decoded it, you know its position)
  • (you could store frame IDs for more than one past frame to make stepping backwards faster)

This still assumes that exact seeking actually works as intended, which is not guaranteed. I guess problems include that the file could contain frames with ambiguous timestamps, or that the seek index could be broken.

It gets complicated quickly.

comment:2 Changed 2 years ago by busytoby

Is this entirely dissimilar from the common request for XmplayerX to support backmasking/reverse playing of audio and video? It seems the first step to supporting such a thing is playing back a single 'frame' or 'sample' in reverse; however the supplied patch does not accomplish that either.

This would be a huge feature addition for analysis of Sports and other physical video media as well as a hugely useful tool in analysing audio samples and could also springboard into ping-pong and other types of effects.

In other words, this would be HUGE for me and others :) would like to give my *bump* towards having this implemented.

comment:3 Changed 2 years ago by uau

The implementation for reverse playback would be almost completely different. Doing an individual accurate seek to the previous frame is too slow to do for every frame and have anything like smooth backwards playback. In practice a backwards playback implementation would require decoding one keyframe interval's worth of frames into a memory buffer and then showing them backwards from that buffer. That would be doable (I think the RAM use for normal content would stay within 1-8 GB), but I don't know if anyone is going to work on it.

comment:4 in reply to: ↑ 1 Changed 2 years ago by oflebbe

Replying to harklu:

I think the problem with this patch is that not all videos have a fixed framerate, so it won't always work reliably.

Sorry, to answer late. IMHO this is more or less an esoteric case. Why killing a feature which works for almost every video, which users need badly?

My users are very happy with this patch. I do not oppose to generate a correct fix, but this will do it for almost all videos.

BTW: I have learned that other things in mplayer( even in mplayer2) are not implemented 100% correctly.

comment:5 Changed 20 months ago by testerus

  • Cc hhielscher@… added

comment:6 follow-up: ↓ 7 Changed 20 months ago by hittepå

This is what I'm looking for in a video player. Working as an animator, frame stepping, in any direction, is a crucial worktool.
Right now there are very few options on linux for backward stepping.
I've asked for this feature in many other players but it probably won't be applied to any of them.

Please, please include this patch in mplayer2. It would make it a top notch tool for me! (and many others)
It doesn't matter as much that it doesn't work on all formats or shaky on some. If anyone needs this feature they can work in formats that allows backward frame stepping. The benefits would be far better than the drawbacks.

comment:7 in reply to: ↑ 6 Changed 20 months ago by testerus

Since there is no way to send hittepå an email, I ask here.

Replying to hittepå:

Right now there are very few options on linux for backward stepping.

Would you please be so kind and share what software is available that does backward frame stepping? TIA.

comment:8 follow-up: ↓ 10 Changed 20 months ago by uau

I have made more comments about this feature elsewhere, but seems that some of the relevant info is not in this bug report.

You can get "works in most cases" level of backwards framestep functionality without any code changes. Try placing this in your input.conf configuration file:

F5 seek -0.05 0 1

This means pressing F5 will do an accurate 0.05 second seek backward. For about 19-36 FPS video, this should usually be a single frame. For higher FPS, you can use a smaller number.

I'm not convinced that the existing patch would do anything more usable (except for adding a keybinding by default) or reliable than this.

comment:9 Changed 20 months ago by hittepå

testerus. The only video player I know of with backward frame stepping is Snappy -  http://luisbg.blogalia.com/historias/69950

The other somewhat usable solution is to use Avidemux, a bit clunky for the task of just reviewing clips but does the job.

uau. Thank you! That worked very, very well for the quick test I just did (mp4, 25fps) I have to test this further but for now; wow!

comment:10 in reply to: ↑ 8 Changed 12 months ago by etatoby

Replying to uau:

You can get "works in most cases" level of backwards framestep functionality without any code changes. Try placing this in your input.conf configuration file:

F5 seek -0.05 0 1

Thank you. I was looking around for this feature and I can attest that this line works in all of the cases I've tested so far. I suggest adding it as a default keybinding under comma. There are many users who would benefit from it.

Note: See TracTickets for help on using tickets.