All posts by PF

How to get the MAC address from Linux with PHP?

MAC address from Linux with PHP

<?php
function getMacLinux() {
  exec('netstat -ie', $result);
  if(is_array($result)) {
    $iface = array();
    foreach($result as $key => $line) {
      if($key > 0) {
        $tmp = str_replace(" ", "", substr($line, 0, 10));
        if($tmp <> "") {
          $macpos = strpos($line, "HWaddr");
          if($macpos !== false) {
            $iface[] = array('iface' => $tmp, 'mac' =>strtolower(substr($line, $macpos+7, 17)));
          }
        }
      }
    }
    return $iface[0]['mac'];
  } else {
    return "notfound";
  }
}

?>

Found it on http://www.zimplicit.se/en/knowledge/how-get-mac-address-linux-php

ffmpeg – watermark positions

This are the command lines that I use to add the watermark picture named watermark.png on the video named source.avi and export to output.flv.

Tested on a DigitalOcean Virtual server! 😉

rock ssd

The 10 values are the paddings!

Top left
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=10:10 [out]" output.flv

Top right
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" output.flv

Bottom left
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]" output.flv

Bottom right
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" output.flv

Center?
ffmpeg –i source.avi -vf “movie=watermark.png [watermark]; [in][watermark] overlay=main_w/2-overlay_w/2:main_h/2-overlay_h/2 [out]” output.flv

 

UPDATE

If you get this error…

[NULL @ 0x45fd680] Unable to find a suitable output format for '–i'
–i: Invalid argument

try something like…

ffmpeg -i 'video-source.mp4' -i /watermark/path/image.png -filter_complex "overlay=main_w-overlay_w-10:main_h-overlay_h-10" -c:v libx264 -vsync 2 -strict -2 /output/video.mp4

The Node Pole

About The Node Pole

The Node Pole region encompasses the municipalities Luleå, Boden and Piteå in the very north of Sweden, just by the Arctic Circle. The region has the epithet The Node Pole due to its northern position and potential to become a global hub for data traffic.

The Node Pole holds perfect conditions to create bespoke construction solutions for high tech, electricity intensive construction such as data centers. In addition to having an extremely stable electricity infrastructure, The Node Pole region provides natural cooling and renewable hydropower with low energy costs. It is also one of the most geologically, politically and socially stable areas in the world. The Node Pole is owned by the three municipalities, Luleå Business Agency and other regional business organizations.

Continue reading The Node Pole

Retrieve all links from a html page/file with PHP

 

$html = file_get_contents('path/to/file.html');
// Create a new DOM document
$dom = new DOMDocument;

// Parse the HTML. Use the @ to avoid any parsing errors if the $html string isn't valid XHTML
@$dom->loadHTML($html);

// Get all links 'a' we can use also 'img', 'li, 'table', etc to extract other tags.
$links = $dom->getElementsByTagName('a');

foreach ($links as $link){
    echo $link->nodeValue;
    // Full node
    echo $link->getAttribute('href'), '<br />';
    // the link itself
}