суббота, 13 августа 2022 г.

software video waveform vectoroscope monitor for free. ffmpeg / fflplay

This time i want to introduce you some great ffmpeg features which help to understand color levels of any video source. 
This meters based on ffmpeg video filters. In my example i use several meters on single screen according to my tasks, but you can change video filters params as you wish to make a custom video meter.


You can run meters with ffplay to show meters on your desktop screen or use ffmpeg to pass meters to ip stream / file / sdi board output.

At first install ffmpeg in your system, and then paste below code into your command line (win/linux), change "stream/video" to your video file, press enter and watch the result. 


ffplay  -i stream/video -vf  "split=5[in][w1][w2][v1][a];[in] scale=1024:576 [scin];  [a] eq=brightness=-1 :saturation=0, scale=1558x876, eq=brightness=0 [bg]; [w1] format=gbrp,waveform=filter=lowpass:components=7:display=overlay:graticule=green:flags=numbers:scale=ire:intensity=0.1 , scale=1024:150[ww1]; [w2]format=gbrp,waveform=filter=acolor:graticule=green:flags=numbers:scale=ire:components=7:display=overlay:intensity=0.4:bgopacity=0.5, scale=1024:150 [ww2]; [v1] format=yuva444p9, vectorscope=b=0.7:m=color3:g=green[vv1];  [bg][scin] overlay=0:150[bgv];[bgv][ww1] overlay=0:0[bvw1];[bvw1][ww2] overlay=0:726[bvw2]; [bvw2][vv1] overlay=x=W-w:y=H-h"






Next example is pretty complex. It uses SDI decklink input/output board to pass input video from SDI live source and pass meters to SDI monitor for live control and fast correction. It helps to adjust camera iris, check black and white balance, sheck saturation.


It's writed in CMD file by one simple reason, it's much easy to edit multi string code than single string.

The code below is writed for windows but you can use it in linux system by changing symbols "^" to "\". And of course it will take time to adjust your SDI board and resolution correctly.
Don't forget, to run ffmpeg with decklink board, your ffmpeg version should be compiled with --enable-decklink option.

The code of ffscope.cmd is below:

C:\ffmpeg-decklink-4.0\ffmpeg.exe -threads 1 -filter_threads 1 -an -sn ^
-f dshow -video_size 1280x720 -pixel_format  uyvy422 -rtbufsize 1M -framerate 50 -r 50  -i video="Decklink Video Capture (3)":audio="Decklink Audio Capture (3)" ^
 -vf split=6[parade][luma][vector][video][dum][bg];^

[bg]eq=brightness=-1:saturation=0,scale=1280x720,eq=brightness=0[bg];^
[video]scale=640:360,format=yuv420p[video];^
[dum]format=yuv420p,histogram=display_mode=0:level_height=360,scale=280:360[dum];^

[vector]format=yuv420p,^
vectorscope=mode=color4:colorspace=709:graticule=green:flags=white+name,^
drawbox=w=4:h=4:t=1:x=104-2:y=98-2:c=invert,^
drawbox=w=4:h=4:t=1:x=110-2:y=106-2:c=invert,^
drawbox=w=4:h=4:t=1:x=116-2:y=113-2:c=invert,^
drawbox=w=4:h=4:t=1:x=122-2:y=120-2:c=invert,scale=360:360^
[vector];^

[luma]scale=640:360,format=yuv420p,^
waveform=filter=lowpass:scale=ire:graticule=orange:flags=dots+numbers,scale=640:360^
[luma];^

[parade]scale=640:360,format=gbrp,^
waveform=filter=lowpass:components=7:display=overlay,scale=640:360^
[parade];^

[parade][luma]hstack=2[row1];^
[video][dum][vector]hstack=3[row2];^
[row1][row2]vstack=2[scopes],[bg][scopes]overlay=0:0 -an -f decklink  -pix_fmt uyvy422 "DeckLink Duo (3)" 

 There will be a lot of error mesages during running this code, it means that ffmpeg hasn't enough buffers for reading input to process all data, but its enough to output meters. If set buffer value then will be high delay in output video.
 Also -threads 1 -filter_threads 1 parameters will make CPU consumption lowest when processing. 

This is another version of example. It runs ffplay and check virtual obs camera colors.
https://raw.githubusercontent.com/Fubaxiusz/Batch-tools/master/FFMPEG%20scripts/Color%20Grading%20Scopes%20(OBS).cmd


convert colors to midi note for midi controllers

I recently (2 years ago) designed and built a simple MIDI controller for my intercom system using an Arduino Leonardo, USB hub, sound card, ...