The first thing I tried was using VLC:

/Applications/VLC.app/Contents/MacOS/VLC '{$movpath}' --start-time='{$ts}' --stop-time='{$te}' --no-video rate='0.5' 2> /dev/null;

However, the player takes 10 seconds to load every time the command is executed, and this is too slow for my purpose as I am calling this command with shell_exec() from a PHP command line script.

I read: How to play audio files from command line, and tried afplay, but it doesn't recognise .mkv files.

Ideally I should not need pre-processing eg. should not need to use ffmpeg to extract the audio from the .mkv file first, as I have tried this, and it also takes too long for my purpose.

In addition, I do need to adjust the speed of the playback as well, as I need to play the file at various speeds (eg. 1x, 0.5x and 0.25x).

How might I achieve my aim?

  • How many mkv files are we looking at, how often do they change?
    – nohillside
    Commented Nov 24, 2023 at 6:02
  • @nohillside it's the same file for maybe every 2-3 days Commented Nov 24, 2023 at 9:38
  • Would preprocessing the file (separating the audio track and maybe create different versions by speed) work?
    – nohillside
    Commented Nov 24, 2023 at 9:46
  • hmm I have a few thousand of segments per file that must be played.. will preprocessing be too long? Commented Nov 24, 2023 at 10:02
  • Why not just try, without segments? If it starts up quickly then, all should be good.
    – nohillside
    Commented Nov 24, 2023 at 10:14


You must log in to answer this question.

Browse other questions tagged .