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?
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:vto set a good video bit-rate (eg:2500,3500or4000).Try: