I have created video with multiple images and single music file. It's working fine
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-000.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;
But when I tried with multiple music files it throws and error in terminal.
Command:
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-%03d.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;
Error:
/<<dir path>>/music3-%03d.mp3: No such file or directory
There's no audio sequence demuxer. To combine multiple audio files in your command, you'll have to use the concat demuxer.
First, create a text file with the list of files
file 'music3-000.mp3'
file 'music3-001.mp3'
file 'music3-002.mp3'
...
Then run
ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg \
-f concat -i list.txt \
-c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental
-shortest /<<dir path>>/video/output.mp4
Related
I tried to stream an mp3 file to a Telegram RTMP live using the following command:
ffmpeg -re -i 1.mp3 -c copy -f mp3 rtmps://dc4-1.rtmp.t.me/s/145158:AtyF3rrME2nHEkqGA
But I couldn't hear any sound in the stream.
You should specify the codecs explicitly.
The following is the simplest working command:
ffmpeg -i your_input -c:v libx264 -c:a aac -f flv rtmps://dcx-y.rtmp.t.me/s/YOUR_KEY
Here is a more advanced example from #tgbeta:
ffmpeg -stream_loop -1 -re -i your_input -c:v libx264 -preset veryfast -b:v 3500k -maxrate 3500k -bufsize 7000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 -ar 44100 -f flv rtmps://dcx-y.rtmp.t.me/s/YOUR_KEY
Change -f mp3 by -f flv.
Example:
ffmpeg -re -i 1.mp3 -c:a copy -f flv rtmps://dc4-1.rtmp.t.me/s/145158:AtyF3rrME2nHEkqGA
I have 250 images / day of 4000*3000 pixels in a text file.
file '/home/user/camdata/nonseqdata.jpg'
file '/home/user/camdata/strangedata.jpg'
i created mp4 video with this command
ffmpeg -y -f concat -safe 0 -i ecam.001_20210525.txt -c:v libx264 -vf "scale=1280:720,fps=25,format=yuv420p" out.mp4
Now i need to add watermark to video.(in same command)
closest example i found on web, trying to modify that and use in my case is like..
ffmpeg -r 25 -f image2 -s 1280x720 -i ecam.001_20210525.txt -i wm.png -filter_complex "[0:v][1:v] overlay=0:0" -vcodec libx264 -crf 25 -pix_fmt yuv420p test_overlay.mp4
OR
ffmpeg -r 25 -f concat -safe 0 -s 1280x720 -i ecam.001_20210525.txt -i wm.png -filter_complex "[0:v]pad=width=mainw:height=mainh:x=0:y=0,[1:v] overlay=0:0" -c:v libx264 test_overlay.mp4
BUT it error out to >> Decoder (codec none) not found for input stream #0:0
Q. how exactly to fix this.? i need output to be 720p or 1080p.?
Use
ffmpeg -y -f concat -safe 0 -i ecam.001_20210525.txt -i wm.png -filter_complex "[0]scale=1280:720[v];[v][1]overlay=x=0:y=0,fps=25,format=yuv420p" -c:v libx264 out.mp4
I have this command to add watermark to an mp4
ffmpeg -i junai-blvaz.mp4 -i evercam-logo-white.png -filter_complex "[1]scale=iw/2:-1[wm];[0][wm]overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10" -codec:a copy output.mp4
But I am creating the video using
ffmpeg -r 6 -i /tmp/%d.jpg -c:v h264_nvenc -r 6 -preset slow -bufsize 1000k -pix_fmt yuv420p -y junai-blvaz.mp4
Is there any way to merge this command of adding watermark
-i evercam-logo-white.png -filter_complex '[1]scale=iw/2:-1[wm];[0][wm]overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10'
to the very first command through which mp4 video has been created?
Combine the two commands:
ffmpeg -y -framerate 6 -i /tmp/%d.jpg -i evercam-logo-white.png -filter_complex "[1]scale=iw/2:-1[wm];[0][wm]overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10,format=yuv420p" -c:v h264_nvenc -preset slow -bufsize 1000k junai-blvaz.mp4
I have 300 images and i wants to generate video from these images.
i am new to FFMPEG so now i am using two commands to generate video from images.
Command to generate video from images which also add Logo on video
ffmpeg -framerate 24 -i img_%d.jpg -i logo.png -filter_complex \
"[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \
-vcodec libx264 -crf 25 -pix_fmt yuv420p test_video.mp4
After using above command i am getting the video to add audio to this video i am using below command
ffmpeg -i test_video.mp4 -i inputfile.mp3 -c:v libx264 -c:a libvorbis -shortest final_video.mp4
which generates video and i am getting below message
MPEG-4 AAC decoder is required to play the file
Help to combine this both command. if possible can we add sound without any decoder required
Log for command 1 https://drive.google.com/file/d/1zS7gvrPy69VK_MkyE4127FpX2kEziJHq/view?usp=sharing
and Log command 2 https://drive.google.com/file/d/1rHqVGzj7f003aWP6eISiyUjsES8_EWuw/view?usp=sharing
Try next command:
ffmpeg -framerate 24 -i img_%d.jpg -i logo.png -i inputfile.mp3 -filter_complex \
"[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \
-vcodec libx264 -crf 25 -map 2:a -c:a copy -pix_fmt yuv420p -shortest test_video.mp4
-map 2:a is needed to skip image in case if there is cover image in track.
With -c:a copy track will not be re-encoded, so you will have mp3 inside of your video file.
THE INPUT FILES
An overlay image that has is being updated every 5 seconds by a Python script
A small MP4 file that will be looped by a concat input
An MP3 file as audio source
THE COMMAND (UPDATED)
This is the command I'm currently using to combine and stream the inputs.
ffmpeg -re -i music.mp3 -f concat -i videoincludes.txt
-r 1 -loop 1 -f image2 -i overlay.png
-c:v libx264 -c:a aac -shortest -crf 23 -pix_fmt yuv420p
-maxrate 2500k -bufsize 2500k -preset ultrafast -r 30 -g 60 -b:v 2000k -b:a 192k -ar 44100
-filter_complex "[1:v][2:v] overlay=0:0" -map 0:a -strict -2
-f flv rtmp://a.rtmp.youtube.com/live2/{key}
Als tried using -framerate 1 instead of -r 1
THE ISSUE
So the issue is that the image doesn't always update. Sometimes it does update every couple seconds at the start but it stops updating after 10-20 seconds without any difference in log output and sometimes it just doesn't update.
I can however confirm that the image is being updated by the Python script but FFmpeg is just not picking this up.
I read setting the input format of the image to image2 should allow it to update so I am not sure what is wrong or what I can do to improve it.
I'm working on the same task, and finally, I think, I found the answer.
Because streams different from each other we must reset their timestamps with setpts=PTS-STARTPTS to have them begin in the same zero timestamp . And, also, try to use image2pipe instead of image2.
This is your code with timestamp reset:
ffmpeg -re -i music.mp3 -f concat -i videoincludes.txt
-r 1 -loop 1 -f image2pipe -i overlay.png
-c:v libx264 -c:a aac -shortest -crf 23 -pix_fmt yuv420p
-maxrate 2500k -bufsize 2500k -preset ultrafast -r 30 -g 60 -b:v 2000k -b:a 192k -ar 44100
-filter_complex "[1:v]setpts=PTS-STARTPTS[out_main]; [2:v]setpts=PTS-STARTPTS[out_overlay]; [out_main][out_overlay]overlay=0:0" -map 0:a -strict -2
-f flv rtmp://a.rtmp.youtube.com/live2/{key}
p.s and I think, there is no need in -r or -framerate anymore