mpv-player / mpv-player/mpv

Looping with Start

Open
#13,860 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

os:win
Dominant language
C
Stars
37k
Forks
3.5k
Avg merge
1d 10h
Merged PRs (30d)
22

Description

Important Information

Provide following Information:
mpv --version
mpv v0.37.0-561-g3afcaeb7 Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects
built on Mar 17 2024 00:11:00
libplacebo version: v7.349.0 (v6.338.0-118-g4fdb9c0-dirty)
FFmpeg version: N-114224-gde2fb43e7
FFmpeg library versions:
libavutil 59.2.100
libavcodec 61.1.101
libavformat 61.0.100
libswscale 8.0.100
libavfilter 10.0.100
libswresample 5.0.100

  • Windows Version
    Windows Version 10 22H2

  • Source of the mpv binary
    https://mpv.io/installation/

  • If known which version of mpv introduced the problem
    I think it has always been there

  • GPU model, driver and version

Reproduction steps

This has been reported before: mpv --loop-file=2 --start=1:10 --end=1:30 file1.avi file2.avi
does not work as exected.

Expected behavior

The two files should be played as follows file1 file1 file2 file2 all starting at position 1:10 and ending 20 seconds later at 1:30. I know that --loop-file=2 will actually play them 3 times although that is hardly expected behaviour either.

Actual behavior

The first time File1 plays it will start from 1:10 but the second and third time it will start from the beginning. Similarly the --end=1:30 will be ignored the second and third time it plays. File2 will just play once and but it will start from 1:10. The addition of the option
--reset-on-next-file=all causes both files to loop twice but the second and third plays ignore the start and end options despite that option.

All this has been reported before but the advice which has been given is not quite correct. It takes the form of including --ab-loop-a,
--ab-loop-b and --ab-loop-count in various combinations many of which do not work as expected either. For example, someone suggested mpv --start 1:10 --ab-loop-a=1:10 --ab-loop-b=1:20 --ab-loop-count=inf file1.avi file2.avi (I am typing this from memory but that is a close approximation). This worked for the original poster but will not work in all circumstances. For example, if the command were: mpv --start 1:10 --ab-loop-a=1:10 --ab-loop-b=1:20 --ab-loop-count=3 file1.avi file2.avi to play the files three times each, the last time each file is played it would continue playing to the end of the file. The full command should actually be:

mpv --start=1:20 --end=1:30 --ab-loop-a=1:20 --ab-loop-b=1:30 --ab-loop-count=3 --reset-on-next-file=all file1.avi file2.avi

when all that was actually wanted was: mpv --start=1:20 --end=1:30 --loop-file 3 file1.avi file2.avi

Surely this cannot possibly be correct and the failure of loop-file to pay attention to --start and --end must be a bug. It should be noted that: mpv --speed=2 --loop-file=3 --reset-on-next-file=all file1.avi file2.avi
behaves exactly as any reasonable person would expect allbeit with the --reset-on-next-file=all option. So options such as --speed are okay with --loop-file but --start and --end are not. I haven't tried --length.

Log file

I'm not sure if a log file will be of any use but I have attached one anyway.
output.txt

Sample files

The problem exists with any video so I haven't attached sample files.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the command using --loop-file, --start, --end, and --reset-on-next-file, then compare the behavior with the attached output.txt log. Trace the handling of these options across repeated file playback and verify that each loop honors the requested start and end positions for both files.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.