How to create Silent Opus Audio Files - audio

I need silent Opus audio files range of 1 second to 60 minutes.
I found this example for wav files:
60 seconds of silent audio in WAV:
ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero
-acodec copy output.wav
60 seconds of silent audio in MP3:
ffmpeg -ar 48000 -t 60 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero
-acodec libmp3lame -aq 4 output.mp3
How can I do it for opus with using ffmpeg or similar tool?

Using a recent build of ffmpeg, run
ffmpeg -f lavfi -i anullsrc -ac 2 -ar 48000 -t 30 -c:a libopus file.opus
You can add -vbr 0 -b:a 128k for a CBR encode.

Related

ffmpeg output to multiple rtmp simultaneously

i have this situation:
i need stream to 3 different rtmp
1 rtmp is normal all the audio and video
2 rtmp is the video but different audio
3 rtmp is only audio of first video
this my elaboration...
ffmpeg -re -i /usr/VIDEO/my_video.mp4 -i /usr/VIDEO/x_audio.mp3 \
-map 0:v -c:v libx264 -vf format=yuv420p -b:v 2000k -bufsize 3000k -maxrate 2000k -s 1024X576 -g 60 -map 0:a -c:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/live/pass \
-map 0:v -c:v libx264 -vf format=yuv420p -b:v 2000k -bufsize 3000k -maxrate 2000k -s 1024X576 -g 60 -map 1:a -streamloop -shortest -f flv rtmp://my_ip/noaudio/pass \
-map 0:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/only_audio/pass
i was thinking was ok, but is not.
Where I have misstake
ok find solution
ffmpeg -re -i /usr/VIDEO/my_video.mp4 -re -i /usr/VIDEO/xaudio.mp3 \
-map 0 -c:v libx264 -vf format=yuv420p -b:v 2000k -bufsize 3000k -maxrate 2000k -s 1024X576 -g 60 -c:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/live/pass \
-map 0:v -c:v libx264 -vf format=yuv420p -b:v 2000k -bufsize 3000k -maxrate 2000k -s 1024X576 -g 60 -map 1:a -c:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/noaudio/pass \
-map 0:a -c:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/onlyaudio/pass
and like that gonna work
for looping the audio add -stream_loop (--NUMBER--) before the audio where (--NUMBER--) sis the times that should repeat
once -stream_loop 1
twice 1nce -stream_loop 2
3 times 1nce -stream_loop 3
... and so on
ffmpeg -re -i /usr/VIDEO/my_video.mp4 -stream_loop (--NUMBER--) -re -i /usr/VIDEO/xaudio.mp3 \
-map 0 -c:v libx264 -vf format=yuv420p -b:v 2000k -bufsize 3000k -maxrate 2000k -s 1024X576 -g 60 -c:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/live/pass \
-map 0:v -c:v libx264 -vf format=yuv420p -b:v 2000k -bufsize 3000k -maxrate 2000k -s 1024X576 -g 60 -map 1:a -c:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/noaudio/pass \
-map 0:a -c:a aac -b:a 192k -ar 44100 -f flv rtmp://my_ip/onlyaudio/pass
Use the tee muxer. It's more complicated but more efficient: you can encode streams once and re-use them for multiple outputs.
ffmpeg -re -i video.mp4 -re -i audio.mp3 -map 0 -map 1:a -c:v libx264 -c:a aac -vf "scale=1024:-2,format=yuv420p" -b:v 2000k -bufsize 3000k -maxrate 2000k -g 60 -b:a 192k -ar 44100 -shortest -f tee "[select=\'v:0,a:0\':f=flv]rtmp://my_ip/normal|[select=\'v:0,a:1\':f=flv]rtmp://my_ip/altaudio|[select=\'a:0\':f=flv:onfail=ignore]rtmp://my_ip/onlyaudio"

ffmpeg multiple outputs is working only on the first rtmp

I have try stream with ffmpeg with output to differents rtmp servers like that
ffmpeg -re -i nameoffile.mp4 -vcodec libx264 -g 60 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv \
-f flv rtmp://rtmp.1.com/code \
-f flv rtmp://rtmp.2.com/code \
-f flv rtmp://rtmp.3.com/code \
-f flv rtmp://rtmp.4.com/code \
-f flv rtmp://rtmp.5.com/code \
The problem is... is working only the first one but not the others
You have to set the output options for each output: -vcodec libx264 -g 60 -c:a aac -b:a 160k -ar 44100

Ffmpeg script cuts out sound

I have this ffmpeg script I'm running to automatically convert videos to instagram's accepted coded
The script looks like this:
ffmpeg -analyzeduration 20M -probesize 20M -y -re -f lavfi -i "movie=filename='file.mp4':loop=5, setpts=N/(FRAME_RATE*TB)" -vcodec libx264 -b:v 3500k -vsync 2 -t 59 -acodec aac -b:a 128k -pix_fmt yuv420p -vf "scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2:white" -crf 24 new_file.mp4
However that seems to cut out the audio, and I can't seem to find out how to prevent that? I didn't use any -an or anything, and when messing around the audio keeps being cut out? Any idea why?
The movie filter, by default, only reads one video stream from the input.
For looping, stream_loop is available without having to use filters.
ffmpeg -analyseduration 20M -probesize 20M -y -re -stream_loop 5 -i "file.mp4" -vcodec libx264 -b:v 3500k -vsync cfr -t 59 -acodec aac -b:a 128k -pix_fmt yuv420p -vf "scale=1080:1080:force_original_aspect_ratio=decrease,pad=1080:1080:(ow-iw)/2:(oh-ih)/2:white" -crf 24 new_file.mp4

How to filter for multiple extensions in a shell script in one line?

For the script below:
Is it possible to make out of these six lines one single line that is looking for mp4, webm etc. files in one step? (perhaps with something like: ".*\.mp4|.*\.webm..."?
for i in *.mp4 ; do avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$i".mp3 ; done;
for i in *.webm ; do avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$i".mp3 ; done;
for i in *.m4a ; do avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$i".mp3 ; done;
for i in *.3gp ; do avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$i".mp3 ; done;
for i in *.mpeg ; do avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$i".mp3 ; done;
for i in *.aac ; do avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$i".mp3 ; done;
for i in *.mp4 *.webm *.m4a *.3gp *.mpeg *.aac; do avconv -i "$i" -vn -acodec libmp3lame -ac 2 -ab 128k -ar 44100 "$i".mp3; done

FFmpeg (merge two audio)

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"

Resources