Copy video quality on FFmpeg

1

I want to use FFmpeg to add a watermark but I want the video will have the same quality. How do I do that?

I tried to use -vcodec copy -acodec copy but was without watermark:

ffmpeg -y -i treino.mp4 -vf "movie=logo.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]" -vcodec copy -acodec copy video2.mp4

Don Donllei

Posted 2016-06-21T16:29:34.027

Reputation: 13

How to get the original encoding information automatically and preset for the new file? – Don Donllei – 2016-06-21T17:03:04.960

Answers

4

You're using a filter, and filtering requires re-encoding, so you can't use -vcodec copy to stream copy the video. If you want the "same quality" then you'll need to use a lossless encoder:

ffmpeg -i video.mp4 -i image.png -filter_complex overlay -c:v libx264 -crf 0 -c:a copy -movflags +faststart output.mp4
  • The resulting file may be huge: this is expected for lossless outputs.

  • Your player or device may not be able to play the lossless file.

  • If you want a "visually lossless" output, which is not technically lossless but appears to be nearly so, then use -crf 18 instead of -crf 0.

  • No need for the movie source filter. Just add your overlay image as in input like any other file as shown in my example.

  • Since you're using PHP, I'll assume you're going to present the videos via progressive download. Add -movflags +faststart so it can begin playback before the file is completely downloaded.

llogan

Posted 2016-06-21T16:29:34.027

Reputation: 31 929