ropensci / av

Working with Video in R
https://docs.ropensci.org/av
Other
92 stars 10 forks source link

extract mono signal from stereo #46

Closed jwijffels closed 1 year ago

jwijffels commented 1 year ago

Hello Jeroen.

I have some audio files which are recorded in stereo. It has 2 channels where 2 persons are talking to one another and would like to transcribe it using the audio.whisper R package (https://github.com/bnosac/audio.whisper) which I was tweaking a bit lately.

I thought it would be possible to split the audio files into 2 mono files using av_audio_convert with channel = 1/2. When I do the following, that does not seem to happen. Is there another way using the av package to extract the different channels?

library(av)
library(curl)
curl_download(url = "http://www.aoakley.com/articles/stereo-test.mp3", destfile = "stereo.mp3")
av_media_info("stereo.mp3")
av_audio_convert(audio = "stereo.mp3", output = "channel1.mp3", channels = 1)
jeroen commented 1 year ago

Mmm it's been a while but I don't think that we have this. Setting channels = 1 combines the two audio channels into a single mono channel in the output. I'm not sure if there is an easy way to extract a single channel.

jwijffels commented 1 year ago

That's what I observed as well. I was a bit lost when I looked into sync_audio_stream at https://github.com/ropensci/av/blob/cda646a6562e1f44c957414087fccf3ce0d41f40/src/video.c#L387 to see if I could easily add it. Never mind, will try to look for another solution to handle this. Thanks for the quick feedback.