0

I was trying to achieve get an animated text overlay. I found this thread: ffmpeg moving text drawtext

When I run this code however:

ffmpeg -i VideoInput.mp4 \
       -vf "drawtext=enable='between(t,12,15)':fontfile=myfont.otf:text='Test test': \
           x='if(lt(t-t2+1\,0)\,x1+(x2-x1)*(t-t1)/(t2-t1-1)\,x)': \
           y='if(lt(t-t2+1\,0)\,y1+(y2-y1)*(t-t1)/(t2-t1-1)\,y)':fontsize=65" \
       -acodec copy outputVideo.mp4

I get the error:

[Parsed_drawtext_0 @ 000002d862595c00][Eval @ 000000e1d79fe300] Undefined constant or missing '(' in 't2-t1-1),x)' 
[Parsed_drawtext_0 @ 000002d862595c00] Failed to configure input pad on Parsed_drawtext_0

A second strange error, which may be the cause for the problem at the top. Is that I can't run the arguments on multiple lines. So with the code below I have to remove the slashes and put it on 1 line. I use PHP so this does not work (white screen, no output)

$arguments = "-i out1.mp4 \
       -vf \"drawtext=enable='between(t,12,15)':fontfile=myfont.otf:text='Test test': \
           x='if(lt(t-t2+1\,0)\,x1+(x2-x1)*(t-t1)/(t2-t1-1)\,x)': \
           y='if(lt(t-t2+1\,0)\,y1+(y2-y1)*(t-t1)/(t2-t1-1)\,y)':fontsize=65\" \
       -acodec copy outputVideo.mp4 2>&1";
$output = shell_exec('D:/wamp64/www/createslideshow/ffmpeg-20190319-f8075b2-win64-static/bin/ffmpeg.exe '.$arguments);

This works but gives the undefined constant error:

$arguments = "-i out1.mp4 -vf \"drawtext=enable='between(t,12,15)':fontfile=myfont.otf:text='Test test': x='if(lt(t-t2+1\,0)\,x1+(x2-x1)*(t-t1)/(t2-t1-1)\,x)': y='if(lt(t-t2+1\,0)\,y1+(y2-y1)*(t-t1)/(t2-t1-1)\,y)':fontsize=65\" -acodec copy outputVideo.mp4 2>&1";
$output = shell_exec('D:/wamp64/www/createslideshow/ffmpeg-20190319-f8075b2-win64-static/bin/ffmpeg.exe '.$arguments);
Rick
  • 806
  • 7
  • 15
  • 1
    As my answer says, *These above need to be replaced with their values in the command.*. So if t1 is 4.5, then that's what you replace it with. – Gyan Mar 21 '19 at 15:24
  • Ugh, that was silly :) thanks – Rick Mar 23 '19 at 01:52

0 Answers0