arecord: set_params:1405: Unable to install hw params: - linux

I'm trying to record audio from a microphone but I got below error. I tried plughw:0,4 to get automatic sample format conversion and also given manually as arecord -D hw:0,4 -d 5 -f S32_LE -r 48000 test.wav, but I get same error.
When I run alsamixer I get this error as ALSA lib ../../alsa-plugins-1.2.1/pulse/pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused cannot open mixer: Connection refused. When I manually start pulseaudio --start alsamixer runs, but when I do some microphone related operation alsamixer repeats same error again.
arecord:
Available formats:
- S16_LE
- S24_LE
- S32_LE
Recording WAVE 'test.wav' : Signed 32 bit Little Endian, Rate 48000 Hz, Mono
arecord: set_params:1405: Unable to install hw params:
ACCESS: RW_INTERLEAVED
FORMAT: S32_LE
SUBFORMAT: STD
SAMPLE_BITS: 32
FRAME_BITS: 32
CHANNELS: 1
RATE: 48000
PERIOD_TIME: 125000
PERIOD_SIZE: 6000
PERIOD_BYTES: 24000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 4000
BUFFER_BYTES: 96000
TICK_TIME: 0

Related

Can I force arecord to record with a certain sampling rate if my sound card allows it?

I am using arecord to record audio using a USB microphone that allows recording up to 384k sampling rate. With Audacity I can easily record with other lower sampling rates (48k, 44.1k ..) but when I use:
arecord -vD hw:4,0 -f S16_LE -d 120 -r 48000 -c 1 sample.wav
It displays a warning message:
Warning: rate is not accurate (requested = 48000Hz, got = 384000Hz)
And records with 384000Hz.
I can't get to fix this.

ffmpeg default audio codec instead of specifying it with acodec option

In raspberry pi I've following i2s microphone breakout board and use it like the guide suggested. When I try record audio from it using ffmpeg to the file with ffmpeg -f alsa -i dmic_sv out.wav command. I'll receive following error
[alsa # 0x22e21c0] cannot set sample format 0x10000 2 (Invalid argument)
dmic_sv: Input/output error
When I specify the used codec explicitly with -acodec it works fine:
ffmpeg -f alsa -acodec pcm_s32le -i dmic_sv out.wav
And from the output ffmpeg will reencode to pcm_s16le
Input #0, alsa, from 'dmic_sv':
Duration: N/A, start: 1597597938.887969, bitrate: 3072 kb/s
Stream #0:0: Audio: pcm_s32le, 48000 Hz, stereo, s32, 3072 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s32le (native) -> pcm_s16le (native))
How I can tell ffmpeg to use signed 32-bit little endian by default without specifying it explicitly? And where ffmpeg gets this default and can I configure it somehow?
I figured this one out myself by reading ffmpeg source code. It seems when codec is not specified and alsa device is used. FFmpeg will default to pcm 16-bit samples instead. Code to set the default here and the default macro here.

FFmpeg - how to set output sample_size

Trying to create a simple command line player for .dsf (DSD audio) files, and output to an alsa device that supports up to 24-bit 192 kHz sample rate. The following command almost works and it does play the track. Examining the bold text below, the dsf input file is converted to 24-bit/192 kHz, but the output is then truncated to 16-bit 192 kHz (pcm_s16le i.e, 16 bit little endian).
ffmpeg -i '01 - Sweet Georgia Brown.dsf' -f alsa hw:0,0
After displaying the ffmpeg banner and song metadata (tags), here is the result, bold is my emphasis:
Duration: 00:05:14.83, start: 0.000000, bitrate: 9234 kb/s
Stream #0:0: Audio: flac, 192000 Hz, stereo, s32 (24 bit)
Stream mapping:
Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, alsa, to 'hw:0,0':
Since I can play this and many other tracks at full resolution using another player (foobar2000) it seems there might be an option in the encoder which is part of FFmpeg: Lavf57.83.100 I can find no information in any of the FFmpeg documentation that helps. Tried finding options in FFplay and even guessing using other FFmpeg options like this example.
ffmpeg -sample_fmt s24 -i '01 - Sweet Georgia Brown.dsf' -f alsa hw:0,0 ***** same results.
I'm stuck. Any suggestions?
Environment: Linux Mint 19.2, 64-bit, ASUS Xonar STXii sound card.
Each output format or device has a default encoder registered for each media type it accepts. ALSA accepts audio and its default encoder is 16-bit signed PCM.
You can change the encoder by specifying one.
ffmpeg -i '01 - Sweet Georgia Brown.dsf' -c:a pcm_s24le -f alsa hw:0,0

ffmpeg stdout wrong timecode out

If I run this command line
ffmpeg -ss 0 -t 3600 -i file1.mp3 -ss 0 -t 20 -i file2.mp3 -filter_complex "[0][1]concat=n=2:v=0:a=1" -ac 2 -f wav - > test.wav
I'm basically putting the stout inside a container wav (test.wav) but the duration is always wrong. The output file should be 01:00:20.00 but if I play it on VLC (or any player audio) it shows 06:12:49.00 and even if I change the start_times, the durations and number of files, I still get that timecode out. The even weirder thing is that ffprobe shows the duration as it should be. Can somebody please help me on this?
UPDATE:
[wav # 0000000000cf3680] Ignoring maximum wav data size, file may be invalid
[wav # 0000000000cf3680] Estimating duration from bitrate, this may be inaccurate
Input #0, wav, from 'test.wav':
Metadata:
encoder : Lavf57.72.101
timecode : 01:00:20.00
Duration: 01:00:20.00, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s
That is what the ffprobe on the output shows..the duration is correct here but not on any audio player

convert MOV to mp4 using transcode

I want to convert a MOV from my Casio cam to mp4 using transcode. Why transcode? Because I also want to deshake the video in the same step.
When I use
ffmpeg -i in.MOV out.mp4
it works. When using
transcode -J stabilize -i in.MOV
or
transcode -J transform -i in.MOV -y ffmpeg -F mpeg4 -o out.mp4
I get hundreds of these errors:
[ffmpeg_audio] Error: avcodec_open2 failed
[adpcm_ima_wav # 0x1f7f180] Only 4-bit ADPCM IMA WAV files are supported
This looks to me as if transcode uses ffmpeg internally.
I could use ffmpeg to make it mp4 first and then use transcode to stabilize the video, but then it would be re-encoded twice which I would like to avoid.
This is what mplayer says about my MOV file:
MPlayer2 2.0-701-gd4c5b7f-2ubuntu2 (C) 2000-2012 MPlayer Team
Cannot open file '/home/koem/.mplayer/input.conf': No such file or directory
Failed to open /home/koem/.mplayer/input.conf.
Cannot open file '/etc/mplayer/input.conf': No such file or directory
Failed to open /etc/mplayer/input.conf.
Playing 1-original.MOV.
Detected file format: QuickTime / MOV (libavformat)
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (adpcm_ima_wav), -aid 0, -alang eng
Clip info:
major_brand: qt
minor_version: 537921536
compatible_brands: qt caqv
creation_time: 2017-01-02 23:31:38
Load subtitles in .
Failed to open VDPAU backend libvdpau_i965.so: cannot open shared object file: No such file or directory
[vdpau] Error when calling vdp_device_create_x11: 1
[ass] auto-open
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [libavcodec]
Selected audio codec: ADPCM IMA WAV [libavcodec]
AUDIO: 44100 Hz, 2 ch, s16le, 352.8 kbit/25.00% (ratio: 44100->176400)
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Starting playback...
VIDEO: 1920x1080 29.970 fps 15940.0 kbps (1992.5 kB/s)
VO: [xv] 1920x1080 => 1920x1080 Planar YV12
Colorspace details not fully supported by selected vo.
A: 1.1 V: 1.1 A-V: -0.000 ct: 0.000 0/ 0 16% 8% 1.6% 0 0
Exiting... (Quit)
How can I make it work with transcode without using ffmpeg first?
FFmpeg has a deshake as well as a stabilization filter. Get a new binary if yours doesn't.
To continue with your existing binaries, run
ffmpeg -i in.MOV -vcodec copy out.mp4
This will skip video re-encoding.

Resources