Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Feature request: add watermark to video #6

Open
arifje opened this issue Mar 23, 2018 · 4 comments
Open

[FR] Feature request: add watermark to video #6

arifje opened this issue Mar 23, 2018 · 4 comments
Assignees

Comments

@arifje
Copy link
Contributor

arifje commented Mar 23, 2018

Sorry for the feature-request-spamming, got another idea for this great addon. We could definately use a watermark function! :-)

I used to have a script that added a watermark on top left, right or bottom left/right, and used different images for different video dimensions, so the size of the watermark was also in ratio with the size of the video.

So, it you let users upload these images, define the path and position in config (or as parameters!) it should be easy to implement. I'm sure you know how this all works, but here's a part of the code/idea. Maybe it will help you.

/ -----------------------------------------------
// video specs 
// -----------------------------------------------

$height = $video_data['height'];         
$width = $video_data['width'];   

// -----------------------------------------------
// determine logo dimension 
// -----------------------------------------------

$logo_1080 = '/path/to/logo_1080.png';
// etc.

if ($width >= 1900) {
    $logo_argument = $logo_1080;
} elseif ($width >= 1100 ) {
    $logo_argument = $logo_720;
} elseif ($width >= 800 ) {             
    $logo_argument = $logo_480;
} elseif ($width >= 600 ) {
    $logo_argument = $logo_360; 
} elseif ($width >= 350 || $width <= 380) { 
    $logo_argument = $logo_240;                       
    
// ----------------------------------------------
// logo offset                  
// ----------------------------------------------

$position = ' ';        

// increase offset for bigger videos (preseve offset ratio)

if($logo_offset_x > 0) {

    if ($width >= 1900) $logo_offset_x *= 5; // 1080p
    elseif ($width >= 1100 ) $logo_offset_x *= 3.5; // 720p
    elseif ($width >= 800 ) $logo_offset_x *= 2.5; // 480p
    elseif ($width >= 600 ) $logo_offset_x *= 2; // 360p
    elseif ($width >= 350 || $width <= 380) $logo_offset_x *=1; // 240p
}

if($logo_offset_y > 0) {       
    if ($width >= 1900) $logo_offset_y *= 5; // 1080p
    elseif ($width >= 1100 ) $logo_offset_y *= 3.5; // 720p
    elseif ($width >= 800 ) $logo_offset_y *= 2.5; // 480p
    elseif ($width >= 600 ) $logo_offset_y *= 2; // 360p
    elseif ($width >= 350 || $width <= 380) $logo_offset_y *=1; // 240p
}

$debug_string .= "[INFO] logo offset: " . $logo_offset_x . "/" . $logo_offset_y . "\n";

// ----------------------------------------------
// logo position
// ----------------------------------------------

$position = ' ';

switch($logo_position) {
    
    case 'top_left':
        $position = 'overlay=' . $logo_offset_x . ':' . $logo_offset_y;
    break;
    
    case 'top_right':       
        $position = 'overlay=main_w-overlay_w-' . $logo_offset_x . ':' . $logo_offset_y;
    break;
    
    case 'bottom_left': 
        $position = 'overlay=' . $logo_offset_x . ':main_h-overlay_h-' . $logo_offset_y;
    break;
    
    case 'bottom_right':
        $position = 'overlay=main_w-overlay_w-' . $logo_offset_x . ':main_h-overlay_h-' . $logo_offset_y;
    break;
    
    case 'center_middle':
        $position = 'overlay=main_w/2-overlay_w/2:main_h/2-overlay_h/2';
    break;
    
    default: 
        $position = 'overlay=main_w-overlay_w-' . $logo_offset_x . ':' . $logo_offset_y;
}   


// $position string is then added to the ffmpeg encode string / command
// example;  [watermark]; [in] [watermark] ' . $position . '

Cheers!

@khalwat
Copy link
Contributor

khalwat commented Mar 27, 2018

Ah great, yeah for sure adding a watermark is very doable!

@khalwat khalwat self-assigned this Mar 27, 2018
@arifje
Copy link
Contributor Author

arifje commented Jul 31, 2018

Hi mate, any chance these features will be integrated soon? Project seems a little bit quiet :-(

Thanks!

@khalwat
Copy link
Contributor

khalwat commented Jul 31, 2018

It's a little quiet because thankfully, there haven't been many bug reports, so we're left with enhancements/feature requests.

My plan is to finish porting Retour, and then circle back and look at FRs for plugins like this one.

@arifje
Copy link
Contributor Author

arifje commented Jul 31, 2018

Cool, thanks. And maybe you can look into the my recent pull request: #7 :-)

Thanks!!

@khalwat khalwat changed the title Feature request: add watermark to video [FR] Feature request: add watermark to video Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants