ffmpeg default audio codec instead of specifying it with acodec option - audio

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.

Related

ffmpeg Unsupported codec adpcm_ima_wav when i want sending in RTP

when i want encode a wav file and send it with rtp in ffmpeg i receive an error that say "Unsupported codec adpcm_ima_wav" but i can encode this file with adpcm_ima_wav and save this file but i can not send with rtp in ffmpeg.
ffmpeg -hide_banner -y -re -thread_queue_size 4 -i audio -acodec adpcm_ima_wav -sdp_file test.sdp -f rtp "rtp://127.0.0.1:2222"
below show this error:
Input #0, wav, from 'audio':
Metadata:
encoded_by : Pro Tools
originator_reference: !jtMVHCThOfaaaGk
date : 2010-09-14
creation_time : 08:04:58
time_reference : 0
Duration: 00:00:30.03, bitrate: 2304 kb/s
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s24le (native) -> adpcm_ima_wav (native))
Press [q] to stop, [?] for help
[rtp # 0x55867efcd380] Unsupported codec adpcm_ima_wav
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Error initializing output stream 0:0 --
Conversion failed!
ffmpeg Support decode and encode adpcm_ima_wav but When you want to convert any codec to adpcm_ima_wav,chunk is important for you so you need to pay attentions to calculation of chunk. I understood that i forgot calculation chunk of That voice i want to convert.

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

Multichannel AAC mp4 encoding using libav (avconv) or ffmpeg

I am trying to create a four-channel mp4 file with AAC encoding for ambisonics use. I am trying to encode a 4-channel first-order ambisonic wav file into AAC like so:
avconv -i four_channel_input.wav -c:a libfaac -ac 4 four_channel_output.mp4
This gives me the error
[libfaac # 0x7f938885a000] Specified channel_layout is not supported
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Removing the -ac 4 option gives me a 5 channel file
Duration: 00:01:21.09, start: 0.021333, bitrate: 218 kb/s
Stream #0:0(und): Audio: aac (LC) [mp4a / 0x6134706D]
48000 Hz, 5.0, fltp, 215 kb/s (default)
with a blank first channel, which is obviously suboptimal. In order to create compressed ambisonics files, should I be using a separate format like AmbiX (even though I believe this is uncompressed)?
With ffmpeg, you can run
ffmpeg -i input.wav -c:a aac -ac 4 -channel_layout 4.0 four_channel_output.mp4

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

RTMP: Is there such a linux command line tool?

I have looked everywhere to find a linux utility that will allow me to download rtmp streams. Not flv video but MP3 streams. The location of the streams I want to download are in this format.
rtmp://live.site.com/loc/45/std_fc74a6b7f79c70a5f60.mp3
Anyone know of such a command line tool? Or even anything close to what I am asking for?
I do not want full software applications and it would be great if it worked on Linux via Shell or something.
Thanks all
One of the following should do, if you have mplayer or vlc compiled with RTMP access.
mplayer -dumpstream rtmp://live.site.com/loc/45/std_fc74a6b7f79c70a5f60.mp3
This will generate a ./stream.dump.
vlc -I dummy rtmp://live.site.com/loc/45/std_fc74a6b7f79c70a5f60.mp3 \
--sout file/ts:output.mpg vlc://quit
This will generate a ./output.mpg. You'll have to demux it to extract just the audio stream out.
This question is old but this can help to another users with this doubt.
To download directly, without any conversion, there is two options (the author of both programs is the same and the behavior is the same):
RTMPDump. Example: rtmpdump -r "rtmp://host.com/dir/file.flv" -o filename.flv
flvstreamer. Example: flvstreamer -r "rtmp://od.flash.plus.es/ondemand/14314/plus/plustv/PO770632.flv" -o salida.flv
And if you want download and convert the video at same time, the best way is use ffmpeg:
ffmpeg -i rtmp://server/live/streamName -acodec copy -vcodec copy dump.mp4
I think the landscape has changed a bit since the time of some of the previous answers. At least according to the rtmp wikipedia page. It would appear that the rtmp protocol specification is open for public use. To that end you can use 2 tools to accomplish what the original poster was asking, rtmpdump and ffmpeg. Here's what I did to download a rtmp stream that was sending an audio podcast.
step #1 - download the stream
I used the tool rtmpdump to accomplish this. Like so:
% rtmpdump -r rtmp://url/to/some/file.mp3 -o /path/to/file.flv
RTMPDump v2.3
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
INFO: Connected...
Starting download at: 0.000 kB
28358.553 kB / 3561.61 sec
Download complete
step #2 - convert the flv file to mp3
OK, so now you've got a local copy of the stream, file.flv. You can use ffmpeg to interrogate the file further and also to extract just the audio portion.
% ffmpeg -i file.flv
....
[flv # 0x25f6670]max_analyze_duration reached
[flv # 0x25f6670]Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'file.flv':
Duration: 00:59:21.61, start: 0.000000, bitrate: 64 kb/s
Stream #0.0: Audio: mp3, 44100 Hz, 1 channels, s16, 64 kb/s
From the above output we can see that the file.flv contains a single stream, just audio, and it's in mp3 format, and it's a single channel. To extract it to a proper mp3 file you can use ffmpeg again:
% ffmpeg -i file.flv -vn -acodec copy file.mp3
....
[flv # 0x22a6670]max_analyze_duration reached
[flv # 0x22a6670]Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'file.flv':
Duration: 00:59:21.61, start: 0.000000, bitrate: 64 kb/s
Stream #0.0: Audio: mp3, 44100 Hz, 1 channels, s16, 64 kb/s
Output #0, mp3, to 'file.mp3':
Metadata:
TSSE : Lavf52.64.2
Stream #0.0: Audio: libmp3lame, 44100 Hz, 1 channels, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
size= 27826kB time=3561.66 bitrate= 64.0kbits/s
video:0kB audio:27826kB global headers:0kB muxing overhead 0.000116%
The above command will copy the audio stream into a file, file.mp3. You could also have extracted it to a wav file like so:
ffmpeg -i file.flv -vn -acodec pcm_s16le -ar 44100 -ac 2 file.wav
This page was useful in determining how to convert the flv file to other formats.

Resources