Increase volume of one channel in 8channel .wav file ffmpeg - audio

I have 8-channel .wav file with sine wave in there. I would like to increase the volume of only 4th channel in this file. I don't know how to do it though.
ffmpeg -i input.wav -af "volume=1.5" output.wav
This will increase volume for all 8 channels. How can i apply it only to 1 channel (4th one) but still maintain the 8-channel .wav file?

Something like this should work: ffmpeg -i input.wav -af "pan=8c|c0=c0|c1=c1|c2=c2|c3=1.5*c3|c4=c4|c5=c5|c6=c6|c7=c7" output.wav

Related

Change audio format without changing audio from the command line

I have some audio recorded form an i2s mic at 16000hz with arecord. It sounds like it is down an octave so I want to change the file format to 32000hz. When I try to do this with sox it edits the audio, not just the format so it still sounds wrong.
This is the sox command I am using: sox in.wav -r 32000 out.wav What command should I use instead?
Looks like order matters in the command. The correct command is:
sox -r 32000 in.wav out.wav
If you want to change the audio rate, you can do it this way with ffmpeg:
ffmpeg -i input.wav -ar 32000 output.wav

ffmpeg exported file is broken

I am using using ffmpeg to trim and join several audio files. The ouput audio file can be played as a normal file, but when I open it in some C# codes, exceptions are always throwing, says "MP3 Header is missing". I am new to ffmpeg and I googled for many times but seems no one is encountering this problem.
Here is my ffmpeg command to trim an audio file:
ffmpeg -i input_1.mp3 -ss 00:00:00.000 -to 00:00:01.000 -acodec libmp3lame 1.mp3
(The input audio format can be mp3/wma/wav/m4a/aac)
And the following is for joining all the audio files:
ffmpeg -safe 0 -f concat -i list.txt -acodec libmp3lame join.mp3
The list.txt contents:
file C:\\1.mp3
file C:\\2.mp3
file C:\\3.mp3
Problem soved! Thanks to Gyan's comment under my question.
The main point:
Make sure all converted files have same sampling rate and channel count i.e. add -ar 44100 -ac 2
The above parameters did solve my problem.

Use FFMPEG to export audios with gaps filled

I have a MKV file with gaps in the audio. That is, there are gaps in the MKV audio track timestamps. According to "ffmpeg", the AC3 audio length is 802 seconds, but when exporting the audio to WAV, the resulting file length is 801'53 seconds. That is, the "exported" audio is shorter.
Triaging the issue with
ffmpeg -i INPUT.mkv -af ashowinfo -map 0:2 -y -frames:a XXXX -f alaw /dev/null
I can confirm that the length difference is consistent with gaps in the timestamps of the original audio frames. There are a handful of missing audio frames. I guess those are replaced by silence in the player.
The command I use to export the audio is:
ffmpeg -i INPUT.mkv -map 0:1 -ac 2 OUTPUT.wav
My question is: How can I instruct FFMPEG to preserve the gaps in the original audio, zero (silence) filled?. The WAV file duration should be the same than the original AC3 audio.
Given my current workflow, I would rather prefer to not keep the original timestamps in the output file but generate a WAV with (tiny) silences instead. I could consider keeping timestamps if there is no other choice, but this could be quite a pain in my workflow.
Advice? Help?
Thanks a lot in advance!
Use
ffmpeg -i INPUT.mkv -map 0:1 -af aresample=async=1 -ac 2 OUTPUT.wav
The aresample filter will insert silent samples within the gaps.

How to add offset or delay to audio file with ffmpeg?

I need offset (some silence) in the start of file, so I tried:
./ffmpeg -itsoffset 100 -i 3.mp3 offset_test.mp3
But it doesn't work.
How to add offset to audio file with ffmpeg?
For formats without timestamps, you'll need to add silence, as #Brad mentioned.
ffmpeg -i 3.mp3 -af adelay=100000|100000 delayed.mp3
The adelay takes delay in milliseconds per channel, separated by |.
The easiest way I found so far for ffmpeg ver > 4.2:
ffmpeg -i audio_in.wav -af areverse,apad=pad_dur=1s,areverse audio_out.wav
This will add an offset of 1 second to the audio.

How can i use ffmpeg to extract audio from an video every 5 seconds

I need to extract audio from live stream. I want to generate an audio file every 5s.
if i use the command
ffmpeg -i ***.flv -c:a aac -fs 128k output.aac
I can only get one file. but i want generate a file every 5s.
if i use the commmand
ffmpeg -i ***.mp4 -vf fps=1/5.0 E:\image%d.jpg
I got an image every 1s.
How can i do the same thing to extract audio.
Use the segment muxer:
ffmpeg -i input -map 0:a -f segment -segment_time 5 output_%03d.aac
Add -c copy and use a compatible output container format if you don't want to re-encode.

Resources