Adding a watermark to a video via ffmpeg


#41

How/where would I add this: error_log($shell) into the file code
to show info in PHP error log?


#42

That would do it, if that’s where your watermark.png file is located. As the ffpmeg command appears to require a complete path for the video file, it is reasonable to presume it will need a complete path for the watermark as well.


#43

Anywhere that you want to log the current value of that variable.


#44

Thank you for your replies. Can you give me an example of what you’re suggesting?


#45

I can’t really give you an example of the full path to the watermark file because I don’t know what it is on your installation. And if you know the full path, then you can put it into the command line directly.


#46

Thanks for your reply. Does this look correct, in regard to adding: error_log($shell)

            if ($video_res >= 854 || $video_res == 0) {
                error_log($shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path -i /home/user/public_html/watermark.jpg -filter_complex 'overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2' -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=854:-2 -crf 26 $video_output_full_path_480 2>&1"));
                $upload_s3 = PT_UploadToS3($filepath . "_480p_converted.mp4");
                $db->where('id', $insert);
                $db->update(T_VIDEOS, array(
                    '480p' => 1
                ));
            }

#47

@ChrisjChrisj I confess I’m not all that familiar with shell commands. What do each of these do?

-y -i -filter_complex -vcodec -preset -filter -crf


#48

Not to me, though I’ve never tried it. To my mind (and it seems the documentation agrees, on a cursory read) you need to just have a string as a parameter. I don’t know whether what you have done would work - what happens when you try it? The way I would have done it would be:

$shell = shell_exec(... all your stuff here  );
error_log("location comment" . $shell);

where "location comment" is just a note that will appear in the log to show what bit of code wrote the log - useful if you insert lots of log entries.

(ETA I’d have copied/pasted the actual code line for the first one, but since the recent forum software update I find it almost impossible to copy/paste from previous posts. So I’m not just being awkward, except perhaps in not wanting to change browser where it undoubtedly works better).


#49

I’m guessing -i marks the next parameter as being an input file, I haven’t used ffmpeg. It’ll all be stuff to control how the video is processed. codecs are something about coder/decoder, aren’t they?


#50

Thanks for all of your help