python-mpv icon indicating copy to clipboard operation
python-mpv copied to clipboard

Unable to set Gapless Playback option

Open pauljeffrussell opened this issue 1 year ago • 2 comments
trafficstars

I've got a simple python script that's playing a list of mp3s from a command line. No GUI. When I create the player, I set gapless_audio = 'yes' as follows.

player = mpv.MPV(gapless_audio='yes')
print( f"gapless-audio: {player.option_info('gapless-audio')}")

This outputs the text below which suggest gapless-audio was never set by my program. I've also confirmed audibly that gapless playback isn't working.

gapless-audio: {'name': 'gapless-audio', 'type': 'Choice', 'set-from-commandline': False, 'set-locally': False, 'default-value': 'weak', 'choices': ['no', 'yes', 'weak']}

I've tried setting it using the following methods as well and they all produce the same result. No gapless-playback

player.gapless_audio = 'yes' 
player.command('set', 'gapless-audio', 'yes')

It's entirely possible, I'm just doing this wrong, but I can't seem to find any examples that suggest an alternative way to enable gapless playback. Wicked cool library all the same.

pauljeffrussell avatar May 25 '24 17:05 pauljeffrussell

In case it helps here's the version info I get for mpv

mpv 0.35.1 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
FFmpeg library versions:
   libavutil       57.28.100
   libavcodec      59.37.100
   libavformat     59.27.100
   libswscale      6.7.100
   libavfilter     8.44.100
   libswresample   4.7.100
FFmpeg version: 5.1.4-0+rpt3+deb12u1

pauljeffrussell avatar May 25 '24 22:05 pauljeffrussell

I just tested this, and I can confirm that at least setting the option works as advertised.

#!/usr/bin/env python3

import mpv

player = mpv.MPV()
print(player.gapless_audio)

player = mpv.MPV(gapless_audio=True)
print(player.gapless_audio)

player = mpv.MPV()
player.gapless_audio = True
print(player.gapless_audio)

Output:

~/p/python-mpv <3 python test.py
weak
True
True

The mpv manpage mentions that apparently mpv's gapless playback implementation isn't very good, maybe that's why it's not working for you?

jaseg avatar May 29 '24 12:05 jaseg

@pauljeffrussell Did you figure out what went wrong? Since I couldn't reproduce your issue at all, I'm closing it for now. Please feel free to re-open it, or to open another issue if you're still having trouble :)

jaseg avatar Jul 19 '24 11:07 jaseg