DrawText Not Drawing from top-left (0,0)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

DrawText Not Drawing from top-left (0,0)

dinizthiagobr
Hey,

So I`m trying a pretty common task, draw a text on the top-left of my video (0,0), but for some reason it draws on the top-right, and the text is written vertically for some reason, I want it to be written horizontally. Here`s the code I`m using (Xamarin Android):

            List<string> cmd = new List<string>();
            cmd.Add("-i");
            cmd.Add(GetPathToImage(this.ApplicationContext, videoUri));
            cmd.Add("-vcodec libx264 -acodec aac -strict -2 -ar 44100 -r 30");        
            cmd.Add("-vf");
            cmd.Add("scale=720:368,pad=750:398:15:15:white,drawtext=fontfile="+fontFilePath+":text=AAAA:x=0:y=0:fontsize=30:box=1");
            cmd.Add(croppedVideoPath);

Additionally, I`m using pad to create a white border on my video, but I want the top border to be bigger than the rest, how can I achieve that?

Thank you,
Reply | Threaded
Open this post in threaded view
|

Re: DrawText Not Drawing from top-left (0,0)

dinizthiagobr
I figured out the first issue, android's rotation metadata was screwing everything up, so I cleared all metadata then rotated accordingly to original rotation metadata

int rotationMetaData = System.Convert.ToInt32(m.ExtractMetadata(Android.Media.MetadataKey.VideoRotation));

if (rotationMetaData == 0)
                    cmd.Add("scale=640:640,pad=670:670:15:15:white,drawtext=fontfile=" + fontFilePath + ":text=" + _caption + ":x=15:y=15:fontsize=30:box=1");

if (rotationMetaData == 90)
                    cmd.Add("scale=640:640,transpose=1,pad=670:670:15:15:white,drawtext=fontfile=" + fontFilePath + ":text=" + _caption + ":x=15:y=15:fontsize=30:box=1");

Now looking to solve the second issue, I want the top border/pad to be bigger than the rest, couldn`t figure this one yet. :)
Reply | Threaded
Open this post in threaded view
|

Re: DrawText Not Drawing from top-left (0,0)

Moritz Barsnick
On Thu, Jan 19, 2017 at 14:31:30 -0800, dinizthiagobr wrote:
> I figured out the first issue, android's rotation metadata was screwing
> everything up, so I cleared all metadata then rotated accordingly to
> original rotation metadata

We might have figured it out, had you shown us the console output from
your command. There's so much useful information in it, honestly!

> cmd.Add("scale=640:640,transpose=1,pad=670:670:15:15:white,drawtext=fontfile="
> + fontFilePath + ":text=" + _caption + ":x=15:y=15:fontsize=30:box=1");
>
> Now looking to solve the second issue, *I want the top border/pad to be
> bigger than the rest*, couldn`t figure this one yet. :)

Well, what you're doing is padding something originally 640x640, and putting it on
a 670x670 canvas, with an offset of 15, which is exactly in the middle
((670-640)/2 = 15). If you want the top border to be larger, increase
the canvas and the offset, e.g.:
  "scale=640:640,transpose=1,pad=670:680:15:25"
or just put the overlay lower:
  "scale=640:640,transpose=1,pad=670:670:15:25"
It really depends on what you're trying to achieve (exactly).

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".