question about displace filter
In the documentation for the displace filter is written: "The second input specifies how much to displace pixels along the x-axis, ..." If I understand this right, a video input file is "misused" for storing the displacement (instead of brightness). Does that mean that only positive displacements are possible? I'm looking for a solution to make curved text for a fulldome video. Thanks, Michael
On 11/18/17, Michael Koch <astroelectronic@t-online.de> wrote:
In the documentation for the displace filter is written: "The second input specifies how much to displace pixels along the x-axis, ..." If I understand this right, a video input file is "misused" for storing the displacement (instead of brightness). Does that mean that only positive displacements are possible?
No, value stored in pixels is 0 - 255. One just substract each possible value with 128 and now you have [-128, 127].
One just substract each possible value with 128 and now you have [-128, 127].
Thanks for your fast answer. That should be added to the documentation! Michael
One just substract each possible value with 128 and now you have [-128, 127].
The range is too small for my purpose. Is it possible to create 16 bit displacements? Michael
Perhaps you could try remap filter?
Unfortunately the remap filter has so few documentation. No examples at all. Is it possible to create the Xmap and Ymap files with ffmpeg? Michael
On 11/18/17, Michael Koch <astroelectronic@t-online.de> wrote:
Perhaps you could try remap filter?
Unfortunately the remap filter has so few documentation. No examples at all. Is it possible to create the Xmap and Ymap files with ffmpeg?
Yes, with geq filter. Remap filter documentation is on FFmpeg wiki.
Yes, with geq filter. Remap filter documentation is on FFmpeg wiki.
I can't find an example how to make the Xmap and Ymap files with ffmpeg. In the wiki the files are made with a C program which is difficult to understand. https://trac.ffmpeg.org/wiki/RemapFilter This example is from the documentation of the displace filter: ffmpeg -i INPUT -f lavfi -i nullsrc=s=hd720,lutrgb=128:128:128 -f lavfi -i nullsrc=s=hd720,geq='r=128+30*sin(2*PI*X/400+T):g=128+30*sin(2*PI*X/400+T):b=128+30*sin(2*PI*X/400+T)' -lavfi '[0][1][2]displace' OUTPUT However for the remap filter we need only one 16-bit value per pixel. Not three 8-bit RGB values. How can this be created with ffmpeg? Michael
Finally I found a solution how to make curved text for a fulldome video. It's awfully slow because in the geq filter the same calculations are made for each frame again and again. But it works. Below is the Windows batch file. Most probably the remap filter would make this process much faster, but I haven't yet figured out how to make the Xmap and Ymap files. Michael REM make a video with curved text for fulldome fade-in fade-out set "DUR=10" : duration of video set "FPS=30" : framerate set "BACK=black" : background color set "FONT=arial.ttf" : font set "TEXT=my_text.txt" : text file set "COLOR=orange" : text color set "FSIZE=15" : font size set "POS_X=(w-tw)/2" : X text position, for centered text: (w-tw)/2 set "POS_Y=h*0.9" : Y text position set "S=2" : start time for text set "E=8" : end time for text set "FI=2" : fade-in duration (may be small, but not zero) set "FO=2" : fade-out duration (may be small, but not zero) set "SIZE=1000" : video size (quadratic) c:/ffmpeg/ffmpeg ^ -f lavfi ^ -i color=c=%BACK% ^ -r %FPS% ^ -t %DUR% ^ -aspect "1:1" ^ -vf "scale=%SIZE%:%SIZE%,drawtext='fontfile=%FONT%:textfile=%TEXT%:fontcolor_expr=%COLOR%@%%{e\:clip(((t-%S%)/%FI%)*between(t,%S%,%S%+%FI%)+(%E%-t)/%FO%*between(t,%S%+%FI%,%E%),0,1)}:fontsize=%FSIZE%:x=%POS_X%:y=%POS_Y%',geq=p(if(gt(Y\,H*0.7)\,W/2+H/2*atan((X-W/2)/(Y-H/2))\,0)\,if(gt(Y\,H*0.7)\,H/2+hypot(X-W/2\,Y-H/2)\,0))" ^ -c:v mpeg4 ^ -q:v 0 ^ -y test.mp4 pause
participants (2)
-
Michael Koch -
Paul B Mahol