Audio sample format in alsa?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Audio sample format in alsa?

Simon
I'm trying to grab audio from a USB device that's managed by alsa. I find
that if I configure pulse to use this device, then I can grab successfully
with:

ffmpeg -f alsa -i pulse audiotest.mp3

But I need to refer to the hardware device directly, and I'm failing to do
that.

I have these cards:

$ cat /proc/asound/cards
 0 [HDMI           ]: HDA-Intel - HDA Intel HDMI
                      HDA Intel HDMI at 0xf7e34000 irq 44
 1 [UA3FX          ]: USB-Audio - UA-3FX
                      EDIROL UA-3FX at usb-0000:00:14.0-3, full speed
 2 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7e30000 irq 43

and these devices:

$ cat /proc/asound/devices
  1:        : sequencer
  2: [ 1]   : control
  3: [ 1- 0]: digital audio playback
  4: [ 1- 0]: digital audio capture
  5: [ 1- 1]: digital audio playback
  6: [ 0]   : control
  7: [ 0- 3]: digital audio playback
  8: [ 0- 7]: digital audio playback
  9: [ 0- 8]: digital audio playback
 10: [ 0- 9]: digital audio playback
 11: [ 0- 0]: hardware dependent
 12: [ 2]   : control
 13: [ 2- 0]: digital audio playback
 14: [ 2- 0]: digital audio capture
 15: [ 2- 0]: hardware dependent
 33:        : timer

But when I try:

$ ffmpeg -f alsa -i hw:1,0 audiotest.mp3

I get:
[alsa @ 0x55ac7254fd80] cannot set sample format 0x10000 2 (Invalid
argument)
hw:1,0: Input/output error

But I'm not sure where to start with configuring this sample format. Can
someone point me in the right direction? I didn't find much in the alsa
section of the online manual.

Cheers,
Simon
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Audio sample format in alsa?

Nicolas George
Simon Roberts (12020-06-30):
> I get:
> [alsa @ 0x55ac7254fd80] cannot set sample format 0x10000 2 (Invalid
> argument)
> hw:1,0: Input/output error

This message could be made better. This is s16le, which should be the
most common format, but we never know.

> But I'm not sure where to start with configuring this sample format. Can
> someone point me in the right direction? I didn't find much in the alsa
> section of the online manual.

ALSA can be tricky. I suggest you try first to use the card with aplay,
fiddling with -f to find what format it supports. And then, when it
works, transpose this into ffmpeg options.

Or you could let ALSA make automatic conversions by using plughw instead
of hw.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Audio sample format in alsa?

Simon
On Wed, Jul 1, 2020 at 5:00 AM Nicolas George <[hidden email]> wrote:

> Simon Roberts (12020-06-30):
> > I get:
> > [alsa @ 0x55ac7254fd80] cannot set sample format 0x10000 2 (Invalid
> > argument)
> > hw:1,0: Input/output error
>
> This message could be made better. This is s16le, which should be the
> most common format, but we never know.
>

Interesting. Yes, when I (as you suggested below) use the plughw, it does
indeed record in 16le, but even setting this manually, still rejects. Ah
well.


> > But I'm not sure where to start with configuring this sample format. Can
> > someone point me in the right direction? I didn't find much in the alsa
> > section of the online manual.
>
> ALSA can be tricky. I suggest you try first to use the card with aplay,
> fiddling with -f to find what format it supports. And then, when it
> works, transpose this into ffmpeg options.
>
> Or you could let ALSA make automatic conversions by using plughw instead
> of hw.
>

Magic! plughw:1,0 works a treat. Are there any limitations, or caveats,
that I should be aware of? Is this a risk or tradeoff of any sort? I note
that the recording seems to be 16le, so I have no immediate evidence of it
being in any way less than optimal, but since I'm afraid I had never come
across this, I don't know what I don't know.

Many thanks!
Simon
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Audio sample format in alsa?

Nicolas George
Simon Roberts (12020-07-01):
> Magic! plughw:1,0 works a treat. Are there any limitations, or caveats,
> that I should be aware of? Is this a risk or tradeoff of any sort? I note
> that the recording seems to be 16le, so I have no immediate evidence of it
> being in any way less than optimal, but since I'm afraid I had never come
> across this, I don't know what I don't know.

With hw, you are talking directly with the sound device, you have to
provide parameters that it accepts, exactly: correct format, correct
number of channels, correct sample rate.

With plughw, you tell ALSA to insert the "plug" plugin before the actual
device, to do automatic conversion. Therefore, it accepts any format,
number of channels, sample rate, but there is a conversion happening and
you do not know what it is.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Audio sample format in alsa?

Simon
On Wed, Jul 1, 2020 at 12:22 PM Nicolas George <[hidden email]> wrote:

> Simon Roberts (12020-07-01):
> > Magic! plughw:1,0 works a treat. Are there any limitations, or caveats,
> > that I should be aware of? Is this a risk or tradeoff of any sort? I note
> > that the recording seems to be 16le, so I have no immediate evidence of
> it
> > being in any way less than optimal, but since I'm afraid I had never come
> > across this, I don't know what I don't know.
>
> With hw, you are talking directly with the sound device, you have to
> provide parameters that it accepts, exactly: correct format, correct
> number of channels, correct sample rate.
>
> With plughw, you tell ALSA to insert the "plug" plugin before the actual
> device, to do automatic conversion. Therefore, it accepts any format,
> number of channels, sample rate, but there is a conversion happening and
> you do not know what it is.
>
>
> Ah, so it will be (a little?) less efficient, right, and it could
conceivably lose some qualtiy.

I guess I should persevere with trying to work out how to use hw: directly
then.

Thanks that's good to know.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".