SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Video water mark ?

    I came across this article on water marking images with PHP, can this be done with videos as well with PHP, or an alternative language.

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    I did a simple test a while ago with a gif:
    PHP Code:
    <?php
    $animation 
    "morph.gif";

    $watermark "output.png";

    $watermarked_animation "morph.gif";

    $cmd $animation -coalesce -resize 100x200 -gravity South ".
    " -geometry +0+0 null: $watermark -layers composite -layers optimize ";

    exec("convert $cmd $watermarked_animation ");
    ?>

  3. #3
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What about other video formats ?

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    With PHP itself? No. You'll need something like ffmpeg to encode the video.
    This might help: http://www.linuxjournal.com/video/ad...k-video-ffmpeg
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    I would think this might need to be something the server does in scheduled batches. My familiarity with video codecs is limited, but I've not seen one that's quick or not memory intensive. I can't imagine this being feasible on a large scale without a lot more silicon than I'm familiar with managing.

  6. #6
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    What about other video formats ?
    I am afraid I have no idea but I would think as Michael says it would take quite a bit of processing.

  7. #7
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How does it work with images ? You upload the image and it's automatically placed in any custom location on the image ? If it works that beautiful, I may consider.

  8. #8
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Images are relatively simple. They are static. And the libraries needed to manipulate images are built into PHP.

    Videos are much, much different.

    Either you need to encode the video yourself with an encoding/conversion tool to add a watermark, or utilize ffmpeg with an exec command like Ruble posted.

    ffmpeg is usually a special request to add to a server. For shared hosting, hosts won't usually add it because it sucks up CPU time when in use and can slow down the other sites on the server. You'll typically need to be using dedicated server or VPS.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  9. #9
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't completely understand what you mean by a FFmpeg server ?

  10. #10
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,192
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    What are you trying to achieve? Probably the simplest and least time intensive approach in regards to work involved and processing time would be to have the user upload variable file formats themselves. That would completely alleviate the pain of needing to do it server side. However, the trade-off would be user error. So it depends on what needs to be a done and scale.
    The only code I hate more than my own is everyone else's.

  11. #11
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,435
    Mentioned
    82 Post(s)
    Tagged
    3 Thread(s)
    How does it work with images ? You upload the image and it's automatically placed in any custom location on the image ? If it works that beautiful, I may consider.
    My watermark examples are here:Watermark

    From what I understand FFmpeg is an external program that can be installed on a server and used using exec(). Imagemagick also uses it for some of its processes.

  12. #12
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I understand now. Making the server add a water mark to a video would be processor intensive. Adding a watermark to a image I'm going to think about


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •