Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I' going to add some text to a video segment using -vf but it doesn't work. Here is what I tried

avconv -ss 00:00:20 -i input.mp4 -t 00:00:10 -vcodec copy -acodec copy \
  -vf "drawtext=fontfile='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf':text='hello world':x=0:y=0:fontsize=24:fontcolor=black" output.mp4

But the text doesn't show up. I know that -t argument should appear after -i or the duration won't be set. I wonder if I misplace -vf in this case. Would anyone tell me how to make it?

P.S. I install it with apt-get install ffmpeg. Software info:

avconv version 0.8.9-6:0.8.9-0ubuntu0.13.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Nov  9 2013 19:09:48 with gcc 4.7.3
share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

In case we want to add text to our video using the drawtext filter we can not make use of the copy video codec.

Adding text to a video will change the video data. Therefore we have to re-encode the video stream using any codec other than copy.

share|improve this answer
    
If I remove -vcodec avconv will report an error "encoder 'aac' is experimental and might produce bad results. Add '-strict experimental' if you want to use it." Is it any mistakes I made during installation? –  neuront Mar 19 at 9:52
    
Your source may be aac encoded... you can choose any vcodec or acodec supported for re-encoding, or use the -target option for some defaults. See libav.org/avconv.html#Codec-AVOptions –  Takkat Mar 19 at 10:15
1  
In fact I didn't have libavcodec-extra-53 installed. After an apt-get it is now all right. –  neuront Mar 19 at 10:19
add comment

The following command worked for me:

avconv -i input.mp4 -vf "drawtext=fontfile='/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf':text='hello world':x=0:y=0:fontsize=24:fontcolor=black" output.mp4

tested on this mp4 sample file.

share|improve this answer
add comment

protected by Community Mar 19 at 11:29

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.