Blog-Archiv

Montag, 16. September 2024

Using ffplay for Writing Cutting Plans

The widely used ffmpeg library is a complex commandline-oriented video software. It also contains a very basic video viewer named ffplay which may be useful for certain purposes. After installing ffmpeg, you can play a video using following command from some terminal-window:

ffplay pathToSomeVideo.mp4

When you run this player, you will see just the video screen with no control-buttons at all. That doesn't mean that you can't stop the video, seek to some position, or display single frames, but everything is quite limited. On the ffmpeg home page you can find documentation about available keyboard commands. Here are some explanations about the most important ones.

  • The 'p' (→pause) or Space key stops the video. Pressing it again ends the pause, so it is like a Start/Stop button.

  • The 's' (→step) key also stops the video, but if already stopped, it goes to the next frame image. Unfortunately there is no "step back one frame" command...

  • If you right-click with the mouse into the video screen, ffplay will seek to a video position proportional to the click's horizontal coordinate inside the screen's width. That means if you right-click into the (horizontal) middle of the screen, ffplay will seek to the middle of the video, if you right-click near the left border, the video will continue near its beginning. You will see output like this on console:
    Seek to 51% ( 0:02:17) of total duration ( 0:04:27)       B f=0/0
    The pause-state will not be changed by this action, i.e. when the video was running, it will continue at clicked position, when it was stopped, it will display the frame at clicked position.

  • The Cursor-Left key will seek backward 10 seconds, Cursor-Right will seek forward 10 seconds. The pause-state will not be changed by this action.

  • The Cursor-Down key will seek backward 1 minute, Cursor-Up will seek forward 1 minute. Useful for quickly winding back to start on short clips. The pause-state will not be changed by this action.

  • The 'q' (→quit) key end the ffplay run.

While playing or stepping, on the console (terminal window) where you started ffplay from, you will see some output like

  42.39 A-V: -0.049 fd=   3 aq=   66KB vq= 2455KB sq=    0B f=0/0

I could not find documentation about this line, but obviously the first number ('42.39') gives the precise time in seconds where the video currently is.
So, if you want to cut out certain frames from a video very precisely, I would suggest following workflow:

  1. Run "ffplay TheVideo.mp4" from command line.
  2. Press the 's' key to go to the frame you want to find, or 'p' and right-click to go near that position.
  3. If you found the frame you want to cut out, copy the seconds display in console window to your cutting plan; this is your clip's begin.
    Skip frames as long as you want to keep them, then again copy the seconds display in console window to your cutting plan; this is your clip's end. As much as I observed, the frame at the end time will not be in the clip anymore.

If you are interested in using a cutting-plan to cut videos with ffmpeg, my UNIX shell-scripts may be useful for you (also running on WINDOWS via CygWin). Read my Blogs here:

You can copy any source-code of my scripts freely.
UPDATE: My newest Blog contains a complete list of my passed ffmpeg Blogs!




Keine Kommentare: