Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm attempting to draw text onto a video using either the avconv or ffmpeg commands. When specifying x= for where on the final video to place the text, the 'text_w' value is evaluating to 0, rather than the width of the rendered text as it should.

  • I'm using Ubuntu 12.04
  • I've got avconv version 0.8.3-4:0.8.3-0ubuntu0.12.04.1
  • and ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1

Example command:

avconv -i test.mov -vf "drawtext=fontfile='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf':text='test text':x=text_w:y=50:fontsize=24:fontcolor=black" texted.mov

This command causes the text to be printed as if x were set to 0.

What I'd really like to be able to do is center the text horizontally using something like this:

avconv -i test.mov -vf "drawtext=fontfile='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf':text='test text':x=(main_w-text_w)/2:y=50:fontsize=24:fontcolor=black" texted.mov

Using ffmpeg for to attempt the same ends with the same result

ffmpeg -i test.mov -vf "drawtext=fontfile='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf':text='test text':x=(main_w-text_w)/2:y=50:fontsize=24:fontcolor=black" texted.mov
share|improve this question
    
Not an expert on the filters, but have you tried in the latest version? It's at least at 0.11 now. –  slhck Jul 11 '12 at 15:05
1  
I don't understand the problem. The command you wrote: avconv -i test.mov -vf "drawtext=fontfile='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf':text='t‌​est text':x=(main_w-text_w)/2:y=50:fontsize=24:fontcolor=black" texted.mov works fine for me. –  abhshkdz Jul 11 '12 at 17:01
    
abhshkdz: The command does not error for me, but it does fail to center the text. The calculated x location is the same as if 'text_w' were replaced with 0. Is the text centered properly in your output video? Sounds like this could be a bug on this version. –  Chris White Jul 11 '12 at 20:21
    
Works for me using ffmpeg from FFmpeg (and not the fork that Ubuntu now uses): ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide. –  LordNeckbeard Jul 13 '12 at 18:27
    
Is anyone else able to confirm the bad behavior on the libav fork that Ubuntu uses? If this is recreatable I'd like to file a bug report. –  Chris White Jul 13 '12 at 18:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.