mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.46k stars 2.91k forks source link

Looping with Start #13860

Open ccx004B opened 7 months ago

ccx004B commented 7 months ago

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

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.

ccx004B commented 7 months ago

I've just found something else which suggests this is a bug. As I, and others, have said the command mpv --loop-file=2 --start=1:0 file1.avi file2.avi ignores the --start when playing file1 the second and subsequent times. However, the same command but with the addition of --end behaves differently. For example, mpv --loop-file=2 --start=1:0 --end=1:20 file1.avi file2.avi will still ignore the --start when it plays the files the second and third time, it will honour the --end option each time it plays the files. Similarly it will happily honour a --length option if that was included but ignore the --start. One odd thing is that the command: mpv --loop-file=2 --start=1:0 -length=10 file1.avi file2.avi will start each file the first time it is played at 1:0 and end at 1:10 but the second and subsequent times it will start at 0:0 but it will still end at 1:10. In other words for the purpose of stopping, it will use the start value but not for the purpose of starting on each play.

I'm not sure if this is fixable but given that --length and --end both work as expected and the start value is used to calcuate the end value when --start is given it is hard to see why --start is not expected to set the starting value for every time the files are played.

ccx004B commented 5 months ago

Is this being ignored for a reason? This is obviously a bug in MPV and, although I haven't tried it, I bet it affects Linux and MAC versions as well. It is a bug in simple usage so it is I find it surprising that it is just ignored. Others have reported this and been given all sorts of bizarre advice such as use ab-loop. If MPV provides options such as start and loop they should work and not only that, they should behave in a sensible manner.

llyyr commented 5 months ago

You should be using --loop-playlist, as loop-file is only intended to work with one file.

Though there was a bug, which will be fixed by #14289, so you could use the --{ --} syntax for specifying --loop-file for each file in a playlist.

Is this being ignored for a reason?

No, because people work on things that they care about. This is a niche bug in a not-so-common workflow.

ccx004B commented 5 months ago

Hi,I have never seen this explanation before. Is this in the documentation anywhere? In any event loop-playlist does something different compared to loop-file. What’s more, if what you say is true why does —length and —end behave in a way that most people would think is correct. Similarly, using —{ is just a work around to get round the bug in mpv. In any event, thanks for the reply.Best wishes.....Colin(Sent from my iPhone)On 4 Jun 2024, at 04:30, llyyr @.***> wrote: You should be using --loop-playlist, as loop-file is only intended to work with one file. Though there was a bug, which will be fixed by #14289, so you could use the --{ --} syntax for specifying --loop-file for each file in a playlist.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

llyyr commented 5 months ago

See https://mpv.io/manual/master/#options-loop-file

Also see https://mpv.io/manual/master/#options-start

--start does not change the starting frame, it simply seeks to that time

guidocella commented 5 months ago

I think it's fine to use ab-loop for looping between timestamps as that is what it's for. Preserving --loop-file=N and --ab-loop-count=N between files without adding them to --reset-on-next-file however is a valid request as there have already been multiple issues with users confused by this behavior.

ccx004B commented 5 months ago

Hi,

Thanks for your reply and also to Guido Cella for his reply.

That is not how I read the document you have linked to. “Loop a single file N times” as opposed to what it says for playlists. E.g “Loops playback N times”. Using file1,file2,file3 as an example. I read that as meaning loop each single file N times for –loop-file. E.g play file1, file1, .. , file2, file2, file2 etc. Whereas it would be file1,file2,file3,file1,file2,file3,… with –start, --length and –end behaving appropriately for –loop-playlist. However, I accept your interpretation even though it is pretty limiting.

Still even if it is supposed to only work for a single file as you have indicated, that doesn’t explain why –end and –length both work correctly for multiple files and it even, in the case of --length, takes into account the start value given by –start but ignores it for the starting value on the second and subsequent play. E.g.

mpv –loop=3 –start=10 –length=10 file1 file2 file3

Will play file1 from 10 seconds and stop at 20 seconds on the first play but on the second and third play it will start at 0 but still end at 20 seconds. In other words it is ignoring the start value for –start but using it to calculate the position to stop at and actually ignoring the actual start position on the second and third plays. However, file2 will also start at 10 seconds and end at 20 but it will only play once. The same goes for file3. So –loop is ignored after the first file and –start is ignored on the second and subsequent plays.

All of this just screams bug to me.

On the topic of –ab-loop: That also seems odd. A command such as:

            mpv –ab-loop-a=10 –ab-loop-b=20 file1

will not behave as might be expected by some although, personally, I think it does what is intended. That command will play the file starting at 0 and play until it gets to 20 then it will skip back to 10 and play that 10 to 20 second section forever. However, if the –ab-loop-count is used to set the number of times it will play, after the last iteration (which will be 1 more than expected) it will continue playing to the end of the file. To get the desired behaviour (in my case at least) you would need to do something like:

            mpv –start=10 –end=20 –ab-loop-a=10 –ab-loop-b=20 –ab-loop-count=5 file1

to play it 6 times. Not exactly user friendly! What is more if you do something like:

            mpv –start=10 –end=20 –ab-loop-a=10 –ab-loop-b=20 –ab-loop-count=5 file1 file2 file3 …

the first file will play the section marked with –ab-loop values 6 times but the second and subsequent files will only be played once. Adding –loop will get even more bizarre outcomes.

Essentially, mpv can’t play one or more sections from media files in any meaningful or reliable way and that seems to me to be by design. What prompted this design is a mystery to me but it is not my business. I’ll just have to work round it in my code which I can do with the exception of –loop=inf.

I think the issue can be closed.

Best wishes…..

Colin Bruce

From: llyyr @.> Sent: 04 June 2024 16:35 To: mpv-player/mpv @.> Cc: ccx004B @.>; Author @.> Subject: Re: [mpv-player/mpv] Looping with Start (Issue #13860)

See https://mpv.io/manual/master/#options-loop-file

Also see https://mpv.io/manual/master/#options-start

--start does not change the starting frame, it simply seeks to that time

— Reply to this email directly, https://github.com/mpv-player/mpv/issues/13860#issuecomment-2147839732 view it on GitHub, or https://github.com/notifications/unsubscribe-auth/AVBL56JILXS54TF42LYMRD3ZFXNDDAVCNFSM6AAAAABGBP5ZC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHAZTSNZTGI unsubscribe. You are receiving this because you authored the thread. https://github.com/notifications/beacon/AVBL56MOAZ4C4PYNGGM5X4DZFXNDDA5CNFSM6AAAAABGBP5ZC2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUAAVXPI.gif Message ID: < @.> @.>

-- This email has been checked for viruses by AVG antivirus software. www.avg.com

guidocella commented 5 months ago

--loop-file=N and --ab-loop-count=N with multiple files are fixed by https://github.com/mpv-player/mpv/pull/14302.

It would probably be more consistent to either make --loop-file respect --start or not respect --end and --length as you say. But playing before --ab-loop-a and past --ab-loop-b after --ab-loop-count reaches 0 makes sense and we shouldn't take this option away when what you want is achieved with --start and --end.

Also if you want to play segments of various file you may be better off using EDL.

ccx004B commented 5 months ago

Hi,

Yes, I agree it would be more consistent to do one of the two options you mentioned. My preference would be the first one but I have no idea how difficult that would be and obviously if this is ever done it would be up to whoever is doing the work to decide what is the best way to do it.

Thanks for the tip about EDL. I just tried a brief experiment and that might be very useful for my little application.

Thanks again….

Colin Bruce

From: Guido Cella @.> Sent: 05 June 2024 08:38 To: mpv-player/mpv @.> Cc: ccx004B @.>; Author @.> Subject: Re: [mpv-player/mpv] Looping with Start (Issue #13860)

--loop-file=N and --ab-loop-count=N with multiple files are fixed by #14302 https://github.com/mpv-player/mpv/pull/14302 .

It would probably be more consistent to either make --loop-file respect --start or not respect --end and --length as you say. But playing before --ab-loop-a and past --ab-loop-b after --ab-loop-count reaches 0 makes sense and we shouldn't take this option away when what you want is achieved with --start and --end.

Also if you want to play segments of various file you may be better off using EDL https://github.com/mpv-player/mpv/blob/master/DOCS/edl-mpv.rst .

— Reply to this email directly, view it on GitHub https://github.com/mpv-player/mpv/issues/13860#issuecomment-2149093988 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AVBL56LVCQQ4UELXEGEVTJ3ZF256NAVCNFSM6AAAAABGBP5ZC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBZGA4TGOJYHA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AVBL56NI42JAUWB7EROURGLZF256NA5CNFSM6AAAAABGBP5ZC2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUADCJGI.gif Message ID: @. @.> >

-- This email has been checked for viruses by AVG antivirus software. www.avg.com