Text Watermarking on video without loss of audio and video quality

700 Views Asked by At

I am using following command to add text watermark on a video file(for mp4, mpg,m4v,flv,mov etc..):

ffmpeg -i input.mp4 -vf "drawtext=text='Opentext':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" TextOutput.mp4

For some of the file transformation the property of video file changes. for example- When I tried to add text watermark on a mkv file I got this message:

[matroska @ 0000001867d36ec0] Non-monotonous DTS in output stream 0:1; previous: 2273, current: 1596; changing to 2273. This may result in incorrect timestamps in the output file.

This is one of the issues, i have mentioned here. There are others as well, such as:

  • video quality is reduced
  • video file size is changed(increses/decreases drastically)
  • Audio lagging occurs etc...

So, I want to preserve the quality of video after adding the text watermark. How can I do that?

1

There are 1 best solutions below

2
VC.One On

Use -crf (constant rate factor) to improve picture quality.
Lower number is higher quality (where possible) but with slower encoding time. Test a good number.

Also use b:v to set a good video bit-rate (eg: 2500, 3500 or 4000).

Try:

ffmpeg -i input.mp4 -vf "drawtext=text='Opentext':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" -c:v libx264 -pix_fmt yuv420p -crf 20 -c:a copy TextOutput.mp4