Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add audio support for playing video files #69

Open
dkbast opened this issue Dec 17, 2021 · 5 comments
Open

add audio support for playing video files #69

dkbast opened this issue Dec 17, 2021 · 5 comments

Comments

@dkbast
Copy link

dkbast commented Dec 17, 2021

  • it would be awesome to have the option to play the audio as well,
  • consideration: maybe only play audio when enabled with a flag
@hzeller
Copy link
Owner

hzeller commented Dec 25, 2021

Adding audio will open a whole can of worms as it might be hard to have an implementation that works on Linux (and the various flavors from simple ALSA to jack etc) and MacOS.
If someone knows a platform independent way to implement this, a pull request is greatly appreciated.

@dkbast
Copy link
Author

dkbast commented Apr 7, 2022

I was just going over this again and did a little bit of research - apparently there is an audio library which works on most platforms called "sox": https://sourceforge.net/p/sox/code/ci/master/tree/
Since I haven't been working with C/C++ in about 15 years I don't think I'm going to be able to solve this on my own, but I would be open & interested in pairing anytime you like.

Update: Maybe it would be easier to add terminal image protocol support to mpv which is a mediaplayer that can also output to the terminal: mpv-player/mpv#9605

@ericonr
Copy link

ericonr commented Jun 6, 2022

OpenAL or Portaudio might be options, I believe. If I have the time, I might try to look into this.

@RGBCube
Copy link

RGBCube commented Nov 22, 2023

PulseAudio for Linux would work, since most people are either using that or PipeWire which implements compatibility layers for Pulse and Alsa.

MacOS is easy since it has a single Audio API. There must be a library for C++ that implements all this, don't know any names since I'm not that familiar with the C++ ecosystem.

@VSuryaPrashanth
Copy link

VSuryaPrashanth commented Nov 26, 2023

It might not help but I have found a simple workaround,
In MacOS we have a terminal command afplay which can be used to play audio headless so we simply run both the commands in parallel. and to cancel them simultaneously we can trap the ctr+c and manually pkill them.

#!/bin/zsh
trap '' INT
player () (
   afplay $@ & timg $@
)
player $@
pkill timg
pkill afplay

instead of afplay we can use any other terminal headless audio player as well and if it has output then simply we can command $@ >/dev/null 2>/dev/null and ofcourse we have to assign a proper pid and all.
This is obviously a hack and gives no regards to the video-audio sync. but if you only want to have a quick view then this might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants