Author Topic: Video Clip same name on Server via FTP  (Read 1084 times)

0 Members and 1 Guest are viewing this topic.

Offline Simnm

  • Member
  • *
  • Posts: 8
    • Meteoso
Video Clip same name on Server via FTP
« on: December 09, 2017, 07:51:49 PM »
Hi, with BlueIris I have setting a camera for Record on Periodic, each 3 min for 5 sec . Combine or cut video each 1 min. So every 3 minutes, it sends the converted .mp4 file to my server via FTP. A file that is named with the name of the camera, the date and time.

Is it possible to have a file name always the same ? As for the JPEGs Post. I can display the photo on my weather web site, with a code that gets refreshed in 1 minute with the view of the new photo.

Or I have to use a code on my website that will display the latest send file in my server. But then how to automatically delete old videos ?

I found a code for the name of a specific video. If you would have the code to broadcast the last video recorded on the server, I would be grateful to you.

Thank
« Last Edit: December 10, 2017, 12:09:19 PM by Simnm »

Offline GregJ

  • Forecaster
  • *****
  • Posts: 946
    • http://www.SkunkBayWeather.com
Re: Video Clip same name on Server via FTP
« Reply #1 on: December 10, 2017, 11:11:15 AM »
I update videos and images every 2 minutes on my site along with all my weather data using ftp.  I have 3 cams and create a time lapse video from each at the top of every hour.  To simplify things I bought this package: https://www.scriptftp.com/ for $35.  The author was very helpful and it was well worth the money.

I run the script with Windows Task Scheduler on a 2 minute schedule.  This is what my script looks like:  (X's are used for username and password)
______________________________________________________________________________

OPENHOST("ftp.skunkbayweather.com","XXXXXXXXX","XXXXXXXXXX")

SYNC("C:\VWS\root","/public_html/",UPLOAD,"vws*.jpg")
SYNC("C:\VWS\root","/public_html/",UPLOAD,"*.htm")
SYNC("C:\VWS\root","/public_html/",UPLOAD,"*.html")
SYNC("C:\VWS\data\noaa","/public_html/",UPLOAD,"2017*.txt")
SYNC("C:\VWS\data\noaa","/public_html/",UPLOAD,"2018*.txt")

# ******************* Web Cam Updates ****************

# Cam 1 *******************
CHDIR("/public_html/Cam1")

# Time Lapse Videos
SYNC("\\Sbwcam1\c\WebcamVideo","/public_html/Cam1",UPLOAD,"Intraday_Video_1024x576_Cam1.mp4")
SYNC("\\Sbwcam1\c\WebcamVideo","/public_html/Cam1",UPLOAD,"Video_1024x576_Cam1.mp4")

# Create file for upload
EXEC("copy \\Sbwcam1\c\Webcam\WebCamImage\thumb1.jpg c:\FTPScripts\Cam1\Cam1_1024x576.jpg")
EXEC("copy \\Sbwcam1\c\Webcam\WebCamImage\olympusCam1.jpg c:\FTPScripts\Cam1\Cam1_1920x1080.jpg")

# Sync it...
SYNC("c:\FTPScripts\Cam1","/public_html/Cam1",UPLOAD,"Cam1_1024x576.jpg")
SYNC("c:\FTPScripts\Cam1","/public_html/Cam1",UPLOAD,"Cam1_1920x1080.jpg")

# Cam 2 *******************

CHDIR("/public_html/Cam2")

# Time Lapse Videos
SYNC("\\Sbwcam2\c\WebcamVideo","/public_html/Cam2",UPLOAD,"Intraday_Video_1024x576_Cam1.mp4")
SYNC("\\Sbwcam2\c\WebcamVideo","/public_html/Cam2",UPLOAD,"Video_1024x576_Cam1.mp4")

# Create file for upload
EXEC("copy \\Sbwcam2\c\Webcam\WebCamImage\thumb1.jpg c:\FTPScripts\Cam2\Cam2_1024x576.jpg")
EXEC("copy \\Sbwcam2\c\Webcam\WebCamImage\olympusCam1.jpg c:\FTPScripts\Cam2\Cam2_1920x1080.jpg")

# Sync it...
SYNC("c:\FTPScripts\Cam2","/public_html/Cam2",UPLOAD,"Cam2_1024x576.jpg")
SYNC("c:\FTPScripts\Cam2","/public_html/Cam2",UPLOAD,"Cam2_1920x1080.jpg")

# Cam 3 *******************

CHDIR("/public_html/Cam3")

# Time Lapse Videos
SYNC("\\HPDEV\c\WebcamVideo","/public_html/Cam3",UPLOAD,"Intraday_Video_1024x576_Cam1.mp4")
SYNC("\\HPDEV\c\WebcamVideo","/public_html/Cam3",UPLOAD,"Video_1024x576_Cam1.mp4")

# Create file for upload
EXEC("copy \\HPDEV\c\Webcam\WebCamImage\thumb1.jpg c:\FTPScripts\Cam3\Cam3_1024x576.jpg")
EXEC("copy \\HPDEV\c\Webcam\WebCamImage\olympusCam1.jpg c:\FTPScripts\Cam3\Cam3_1920x1080.jpg")

# Sync it...
SYNC("c:\FTPScripts\Cam3","/public_html/Cam3",UPLOAD,"Cam3_1024x576.jpg")
SYNC("c:\FTPScripts\Cam3","/public_html/Cam3",UPLOAD,"Cam3_1920x1080.jpg")

CLOSEHOST

____________________________________________________________________________________________

Hope this helps,
Greg

Davis VP2 with VWS

"Everybody talks about the weather, but nobody does anything about it." -- Mark Twain

Offline Simnm

  • Member
  • *
  • Posts: 8
    • Meteoso
Re: Video Clip same name on Server via FTP
« Reply #2 on: December 10, 2017, 12:07:37 PM »
Thank GregJ . You use BlueIris to create your images ?  If I fail to broadcast as I want, a video each 3 min for 5 sec. I will try your setup. Others have ideas ?
« Last Edit: December 10, 2017, 12:10:41 PM by Simnm »

Offline GregJ

  • Forecaster
  • *****
  • Posts: 946
    • http://www.SkunkBayWeather.com
Re: Video Clip same name on Server via FTP
« Reply #3 on: December 10, 2017, 01:10:57 PM »
I am using Sebectec to capture images and create the time lapse.  Sebectec / IPTimelapse has it's own ftp feature, but I had to consolidate it all into one session.  My webhost was blacklisting my IP because of too many concurrent ftp sessions.  Their firewall thought it was an attack.....

Greg
Davis VP2 with VWS

"Everybody talks about the weather, but nobody does anything about it." -- Mark Twain

Offline Simnm

  • Member
  • *
  • Posts: 8
    • Meteoso
Re: Video Clip same name on Server via FTP
« Reply #4 on: December 11, 2017, 12:37:55 PM »
I found on a site in French, a php script that displays the most recent photo created by a webcam in a folder on the web server. The camera creates a picture name like this:  00606E905560(Phoenix)_0_20110117220232_34.jpg

The code in French is this:   I translated in English below. But English is not my main language.

<?php
/**************************************/
/*    Date 18/01/2011   */
/* Affichage de la dernière image */
/*************************************/

// Tout les nomFichiers sont de titre:
// 00606E905560(Phoenix)_0_AAAAMMJJHHmmss_id.jpg 
// On récupère le nom des fichiers

// On ouvre le répertoire en question
$repertoire = 'webcam';
$dir = opendir($repertoire);

// On parcours les fichiers
// On veut localiser le plus récent
// On créer un tableau contenant le nom et la date
$i = 0;
while ($nomFichier = readdir($dir))
{
   if(($nomFichier != '..')&&($nomFichier !='.'))
   {
    //On change les permissions du fichier
    chmod($repertoire . '/' . $nomFichier,777);
    $annee = substr($nomFichier,24,4);
    $mois = substr($nomFichier,28,2);
    $jour = substr($nomFichier,30,2);
    $heure = substr($nomFichier,32,2);
    $minute = substr($nomFichier,34,2);
    $seconde = substr($nomFichier,36,2);
    $dateFichier[$i] = array('annee' => $annee, 'mois' => $mois, 'jour' => $jour, 'heure' => $heure, 'minute' => $minute, 'seconde' => $seconde, 'nom' => $nomFichier);
    $i++;
 }
}

// On ferme le répertoire
closedir($dir);

// Création des variables temporaires de comparaisons
$tmpAnnee = 0;
$tmpMois = 0;
$tmpJour = 0;
$tmpHeure = 0;
$tmpMinute = 0;
$tmpSeconde = 0;
$current = 0;

// Comparaisons des dates et récupération du nom du fichier le plus récent
foreach($dateFichier as $id => $tableau)
{
 foreach($tableau as $libelle => $valeur)
 {
  if($libelle != 'nom')
   $valeur = (integer)$valeur;
   
  switch($libelle)
  {
   case 'annee':
    if($valeur > $tmpAnnee)
    {
     $tmpAnnee = $valeur;
     $current = $tableau['nom'];
    }
    break;
   case 'mois':
    if(($tableau['annee'] == $tmpAnnee)&&($valeur > $tmpMois))
    {
     $tmpMois = $valeur;
     $current = $tableau['nom'];
    }
    break;
   case 'jour':
    if(($tableau['annee'] == $tmpAnnee)&&($tableau['mois'] == $tmpMois)&&($valeur > $tmpJour))
    {
     $tmpJour = $valeur;
     $current = $tableau['nom'];
    }
    break;
   case 'heure':
    if(($tableau['annee'] == $tmpAnnee)&&($tableau['mois'] == $tmpMois)&&($tableau['jour'] == $tmpJour)&&($valeur > $tmpHeure))
    {
     $tmpHeure = $valeur;
     $current = $tableau['nom'];
    }
    break;
   case 'minute':
    if(($tableau['annee'] == $tmpAnnee)&&($tableau['mois'] == $tmpMois)&&($tableau['jour'] == $tmpJour)&&($tableau['heure'] == $tmpHeure)&&($valeur > $tmpMinute))
    {
     $tmpMinute = $valeur;
     $current = $tableau['nom'];
    }
    break;
   case 'seconde':
    if(($tableau['annee'] == $tmpAnnee)&&($tableau['mois'] == $tmpMois)&&($tableau['jour'] == $tmpJour)&&($tableau['heure'] == $tmpHeure)&&&&($tableau['minute'] == $tmpMinute)($valeur > $tmpSeconde))
    {
     $tmpSeconde = $valeur;
     $current = $tableau['nom'];
    }
    break;
  }
 }
}

// On reouvre le répertoire
$dir = opendir($repertoire);

//On a récupérer le nom du fichier le plus récent, on le renomme current
while($Fichier = readdir($dir))
{
 if($Fichier == $current)
 {
  if(is_file('current.jpg'))
  {
   unlink('current.jpg');
   echo 'Fichier current.jpg existant supprimé';
  }

  if(rename($repertoire . '/' . $current,'current.jpg'))
  {
   echo 'Fichier ' . $current . ' renommé';
   $current = 'current.jpg';
   echo ' en ' . $current . '<br />';
  }

 }
 if(($Fichier != '..')&&($Fichier !='.')&&($Fichier!='current.jpg'))
 {
  unlink($nomFichier);
  echo 'Fichier ' . $Fichier . ' supprimé. <br />';
 }
}

//~ echo '<pre>';
//~ print_r($dateFichier);
//~ echo '</pre>';

// On referme le répertoire
closedir($dir);
// On commence par extraire l'année, puis les mois, les jours, les heures et enfins les minutes

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>La dernière image</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
 <div>
  <image src="webcam/current.jpg" alt="Dernière image en date" />
 </div>
</body>


////////////////////////////////////////////////

///////////////////////////////////////////////


In English

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
    <meta name="dcterms.created" content="lun., 11 déc. 2017 17:14:17 GMT">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title></title>
   
    <!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
  <body>
<?php
/**************************************/
/*    Date 18/01/2011   */
/* Publish last picture */
/*************************************/

// all picture name like this:
// 00606E905560(Phoenix)_0_YYYYMMDDHHmmss_id.jpg 
// We recover the name of the files

// We open the directory in question
$directory = 'webcam';
$dir = opendir($directory);

// We browse the files
// We want to locate the most recent
// Create a table with the name and date
$i = 0;
while ($namefile = readdir($dir))
{
   if(($filename != '..')&&($filename !='.'))
   {
    //We change the permissions of the file
    chmod($directory . '/' . $filename,777);
    $year = substr($filename,24,4);
    $month = substr($filename,28,2);
    $day = substr($filename,30,2);
    $hours = substr($filename,32,2);
    $minute = substr($filename,34,2);
    $seconde = substr($filename,36,2);
    $filedate[$i] = array('year' => $year, 'month' => $month, 'day' => $day, 'hours' => $hours, 'minute' => $minute, 'seconde' => $seconde, 'name' => $filename);
    $i++;
 }
}

// We close the directory
closedir($dir);

// Creating temporary variables for comparisons
$tmpYear = 0;
$tmpMonth = 0;
$tmpDay = 0;
$tmpHours = 0;
$tmpMinute = 0;
$tmpSeconde = 0;
$current = 0;

// Comparisons of dates and retrieval of the name of the most recent file
foreach($dateFichier as $id => $table)
{
 foreach($tableau as $libelle => $value)
 {
  if($libelle != 'name')
   $valeur = (integrate)$value;
   
  switch($libelle)
  {
   case 'year':
    if($valeur > $tmpYear)
    {
     $tmpYear = $value;
     $current = $table['name'];
    }
    break;
   case 'month':
    if(($tableau['year'] == $tmpYear)&&($valeur > $tmpMonth))
    {
     $tmpMois = $value;
     $current = $table['name'];
    }
    break;
   case 'day':
    if(($tableau['year'] == $tmpYear)&&($table['month'] == $tmpMonth)&&($value> $tmpDay))
    {
     $tmpJour = $value;
     $current = $table['name'];
    }
    break;
   case 'hours':
    if(($tableau['year'] == $tmpYear)&&($table['month'] == $tmpMonth)&&($table['day'] == $tmpDay)&&($value > $tmpHours))
    {
     $tmpHeure = $value;
     $current = $table['name'];
    }
    break;
   case 'minute':
    if(($tableau['year'] == $tmpYear)&&($table['month'] == $tmpMonth)&&($table['day'] == $tmpDay)&&($table['hours'] == $tmpHours)&&($value > $tmpMinute))
    {
     $tmpMinute = $value;
     $current = $table['name'];
    }
    break;
   case 'seconde':
    if(($tableau['year'] == $tmpYear)&&($table['month'] == $tmpMonth)&&($table['day'] == $tmpDay)&&($table['hours'] == $tmpHours)&&&&($table['minute'] == $tmpMinute)($value > $tmpSeconde))
    {
     $tmpSeconde = $value;
     $current = $table['name'];
    }
    break;
  }
 }
}

// We re-open the directory
$dir = opendir($directory);

//We get the name of the most recent file, we rename it current
while($File = readdir($dir))
{
 if($File == $current)
 {
  if(is_file('current.jpg'))
  {
   unlink('current.jpg');
   echo 'File current.jpg existing deleted';
  }

  if(rename($directory . '/' . $current,'current.jpg'))
  {
   echo 'File ' . $current . ' renowned';
   $current = 'current.jpg';
   echo ' en ' . $current . '<br />';
  }

 }
 if(($File != '..')&&($File !='.')&&($File!='current.jpg'))
 {
  unlink($FileName);
  echo 'File ' . $File . ' deleted. <br />';
 }
}

//~ echo '<pre>';
//~ print_r($dateFile);
//~ echo '</pre>';

// We close the directory
closedir($dir);
// We start by extracting the year, then the months, the days, the hours and the minutes

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The latest picture</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
 <div>
  <image src="webcam/current.jpg" alt="Last picture to date" />
 </div>
</body>
  </body>
</html>

Me the files are in the folder '' webcamlive "" . And the name of video file is Cam2.20171209_190109.mp4 '' and time is HHMMSS .
What's interesting is that it removes old files.

A similar code but for videos, that's what I want.

Thank
« Last Edit: December 11, 2017, 12:40:11 PM by Simnm »

Offline Simnm

  • Member
  • *
  • Posts: 8
    • Meteoso
Re: Video Clip same name on Server via FTP
« Reply #5 on: December 11, 2017, 02:45:07 PM »
After a few tries, I managed to configure Blue Iris to make a video that always has the same name. Problem solved.

 

anything