Folks, I am trying to add text to an mp4 file. Seems easy enough right? But once the new mp4 file is generated, the new file has half the width of the original file and is higher. It is almost like it switches the mp4 file from landscape to portrait? Here is the command I am using:

ffmpeg -i file01.mp4 -vf drawtext="text='Text Here': fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2: enable='between(t,20,30)'" -codec:a copy file01Text01.mp4

I then attempted to stop drawtext from distorting the video stream but this results in an error:

ffmpeg -i file01.mp4 -vf drawtext="text='Text Here': fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2: enable='between(t,20,30)'" -c copy file01Text01.mp4

Any help on seeing how I can modify the command so that the video width/height is not changed would be appreciated. Thank you.

  • drawtext cannot alter the video frame size. Your video is most likely portrait but stored as landscape with a rotation tag, and ffmpeg auto-rotates the video for you. Add -noautorotate before -i to avoid that. – Gyan Oct 9 at 14:28
  • Gyan, it worked fine. By any chance do you know how to change the video to landscape and remove the rotation tag? I still am having problems when I upload it to youtube. It again tries to put it in portrait. – Robert Smith Oct 9 at 18:27
  • Add -metadata:s:v rotate=0 before the output filename. – Gyan Oct 9 at 19:12

Gyan solved it: (see comment above)

drawtext cannot alter the video frame size. Your video is most likely portrait but stored as landscape with a rotation tag, and ffmpeg auto-rotates the video for you. Add -noautorotate before -i to avoid that.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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