[FFmpeg-user] Statics when record with ffmpeg

MrNice wxcvbn2006 at iol.ie
Mon Jul 13 11:37:42 CEST 2015


Great improvement...


I had a look on the other thread "Converting a cassette audio tape" and
I had the idea to try to use pulseaudio. I never did.

So I installed pulseaudio-libs-devel x86_64 then compile again  with

$ ./configure --enable-libpulse then $ ./make ffmpeg

Then

./ffmpeg -devices | grep -E "alsa|pulse"
ffmpeg version N-73517-g47d0773 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 5.1.1 (GCC) 20150618 (Red Hat 5.1.1-4)
  configuration: --enable-libpulse
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 47.100 / 56. 47.100
  libavformat    56. 40.100 / 56. 40.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 21.100 /  5. 21.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
 DE alsa            ALSA audio output
 DE pulse           Pulse audio output

pulseaudio and alsa are present.
then

$ pacmd list-sources
2 source(s) available.
    index: 0
	name: <alsa_output.pci-0000_00_14.2.analog-stereo.monitor>
	driver: <module-alsa-card.c>
	flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE
	priority: 1950
	volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100%
/ 0.00 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max rewind: 0 KiB
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 1837.33 ms
	monitor_of: 0
	card: 1 <alsa_card.pci-0000_00_14.2>
	module: 7
	properties:
		device.description = "Monitor of Built-in Audio Analog Stereo"
		device.class = "monitor"
		alsa.card = "0"
		alsa.card_name = "HDA ATI SB"
		alsa.long_card_name = "HDA ATI SB at 0xfe400000 irq 16"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:14.2"
		sysfs.path = "/devices/pci0000:00/0000:00:14.2/sound/card0"
		device.bus = "pci"
		device.vendor.id = "1002"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
		device.product.id = "4383"
		device.product.name = "SBx00 Azalia (Intel HDA)"
		device.form_factor = "internal"
		device.string = "0"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
  * index: 1
	name: <alsa_input.pci-0000_00_14.2.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9959
	volume: front-left: 6554 /  10% / -60.00 dB,   front-right: 6554 /  10%
/ -60.00 dB
	        balance 0.00
	base volume: 6554 /  10% / -60.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max rewind: 0 KiB
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 1837.33 ms
	card: 1 <alsa_card.pci-0000_00_14.2>
	module: 7
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC892 Analog"
		alsa.id = "ALC892 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA ATI SB"
		alsa.long_card_name = "HDA ATI SB at 0xfe400000 irq 16"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:14.2"
		sysfs.path = "/devices/pci0000:00/0000:00:14.2/sound/card0"
		device.bus = "pci"
		device.vendor.id = "1002"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
		device.product.id = "4383"
		device.product.name = "SBx00 Azalia (Intel HDA)"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "352768"
		device.buffering.fragment_size = "176384"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Built-in Audio Analog Stereo"
		alsa.mixer_name = "Realtek ALC892"
		alsa.components = "HDA:10ec0892,18497892,00100302"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-input-front-mic: Front Microphone (priority 8500, latency
offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-rear-mic: Rear Microphone (priority 8200, latency offset
0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-linein: Line In (priority 8100, latency offset 0 usec,
available: yes)
			properties:
				
	active port: <analog-input-linein>


then

$ ./ffmpeg -debug 1 -vn -f pulse -i 1 -ac 2 -channel_layout stereo -c:a
pcm_s16le /Store3/Test/pcm_`date +%m%d_%H%M`.wav
ffmpeg version N-73517-g47d0773 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 5.1.1 (GCC) 20150618 (Red Hat 5.1.1-4)
  configuration: --enable-libpulse
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 47.100 / 56. 47.100
  libavformat    56. 40.100 / 56. 40.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 21.100 /  5. 21.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
 matched as AVOption 'debug' with argument '1'.
Reading option '-vn' ... matched as option 'vn' (disable video) with
argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'pulse'.
Reading option '-i' ... matched as input file with argument '1'.
Reading option '-ac' ... matched as option 'ac' (set number of audio
channels) with argument '2'.
Reading option '-channel_layout' ... matched as option 'channel_layout'
(set channel layout) with argument 'stereo'.
Reading option '-c:a' ... matched as option 'c' (codec name) with
argument 'pcm_s16le'.
Reading option '/Store3/Test/pcm_0713_1019.wav' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Successfully parsed a group of options.
Parsing a group of options: input file 1.
Applying option vn (disable video) with argument 1.
Applying option f (force format) with argument pulse.
Successfully parsed a group of options.
Opening an input file: 1.
[pulse @ 0x30a0300] All info found
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, pulse, from '1':
  Duration: N/A, start: 1436779142.420430, bitrate: 1536 kb/s
    Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 48000 Hz, 2 channels,
s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: output file /Store3/Test/pcm_0713_1019.wav.
Applying option ac (set number of audio channels) with argument 2.
Applying option channel_layout (set channel layout) with argument stereo.
Applying option c:a (codec name) with argument pcm_s16le.
Successfully parsed a group of options.
Opening an output file: /Store3/Test/pcm_0713_1019.wav.
Successfully opened the file.
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x308bf40] Setting 'time_base' to value
'1/48000'
[graph 0 input from stream 0:0 @ 0x308bf40] Setting 'sample_rate' to
value '48000'
[graph 0 input from stream 0:0 @ 0x308bf40] Setting 'sample_fmt' to
value 's16'
[graph 0 input from stream 0:0 @ 0x308bf40] Setting 'channel_layout' to
value '0x3'
[graph 0 input from stream 0:0 @ 0x308bf40] tb:1/48000 samplefmt:s16
samplerate:48000 chlayout:0x3
[audio format for output stream 0:0 @ 0x30a01c0] Setting 'sample_fmts'
to value 's16'
[audio format for output stream 0:0 @ 0x30a01c0] Setting
'channel_layouts' to value '0x3'
[AVFilterGraph @ 0x308b400] query_formats: 4 queried, 9 merged, 0
already done, 0 delayed
Output #0, wav, to '/Store3/Test/pcm_0713_1019.wav':
  Metadata:
    ISFT            : Lavf56.40.100
    Stream #0:0, 0, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001),
48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc56.47.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
size=    3077kB time=00:00:16.40 bitrate=1536.1kbits/s
video:0kB audio:3077kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.002476%
Input file #0 (1):
  Input stream #0:0 (audio): 61 packets read (3150376 bytes); 61 frames
decoded (787594 samples);
  Total: 61 packets (3150376 bytes) demuxed
Output file #0 (/Store3/Test/pcm_0713_1019.wav):
  Output stream #0:0 (audio): 61 frames encoded (787594 samples); 61
packets muxed (3150376 bytes);
  Total: 61 packets (3150376 bytes) muxed
61 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x30ba7e0] Statistics: 4 seeks, 115 writeouts


And now the output audio file is perfect, not distortion, no static.

Now I have to learn pulseaudio commands, do you have a link?

The fact is there is an issue and a workaround: If it's work for me.
I'll test it now, I don't need to use alsa but if not I'll have to fix it.
In the other hand, maybe anyway you'd prefer to go further and fix it,
so I am here to help. I can say I'd prefer as well.
So let me know.

BTW, could you provide a link where I can understand how are pulseaudio
and alsa working together. I know there is jack and maybe more. I tried
to understand few time ago but the only thing I remember is a guy saying
something like: "Linux audio is a big mess"

Thanks



More information about the ffmpeg-user mailing list