ffmpeg images list (text file) to video with overlay watermark - ffmpeg

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

Related

FFMPEG Video loop from images files

I am trying to make a video from a bundle of image files and then apply a an overlay on top of it.Another requirement is to make the video loop 3x. It is simply not working.
The first three paths are pointing toward the same image bundle. (A folder containing images like the following DSC0001_0013.jpg,DSC0002_0013.jpg,etc)
Observed symptoms:
The script runs infinitely.I produces a video file of 0 KB.I have to abort script using CTRL+C
This is my script.
ffmpeg
-start_number 1 -framerate 3/1
-i "C:\Users\xxx\AppData\Local\xxx\xxx\xxx\xxx\xxx\xxx\xxx\963d9d9b8e1\DSC%04d_0013.jpg"
-i "C:\Users\xxx\AppData\Local\xxx\xxx\projects\xxx\xxx\xxx\xxx\963d9d9b8e1\DSC%04d_0013.jpg"
-i "C:\Users\xxx\AppData\Local\xxx\xxx\projects\xxx\xxx\xxx\xxx\963d9d9b8e1\DSC%04d_0013.jpg"
-i "C:\Users\xxx\AppData\Local\xxx\xxx\projects\1237\1138\overlay.png"
-i "C:\Users\xxx\AppData\Local\xxx\xxx\projects\1237\1138\overlay.png"
-i "C:\Users\xxx\AppData\Local\xxx\xxx\projects\1237\1138\overlay.png"
-filter_complex " [0:v]scale=600x900[scaled1]; [1:v]scale=600x900[scaled2]; [2:v]scale=600x900[scaled3]; [scaled1][3:v]overlay[tmp1]; [scaled2][4:v]overlay[tmp2]; [scaled3][5:v]overlay[tmp3]; [tmp1][tmp2][tmp3]concat=n=3[scaled] "
-map [scaled] -r 10 -vcodec libx264 -pix_fmt yuv420p -crf 23 "C:\Users\xxx\Documents\Projets\2020\xxx\video test ffmpeg\test.mp4"
Use the -stream_loop option:
ffmpeg -stream_loop 3 -framerate 3/1 -i DSC%04d_0013.jpg -i overlay.png -filter_complex "[0]scale=600:900[bg];[bg][1]overlay=format=auto,format=yuv420p[v]" -map "[v]" -r 10 -c:v libx264 -crf 23 output.mp4
#Ilogan, This is our solution.
-start_number 1 -framerate 3/1
-i DSC%04d_0013.jpg
-loop 1 -i overlay.png"
-filter_complex "
[0:v]scale=600x900[scaled];
[scaled][1:v]overlay,trim=duration=3,loop=loop=2:size=9[tmp]
" -map [tmp] -r 10 -vcodec libx264 -pix_fmt yuv420p -crf 23
test.mp4

FFMPEG Add watermark to 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

Combine Two Commands (Get Video from Images)

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.

ffmpeg single source and multiple streaming + multiple image overlay

NOTE: The below ffmpeg command lines are just a pseudo lines, not 100% final.
From single source I need to stream 2 different udp:// stream.
And I need to overlay 2 different png images on each.
Base sample line:
ffmpeg -r 25 -f dshow -i "video=VideoCaptureDevice:audio=AudioCaptureDevice" -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1234?pkt_size=1316" -codec:v libx264 s:v 720x480 -codec:a libfaac -f mpegts "udp://224.1.1.1:1235?pkt_size=1316"
Now I need to overlay 2 separate images in each output.
I tried below lines and failed.
Overlay sample line what I tried:
ffmpeg -r 25 -f dshow -i "video=VideoCaptureDevice:audio=AudioCaptureDevice" -i "C:\Image1.png" -filter_complex "overlay=100:100" -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1234?pkt_size=1316" -i "C:\Image2.png" -filter_complex "overlay=500:100" -codec:v libx264 s:v 720x480 -codec:a libfaac -f mpegts "udp://224.1.1.1:1235?pkt_size=1316"
Use
ffmpeg -r 25 -f dshow -i "video=VideoCaptureDevice:audio=AudioCaptureDevice" -i "C:\Image1.png" -i "C:\Image2.png" -filter_complex "split[a][b];[a][1]overlay=100:100[v1];[b][2]overlay=500:100,scale=720:480[v2]" -map "[v1]" -map 0:a -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1234?pkt_size=1316" -map "[v2]" -map 0:a -codec:v libx264 -codec:a libfaac -f mpegts "udp://224.1.1.1:1235?pkt_size=1316"

Create MP4 video from multiple images + musics using FFMPEG command

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

Resources