Hi I am trying to do the equivalent of
ffmpeg -i video.mp4 -vf \
drawtext="fontfile=LucidaGrande.ttc: \
text='THIS IS TEXT':fontsize=20:fontcolor=white:x=(main_w/2-text_w/2):y=100: shadowcolor=black:shadowx=2:shadowy=2" \
with_text3.mp4
I have tried
.videoFilters([drawtext="LucidaGrande.ttc: text='THIS IS TEXT':fontsize=20:fontcolor=white:x=(main_w/2-text_w/2):y=50:shadowcolor=black:shadowx=2:shadowy=2"])
but i get "ffmpeg exited with code 1: Error opening filters!"
is there another method i should be using?
For more info about the error please give the full ffmpeg output:
command.on('error', function(err, stdout, stderr) {
console.log('error: ' + err.message);
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
});
Most likely you have an escaping error in your filter string. Try using a filter spec object instead:
command.videoFilters({
filter: 'drawtext',
options: {
fontfile: 'Lucida Grande.ttf',
text: 'THIS IS TEXT',
/* etc. */
}
});
ya that looks like it. Thanks for your prompt response!
The top line is what I am feeding in, but looks like single quotes being stripped.
drawtext="fontfile=/vagrant/fonts/LucidaGrande.ttc: text='THIS IS TEXT':fontsize=20:fontcolor=white:x=(main_w/2-text_w/2):y=50:shadowcolor=black:shadowx=2:shadowy=2"
error: ffmpeg exited with code 1: Error opening filters!
stdout:
stderr: ffmpeg version 1.2.6-7:1.2.6-1~trusty1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 18:52:58 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --arch=amd64 --disable-stripping --enable-avresample --enable-pthreads --enable-runtime-cpudetect --extra-version='7:1.2.6-1~trusty1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 53. 5.103 / 53. 5.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/vagrant/app/storage/032a63a5-619e-4304-96c1-a7cbc3bb0a87/temp/video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.63.104
Duration: 00:00:02.25, start: 0.000000, bitrate: 1380 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p, 956x474, 1377 kb/s, 8 fps, 8 tbr, 16384 tbn, 16 tbc
Metadata:
handler_name : VideoHandler
[drawtext @ 0x1c817c0] Key '"fontfile' not found.
[AVFilterGraph @ 0x1c719e0] Error initializing filter 'drawtext' with args '"fontfile=/vagrant/fonts/LucidaGrande.ttc: text=THIS IS TEXT:fontsize=20:fontcolor=white:x=(main_w/2-text_w/2):y=50:shadowcolor=black:shadowx=2:shadowy=2"'
Error opening filters!
Yeah, the problem is most likely due to double quotes. You don't need those outside of your shell. But for a more pleasant experience, I still recommend using filter spec objects :)
will do, also seeing that '"fontfile' not found?
Because double quotes are passed to ffmpeg when you're not in the shell. The filter engine looks for an option named "fontfile in the filter and does not find it, I guess.
got it, and yes this works. Thanks again!
.videoFilters({
filter: 'drawtext',
options: {
fontfile:'/vagrant/fonts/LucidaGrande.ttc',
text: 'THIS IS TEXT',
fontsize: 20,
fontcolor: 'white',
x: '(main_w/2-text_w/2)',
y: 50,
shadowcolor: 'black',
shadowx: 2,
shadowy: 2
}
})
Most helpful comment
got it, and yes this works. Thanks again!