1

From the command line, I'd like to play a audio clip, or random subset of a song, eg, seconds 5 - 10. This does not seem to be a feature of paplay or mpg123, the two programs I've been using.

ffmpeg allos me to trim a file (eg, ffmpeg -i file.mkv -ss 20 -to 40 -c copy file-2.mkv), but I'd like to avoid creating a new file. Piping the above does not seem to work, though I may be doing it wrong.

How can I do this?

1

This approach works fine for me. Use force format option -f and select wave, write to stdout then pipe to e.g. aplay like so:

ffmpeg -i input -ss 20 -to 40 -f wav - | aplay
  • 1
    Or if you have ffplay: ffplay -ss 20 -t 20 input – Gyan Apr 19 at 10:50
  • Works. Thanks. Is there a way to get ffplay or aplay to exit when the clip finishes? Right now it continues playing. Would prefer not to have to kill the process. – zadrozny Apr 19 at 16:39
  • ffplay -ss 20 -t 20 input -autoexit – Gyan Apr 19 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.