PyAV
PyAV copied to clipboard
Let user specified input audio codec and not relay on the default one
This PR relates to this #702 issue I posted earlier. This let user to specify input audio codec to be used instead of relaying on FFMPEG default one. Default codec is PCM_S16LE and in one scenario I needed to specify PCM_S32LE instead.
Some questions still on my head related to this:
- I only added PCM codecs. Is this okay? I think in the future if someone needs more they can be added quite easily.
- Anything to improve here? I'd be happy to modify this PR if needed.
With this change av.open can for example be called with
import av
av.open('alsa_device_name', format='alsa', audio_codec='PCM_S32LE')
Could we have some unit tests for this please?
Also the docstring should clarify what the usecase for this is: AFAICT this only makes sense for reading from audio devices (ALSA + pulse).
@jlaine do you think it would make sense to add documentation or something to list the supported codecs? I added a simple test but was thinking could I somehow test the default codec somehow when the audio_codec is not given. I couldn't find tests that open any alsa devices.
I'm closing this because this PR needs to be redone. It has merge conflicts and uses an old code style, (we prefer double quotes now).
I don't know if jlaine would agree with me but I think av.open("alsa_device_name", format="alsa:pcm_s32le") would be a better interface, (the parsing would be implemented in PyAV). I would think along these lines if you were to redo this.
For me, this is a very low priority feature. It's probably a low priority for jlaine too. I don't know anyone else who needs this. I wouldn't it if it were to be implemented, but it would need to be done in another PR.
Hello @WyattBlue. Thanks for commenting on this one. I don't really need this feature anymore so I don't see myself working on this PR again, also because the process has been quite slow I always forgot what I did last time. So this can be closed and the issue I opened also be closed. Maybe someone else who also needs this can find this and continue the work. Thanks for you time!