[FFmpeg-user] drawtext so that it cover whole page

anshul anshul.ffmpeg at gmail.com
Mon Jan 27 12:40:05 CET 2014


On 01/27/2014 05:08 PM, anshul wrote:
> On 01/27/2014 04:04 PM, anshul wrote:
>> On 01/27/2014 03:52 PM, Carl Eugen Hoyos wrote:
>>> anshul <anshul.ffmpeg <at> gmail.com> writes:
>>>
>>>> I want to use  drawtext filter of ffmpeg so that my
>>>> fontsize is automatically increased in such a way,
>>>> so that it cover whole frame.
>>> What happens if you set the video height as fontsize?
>>>
>>> Carl Eugen
>>>
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> ffmpeg-user at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>> If i set fontsize as some percentage of video  height, then it would 
>> work only for single word not for paragraphs
>>
>> I am looking for solution for paragraphs, just now my code is too 
>> dirty it works some time but
>> also fails many time, since I have not consider actual rndered height 
>> but it I am considering max_glyph_w max_glyph_h
>> for a particular font on basis of font size
>>
>> If anyone interested, this is some part of my code in python
>>
>>     //arialbd character have 4/3 w/h ratio
>>     font_size = int(math.sqrt( (w*h*4)/ (len(istr) *3) ))
>>
>>         if mlen > (w/font_size):
>>             font_size = w/mlen
>>
>>         line_split = 2*(w/font_size)
>>         font_size = str(font_size)
>>         out_word = ""
>>         sword = ""
>>         num_lines = 1
>>         for word in istr.split(" "):
>>             if len(sword + word) > line_split:
>>                 out_word = out_word + sword + "\f"
>>                 sword = word
>>                 num_lines += 1
>>             else:
>>                 sword = sword + " " + word
>>         out_word = out_word + sword
>>
>>
>>
>>
>> Thanks
>> Anshul
> Hi
>
> I have generated the code to wrap all the text according aspect ratio 
> in C++
>     std::string test_str = "String geometry\n\nThis is a long string 
> meant to display in a"
>             "in One Frame. Some lines are very long, and then again 
> there are paragraph"
>             "breaks.\n\nThe text widget shall wrap words, but be 
> neither too big nor too"
>             "small, and have a pleasing aspect ratio (say, in pixels, 
> 4:3 or 8:3).";
>
>     int nl_count = 0;
>     double test_len = (double)test_str.length();
>
>     double w0 = 0;
>     double h0 = 0;
>
>
>     for(unsigned int i =0;i<test_str.length();i++)
>     {
>         if(test_str.at(i) == '\n')
>             nl_count++;
>     }
>
>     w0 = round(8.0/3.0 * sqrt(test_len));
>     h0 = round(3.0/8.0 * sqrt(test_len)) + nl_count;
>
>     std::cout <<w0<<"\t"<<h0<<std::endl;
>
> if any one think that it would be good idea to add one more flag of 
> autofit text on image in draw text filter
> I could change this code to fit the need of convention of ffmpeg.
>
> any way if some one else want to use the drawtext in autofit way he 
> can use this code, and ratio of h0 and videoheight
>
> Thanks
> Anshul
>
please excuse me for my 3 mails, there is some kind of problem in my 
thunderbird, it sending mail instead of saving in drawft




More information about the ffmpeg-user mailing list