playing a specific interval of a video in mplayer using command line option
Asked Answered
P

3

31

I am using mplayer to play videos... I wanted to know if there are command line options to play a specific interval of a video in mplayer? For example, if I want to play a video file from 56 secs for a duration of 3 secs, then what would the command line options be? I know about the -ss option that will seek to a specific position, but how do I specify the duration that I want to play? Concretely, if I want a command that plays a video file starting at the beginning of the 56th second and plays 3 seconds of the video (i.e., until the beginning of the 59th sec, or equivalently, the end of the 58th sec.), what would the command look like?

I have been looking at the man page, but no success as yet. Maybe I am missing something. I really appreciate your help!

Puckett answered 26/3, 2012 at 19:4 Comment(1)
Isn't there an endpos switch?Sanctimonious
W
45
man mplayer

reveals:

-ss <time>: Seek to given time position
-endpos <[[hh:]mm:]ss[.ms]|size[b|kb|mb]>: Stop at given time or byte position

so you should be able to do what you want by simple using:

mplayer -ss 56 -endpos 3
Wallaroo answered 24/4, 2012 at 7:31 Comment(1)
what if I want to stop at a time point counting from the end? For example, I want to play video from 0:15 to T-0:12, where T is a total play time of the video, it can vary.Watford
W
21

Using mpv, a fork of MPlayer:

# specify start and length
mpv --start=3:20 --length=10 <file-name>

# specifying end
mpv --start=30 --end=40 <file-name>

# specifying end from end
mpv --start=80 --end=-90 <file-name>

More at mpv manual.

Watford answered 13/6, 2014 at 11:15 Comment(1)
Thanks . For my file mplayer did not work for endpos. Using mpv worked superb!Expose
P
1

If you want to loop with loop=inf, mpv --start and --length/end suggested by @qed will stop working, you need:

mpv --start=0:56 --ab-loop-a=0:56 --ab-loop-b=0:59 foo.mp4

Note:

  • --start for first time play, then hit --ab-loop-b will seek to --ab-loop-a time to loop. So --start and --ab-loop-a need same value.
  • loop=inf is no longer needed.

Relevant issue ticket here.

Patsis answered 13/9, 2023 at 4:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.