ffmpeg adjust contrast, show histogram - ffmpeg

I'm trying to first adjust the contrast of a frame extracted from an mp4, then overlay the histogram of the resultant frame on top. My command here does all of this, but also adjusts the contrast of the histogram itself. Is there a single ffmpeg command that can do what I wish?
ffmpeg -ss 3.5 -i in.mp4 -an -y -vf \
"split=2[a][b],[b]eq=0.5:0:1:1:1:1:1,histogram=levels_mode=logarithmic:\
components=1:level_height=100, [a]overlay,eq=0.5:0:1:1:1:1:1" \
-vframes 1 -q:v 2 out.jpg

Use
ffmpeg -ss 3.5 -i in.mp4 -an -y -filter_complex \
"eq=0.5:0:1:1:1:1:1,split=2[a][b];[b]histogram=levels_mode=logarithmic:\
components=1:level_height=100[b];[a][b]overlay" -vframes 1 -q:v 2 out.jpg

Related

First frame not getting blur from ffmpeg

I am trying to run a combination of overlay and boxblur filters to blur pixels in human background (using ffmpeg). My command is as follows:
ffmpeg -y \
-ss 00:00:02.000 -t 00:00:02.000 -i Adeel_Abbas_20210423T191428-1X.MP4 \
-ss 00:00:02.000 -t 00:00:02.000 -i Adeel_Abbas_20210423T191428-1X-SM.MP4 \
-filter_complex " \
[0:v][1:v] alphamerge[fg0]; [0:v]boxblur=luma_radius=3:chroma_radius=0:alpha_radius=0:luma_power=1:chroma_power=0:alpha_power=0[bv0]; [bv0][fg0]overlay,crop=1920:1080:0:78,setpts=PTS-STARTPTS[vs0]" -map "[vs0]" \
-b:v 8709120 -bf 2 -threads 8 -tag:v avc1 -c:v libx264 -preset medium -g 144 -color_primaries bt709 -color_trc bt709 -colorspace smpte170m output.mp4
Here are sample files that can be used to perfectly reproduce this issue.
Using ffmpeg-5.0 the background in first frame will not get blur applied but successive frames will get blurred properly. Can someone please help
Only happens if I seek from random places in original file using -ss 00:00:02.000 -t 00:00:02.000 command. If I start processing from beginning of file by omitting -ss flag, everything looks good.

I want to pipe these two ffmpeg commands for to convert a video to grayscale frames

Please, I want to pipe these two commands.
ffmpeg -i input.flv -vf fps=1 out%d.png | ffmpeg -i input -vf format=gray output
If you just need frames, try this:
ffmpeg -i input.flv -r 1 -pix_fmt gray out%d.png
There is no need to call it twice
-r sets the output frame rate (1 frame/sec) dropping excess frames
pix_fmt sets the output pixel format
[edit]
Try this to output both grayscale video and images:
ffmpeg -i input.flv \
-filter_complex format=gray,split[v0][v1]
-map [v0] -r 1 out%d.png
-map [v1] output.mp4

FFMPEG images to video + overlay video

I am trying to make 15 second video where the background layer is a video made up of 2 images, the first line creates a 15 second video from 2 images.
I chose a small framerate so it renders an mp4 quickly. I then overlay a webm video (which has transparency) over the images. The final video seems to keep the framerate of 2, but i would rather keep the 24 framerate of the webm video.
Is this possible? & is it also possible to turn the below into 1 statement.
ffmpeg -loop 1 -framerate 2 -t 11 -i image1.png -loop 1 -framerate 2 -t 4 -i image2.png -filter_complex "[0][1]concat=n=2" backgroundvideo.mp4;
ffmpeg -i backgroundvideo.mp4 -c:v libvpx-vp9 -i overlayvideo.webm -filter_complex overlay newvid.mp4
You can use the filter fps to adjust your background's framerate
ffmpeg \
-loop 1 -framerate 2 -t 11 -i image1.png \
-loop 1 -framerate 2 -t 4 -i image2.png \
-c:v libvpx-vp9 -i overlayvideo.webm \
-filter_complex '[0][1]concat,fps=24[bg];[2][bg]overlay' \
backgroundvideo.mp4

How to add 'drawtext' to overlay in ffmpeg?

The command is ffmpeg -loop 1 -t 5 -i "demo_1.jpg" -filter_complex "nullsrc=size=640x360[background];[background][0:v]overlay=shortest=1:x='min(-(t)*20,0)'" -qscale 1 -y out.mp4
I am animating the image from right to left. In the above command, I need to add text, How to integrate the drawtext feature of ffmpeg to that.
The video animation is https://youtu.be/teXUiPKX83o.
Need to add text to that video.
Use
ffmpeg -loop 1 -t 5 -i "demo_1.jpg" -filter_complex
"nullsrc=size=640x360[background];
[background][0:v]overlay=shortest=1:x='min(-(t)*20,0)',
drawtext=fontfile='/path/to/font':fontsize=30:fontcolor=yellow:x=50:y=50:text='Text'"
-qscale 1 -y out.mp4
See drawtext docs for more info.

How to scale and position watermark to scale?

I'm scaling a video and applying a watermark like so:
ffmpeg -ss 0:0:0.000 -i video.mp4 -y -an -t 0:0:10.000
-vf \"[in]scale=400:316[middle]\" -b:v 2000k -r 20
-vf 'movie=watermark.png,pad=400:316:0:0:0x00000000 [watermark];[middle] [watermark]overlay=0:0[out]'
out.flv
However, the applied watermark seems to be scaled to the original video size rather than the smaller scaled video size.
This command line worked on ffmpeg version 0.8.6.git and now behaves differently after an upgrade to version N-52381-g2288c77.
How do I get it to work again?
Update 2013-04-26:
I now have tried to use the overlay filter's X and Y parameters instead of padding without success.
Answered by ubitux on the FFmpeg IRC:
Use scale and overlay in a single -filter_complex chain, like so:
ffmpeg -y -ss 0 -t 0:0:30.0 -i 'video.mp4' -i '/watermark.png'
-filter_complex "[0:0] scale=400:225 [wm]; [wm][1:0] overlay=305:0 [out]"
-map "[out]" -b:v 896k -r 20 -an
'out.flv'
Also load the watermark via -i rather than the movie filter.

Resources