I want to add a rotating 3d effect (Haas effect) in mp3. I mean that the audio will seem to change its directions from left to right and vice versa periodically (as shown below) when listened through the headphone. For this, I searched on the Internet and tried to achieve it in the following ways:
Firstly, I thought, if I change the audio of the left and right channel periodically (like when the right channel has full volume (100%), left channel has low volume (20%) and vice versa) then I can achieve it, but it's not like 3D.
Secondly, when I researched more than found that it is done by creating a delay between the two channels. I found that I can create a delay of 0.0 to 0.8 milliseconds according to requirement.
To do this, I use the following commands in FFmpeg :
Step 1: Splitting Audio Channels :
ffmpeg -i D:\ffmpeg\Down.mp3 -map_channel 0.0.0 D:\ffmpeg\L.mp3 -map_channel 0.0.1 D:\ffmpeg\R.mp3
Stem 2: Splitting Left channel into parts :
Note: We will only change the speed of Left channel so we split left
channel into 4 seconds parts.
ffmpeg -i D:\ffmpeg\L.mp3 -f segment -segment_time 4 D:\ffmpeg\Split\%03d.mp3
Step 3: Changing the tempo of each part
Now We change the tempo (speed) of each part so it may feel like the sound
is moving from left to right and vice versa
ffmpeg -y -i D:\ffmpeg\Split\000.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\000.mp3
ffmpeg -y -i D:\ffmpeg\Split\001.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\001.mp3
ffmpeg -y -i D:\ffmpeg\Split\002.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\002.mp3
ffmpeg -y -i D:\ffmpeg\Split\003.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\003.mp3
ffmpeg -y -i D:\ffmpeg\Split\004.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\004.mp3
ffmpeg -y -i D:\ffmpeg\Split\005.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\005.mp3
ffmpeg -y -i D:\ffmpeg\Split\006.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\006.mp3
ffmpeg -y -i D:\ffmpeg\Split\007.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\007.mp3
ffmpeg -y -i D:\ffmpeg\Split\008.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\008.mp3
ffmpeg -y -i D:\ffmpeg\Split\009.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\009.mp3
ffmpeg -y -i D:\ffmpeg\Split\010.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\010.mp3
ffmpeg -y -i D:\ffmpeg\Split\011.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\011.mp3
ffmpeg -y -i D:\ffmpeg\Split\012.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\012.mp3
ffmpeg -y -i D:\ffmpeg\Split\013.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\013.mp3
ffmpeg -y -i D:\ffmpeg\Split\014.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\014.mp3
ffmpeg -y -i D:\ffmpeg\Split\015.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\015.mp3
ffmpeg -y -i D:\ffmpeg\Split\016.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\016.mp3
ffmpeg -y -i D:\ffmpeg\Split\017.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\017.mp3
ffmpeg -y -i D:\ffmpeg\Split\018.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\018.mp3
ffmpeg -y -i D:\ffmpeg\Split\019.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\019.mp3
ffmpeg -y -i D:\ffmpeg\Split\020.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\020.mp3
ffmpeg -y -i D:\ffmpeg\Split\021.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\021.mp3
ffmpeg -y -i D:\ffmpeg\Split\022.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\022.mp3
ffmpeg -y -i D:\ffmpeg\Split\023.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\023.mp3
ffmpeg -y -i D:\ffmpeg\Split\024.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\024.mp3
ffmpeg -y -i D:\ffmpeg\Split\025.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\025.mp3
ffmpeg -y -i D:\ffmpeg\Split\026.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\026.mp3
ffmpeg -y -i D:\ffmpeg\Split\027.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\027.mp3
ffmpeg -y -i D:\ffmpeg\Split\028.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\028.mp3
ffmpeg -y -i D:\ffmpeg\Split\029.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\029.mp3
ffmpeg -y -i D:\ffmpeg\Split\030.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\030.mp3
ffmpeg -y -i D:\ffmpeg\Split\031.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\031.mp3
ffmpeg -y -i D:\ffmpeg\Split\032.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\032.mp3
ffmpeg -y -i D:\ffmpeg\Split\033.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\033.mp3
ffmpeg -y -i D:\ffmpeg\Split\034.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\034.mp3
ffmpeg -y -i D:\ffmpeg\Split\035.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\035.mp3
ffmpeg -y -i D:\ffmpeg\Split\036.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\036.mp3
ffmpeg -y -i D:\ffmpeg\Split\037.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\037.mp3
ffmpeg -y -i D:\ffmpeg\Split\038.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\038.mp3
ffmpeg -y -i D:\ffmpeg\Split\039.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\039.mp3
ffmpeg -y -i D:\ffmpeg\Split\040.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\040.mp3
ffmpeg -y -i D:\ffmpeg\Split\041.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\041.mp3
ffmpeg -y -i D:\ffmpeg\Split\042.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\042.mp3
ffmpeg -y -i D:\ffmpeg\Split\043.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\043.mp3
ffmpeg -y -i D:\ffmpeg\Split\044.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\044.mp3
ffmpeg -y -i D:\ffmpeg\Split\045.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\045.mp3
ffmpeg -y -i D:\ffmpeg\Split\046.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\046.mp3
ffmpeg -y -i D:\ffmpeg\Split\047.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\047.mp3
ffmpeg -y -i D:\ffmpeg\Split\048.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\048.mp3
ffmpeg -y -i D:\ffmpeg\Split\049.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\049.mp3
ffmpeg -y -i D:\ffmpeg\Split\050.mp3 -af atempo=0.9992 D:\ffmpeg\Modi\050.mp3
ffmpeg -y -i D:\ffmpeg\Split\051.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\051.mp3
ffmpeg -y -i D:\ffmpeg\Split\052.mp3 -af atempo=1.0008 D:\ffmpeg\Modi\052.mp3
ffmpeg -y -i D:\ffmpeg\Split\053.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\053.mp3
ffmpeg -y -i D:\ffmpeg\Split\054.mp3 -af atempo=1.0000 D:\ffmpeg\Modi\054.mp3
Here I used 1.0000 for normal speed
and 1.0008 for increased speed
and 0.9992 for decreased speed
Spet 4: Merging small pieces of audio
ffmpeg -f concat -safe 0 -i D:\ffmpeg\f.txt -c copy D:\ffmpeg\output.mp3
where f.txt contains :
file 'D:\ffmpeg\Modi\000.mp3'
file 'D:\ffmpeg\Modi\001.mp3'
file 'D:\ffmpeg\Modi\002.mp3'
file 'D:\ffmpeg\Modi\003.mp3'
file 'D:\ffmpeg\Modi\004.mp3'
file 'D:\ffmpeg\Modi\005.mp3'
file 'D:\ffmpeg\Modi\006.mp3'
file 'D:\ffmpeg\Modi\007.mp3'
file 'D:\ffmpeg\Modi\008.mp3'
file 'D:\ffmpeg\Modi\009.mp3'
file 'D:\ffmpeg\Modi\010.mp3'
file 'D:\ffmpeg\Modi\011.mp3'
file 'D:\ffmpeg\Modi\012.mp3'
file 'D:\ffmpeg\Modi\013.mp3'
file 'D:\ffmpeg\Modi\014.mp3'
file 'D:\ffmpeg\Modi\015.mp3'
file 'D:\ffmpeg\Modi\016.mp3'
file 'D:\ffmpeg\Modi\017.mp3'
file 'D:\ffmpeg\Modi\018.mp3'
file 'D:\ffmpeg\Modi\019.mp3'
file 'D:\ffmpeg\Modi\020.mp3'
file 'D:\ffmpeg\Modi\021.mp3'
file 'D:\ffmpeg\Modi\022.mp3'
file 'D:\ffmpeg\Modi\023.mp3'
file 'D:\ffmpeg\Modi\024.mp3'
Step 5: The last operation is combining the both channels :
ffmpeg -i D:\ffmpeg\L.mp3 -i D:\ffmpeg\output.mp3 -filter_complex [0:a][1:a]amerge=inputs=2[aout] -map [aout] D:\ffmpeg\LRM.mp3
But even then the result is very poor. It looks like FFmpeg combines audio in Step 4 took a delay after each audio.
I think there may be some bug in my solution. I don't think that I can change tempo like this in audio without splitting the audio(Let me know if I am wrong).
Does anyone have a different solution to achieve this?
Please help me in this. Thanks in advance...
You want the apulsator filter or the eponymous Haas filter.
ffmpeg -i D:\ffmpeg\Down.mp3 -af apulsator=hz=0.125 out.mp3
This will rotate the audio from left to right and back in 8 seconds (1/0.125).
Related
I'm facing a big misunderstanding with bash.
Executing line
ffmpeg -y -i "file.mp4" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy "file.mkv" 2> output.log
process is logged to the file.
But executing
xfce4-terminal -e "ffmpeg -y -i \"file.mp4\" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy \"file.mkv\"" 2> /home/$(whoami)/Desktop/output.log"
the logging to file doesn't work.
What could cause this issue?
It can get tricky escaping things when passing a script to a terminal. I would recommend putting your ffmpeg command into a file (e.g. your-file.sh, making it executable (by running chmod +x your-file.sh), then telling the terminal to run that file.
Alright, I found one solution to my problem by adding nohup before ffmpeg like this:
xfce4-terminal -e "nohup ffmpeg -y -i \"file.mp4\" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy \"file.mkv\""
At least this stores me all terminal output data to /home/$(whoami)/nohup.out file.
Thanks anybody for trying to help me! :)
I have two long audio files. I want to merge cut some part from each video
and merge both parts in one file.
In below command the problem there is no audio in the second audio part. It contain the first part and the second is empty.
What is the problem?
ffmpeg -f lavfi -i color=c=black
-ss 157.824 -t 99.818
-i "file1.mp4"
-ss 315.764 -t 50.308
-i "file2.mp4"
-s 854x480
-aspect 1.779167
-r 25
-c:v libx264
-b:v 800k
-c:a aac
-strict experimental
-b:a 128k
-f mp4
-t 150.126 -async 1
-y "output.mp4"
Currently, using ffmpeg, I am using two commands on my Terminal to:
1) create a video from a bunch of images:
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4
2) stream the video to a udp address:
ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
I am trying to combine both these instructions into one command line instruction, using &&, as suggested in the answer to a previous question of mine:
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4 \
&& ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
but am encountering an error which prevents streaming:
[flv # 0x7fa2ba800000] video stream discovered after head already parsed.
Thoughts on a different command line syntax to join the two instructions, different ffmpeg instruction (filters perhaps?), and why I am getting the error?
Currently, using ffmpeg, I am using two commands on my Terminal to:
1) create a video from a bunch of images:
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4
2) stream the video to a udp address:
ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
How can I combine these two commands, into one single ffmpeg command?
A concern I have is that it takes a couple of minutes to generate the video from the images. Therefore, these commands have to happen serially, whereby the second command waits a few minutes for the first command to be completed, before it ensues.
Just add && between the two commands. This will execute the second command if the first executes successfully.
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4 && ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
Need to concat audio files and add background music in a single command.
Right now I use the following commands to do so,
To concat:
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4 -i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4 -filter_complex '[0:0][1:0]concat=n=10:v=0:a=1[out]' -map '[out]' -strict -2 -y 10_final.mp4
To add background music:
ffmpeg -i 10_final.mp4 -i music.mp4 -filter_complex "[0:a]volume=1dB[a0];[1:a]volume=0.5[a1];[a0][a1]amerge=inputs=2[a]" -map "[a]" -ac 1 -ab 32000 -ar 22050 -strict -2 -y 10_with_music.mp4
But his process is a quite time-consuming process as every time the file read/write happening to the output.
Is there a way I can merge these two above commands to a single so that the command should be optimized.
Use
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4
-i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4
-i music.mp4
-filter_complex '[0:0][1:0]...[9:0]concat=n=10:v=0:a=1,volume=1dB[a0];
[10]volume=0.5dB[a1];[a0][a1]amerge[a]'
-map '[a]' -strict -2 -y 10_with_music.mp4