jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
531 stars 67 forks source link

Unable to set Gapless Playback option #279

Open pauljeffrussell opened 1 month ago

pauljeffrussell commented 1 month ago

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 commented 1 month ago

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
jaseg commented 1 month ago

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?