Adding time stamp overlay to video stream using ffmpeg I’ve been playing around with live streaming from ffmpeg recently, and my latest adventure was to try adding a time stamp to the feed. I searched Google for a solution, but couldn’t find a complete howto, so this is pieced together from information I found found all over the net. I wanted to scale a video input (1.webm) and keeping it's aspect ratio, then overlay to make it centered, with following command: ffmpeg -y -hidebanner -i 1.webm -filtercomplex 'color=color=Bl. Stack Exchange Network.
How can I scale down the overlay image to
Henry The LeastHenry The Leastscale=320:240
in ffmpeg?Wherever I try to place the scale command, i don't get the results.Here is the command I am using, but it is actually stretching the image:34922 gold badges77 silver badges1818 bronze badges
1 Answer
In the filter chain, you must first scale the image separately, and then perform the overlay. Just prepend your filterchain with
[1:v]scale=320:240 [ovrl],[0:v][ovrl]
.The final command line (split to multiple lines for better readability):However, if your video is anamorphic (storage aspect ratio (SAR) is different from display aspect ratio (DAR), used mainly in TV broadcasts), then the video is resized (stretched) upon playback. Of course, the overlaid image is then stretched as well, as it is part of the video.
For example, PAL SD broadcast (stored in 720x576 pixels, SAR=5:4) is usually displayed using 16:9 DAR, thus would be resized upon playback to 1024x576 to keep DAR. So if you overlay 320x240 image on such video, its display size would then be 455x240 and it would look stretched.
For example, PAL SD broadcast (stored in 720x576 pixels, SAR=5:4) is usually displayed using 16:9 DAR, thus would be resized upon playback to 1024x576 to keep DAR. So if you overlay 320x240 image on such video, its display size would then be 455x240 and it would look stretched.
If you require that the aspect ratio of your overlay image (4:3) is kept, you need to take into account the SAR and DAR of your video and calculate the correct dimensions to resize the image for overlay. If you know SAR and DAR of your video, you can use this formula, to calculate the correct width to resize your overlay image (assuming height stays at 240): width=320*SAR/DAR
WeaverWeaver