
Recherche avancée
Autres articles (72)
-
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
Sur d’autres sites (8747)
-
PHP - Read and write the same file hangs
2 février 2016, par AdracatI’m trying to use FFMPEG to make some works with video on the server, and something I need to do is to get the progress of the process.
I searched a little and I found this solution which tells to write the log into a file and then reading and parsing it.
The problem
What is driving me crazy is that I tell FFMPEG - with
exec
- (process A) to write the log into a file, but when I try to read it - withfile_get_contents()
- (process B) it does not show the contents until process A is finished (or interrupted the PHP script).So, when process A finishes or it says "PHP script timeout", then I can read the file as times as I want, refreshing the page (process B) and showing the contents at the time.
What I’ve tried
I’ve tried to use
fopen()
to create the file withw
,w+
anda
parameters, using - and without using -fclose()
. I’ve tried to use alsoflock()
just in case it gets faster to read to process B if it knows it’s already locked and does not have to wait, but then FFMPEG is not able to write into the file.I’ve searched for multithreading too, but I think there must be an easier and simpler way.
I’ve used also CURL and HTTP context, as this link suggests, but no luck.
I’ve tried, too, to use PHP-FFMPEG but it’s not supporting the last FFMPEG version, so I cannot use it.
When I said before "(or interrupted the PHP script)" is because I tried to wait and, when PHP got a timeout, process B worked alright and the file was still updating.
The code
Process A (fileA.php)
exec('ffmpeg -y -i input_file.mp4 output_file.avi 2> C:\Full\Path\To\File\log.txt 1>&2');
Process B (fileB.php)
$content = file_get_contents($file);
if($content){
//get duration of source
preg_match("/Duration: (.*?), start:/", $content, $matches);
$rawDuration = $matches[1];
//rawDuration is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawDuration));
$duration = floatval($ar[0]);
if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;
//get the time in the file that is already encoded
preg_match_all("/time=(.*?) bitrate/", $content, $matches);
$rawTime = array_pop($matches);
//this is needed if there is more than one match
if (is_array($rawTime)){$rawTime = array_pop($rawTime);}
//rawTime is in 00:00:00.00 format. This converts it to seconds.
$ar = array_reverse(explode(":", $rawTime));
$time = floatval($ar[0]);
if (!empty($ar[1])) $time += intval($ar[1]) * 60;
if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;
//calculate the progress
$progress = round(($time/$duration) * 100);
echo "Duration: " . $duration . "<br />";
echo "Current Time: " . $time . "<br />";
echo "Progress: " . $progress . "%";
}The process
I just open
fileA.php
on a Chrome tab and, after a few seconds, I openfileB.php
on another Chrome tab (and it stays as loading).What I need
I need to be able to load the file and show the information I want to show while the file is being written (by
exec
andFFMPEG
or other PHP scripts), so I can update the progress percentage with some AJAX calls.Extra information
At this point, I’m using PHP 5.4 on a IIS 7.5 with Windows 7 Professional.
Thank you everyone for your time, help and patience !
Best regards.
-
OCPA, FDBR and TDPSA – What you need to know about the US’s new privacy laws
22 juillet 2024, par Daniel Crough -
Evolution #4493 (Nouveau) : Ajouter des robots à l’écran de sécurité
17 mai 2020Bonjour,
J’ai quelques sites qui ont des nombres de visites bizarres (trop grand, d’un facteur 10 à 30 certains jours).
J’ai fait un patch : https://git.spip.net/RealET/spip/commit/ce2ce832b697ab0754a78e0fc8b298ae1e9c992b
Mais je ne sais pas comment en faire un PR.Pour info, voici un extrait d’awstats pour le serveur concerné :
Pour info :
MJ12bot 2 241 164+29470 32.60 Go 17 Mai 2020 - 11:50
AhrefsBot 1 388 315+9242 28.07 Go 17 Mai 2020 - 11:50
SemrushBot 1 251 075+74309 23.91 Go 17 Mai 2020 - 11:50
bingbot 619 488+28872 22.38 Go 17 Mai 2020 - 11:50
DotBot 394 445+7038 22.52 Go 17 Mai 2020 - 11:50
Googlebot 297 801+35895 11.64 Go 17 Mai 2020 - 11:50
crawl 243 784+325 4.66 Go 17 Mai 2020 - 11:39
MegaIndex.ru 172 567+51 5.41 Go 17 Mai 2020 - 04:50
BLEXBot 161 178+4405 4.24 Go 17 Mai 2020 - 06:42
Applebot 136 660+2443 3.20 Go 17 Mai 2020 - 11:50
robot 129 533+3017 7.80 Go 17 Mai 2020 - 11:50
empty user agent string 117 782+778 6.55 Go 17 Mai 2020 - 11:49
Firefox version 10 and lower - various robots 106 252+366 1.87 Go 17 Mai 2020 - 11:50
qwantify 83 743+3013 3.61 Go 17 Mai 2020 - 11:50
Unknown robot identified by bot* 53 246+1846 2.25 Go 17 Mai 2020 - 11:37
spip 46 253 554.75 Mo 17 Mai 2020 - 11:50
link 44 510+567 761.38 Mo 17 Mai 2020 - 11:50
Googlebot-Image 36 704 1.24 Go 17 Mai 2020 - 11:48
facebookexternalhit 35 176+1 1.31 Go 17 Mai 2020 - 11:49
MSIE 6 - ( Rogue Robot ) 33 090 1.10 Go 17 Mai 2020 - 11:47
YandexBot 21 272+9245 822.57 Mo 17 Mai 2020 - 11:50
Unknown robot (identified by hit on robots.txt) 0+27213 98.21 Mo 17 Mai 2020 - 11:48
LinkpadBot 17 954 289.02 Mo 17 Mai 2020 - 06:46
infobot 15 038+1887 198.28 Mo 17 Mai 2020 - 04:19
MSIE 5 - ( Rogue Robot ) 16 110+1 980.04 Mo 17 Mai 2020 - 11:18
Sogou web spider 14 514+453 239.14 Mo 17 Mai 2020 - 11:49
ltx71 10 593+3663 378.89 Mo 17 Mai 2020 - 11:50
BingPreview 11 920 1.87 Go 17 Mai 2020 - 11:40
nbot 8 476+1023 230.66 Mo 17 Mai 2020 - 11:42
Apache-HttpClient 7 897+43 99.64 Mo 17 Mai 2020 - 11:01
Curl 7 752 151.93 Mo 17 Mai 2020 - 11:49
CFNetwork 7 313 779.65 Mo 17 Mai 2020 - 11:25
core 7 295+2 174.93 Mo 17 Mai 2020 - 11:35
oBot 7 064+230 338.14 Mo 17 Mai 2020 - 08:06
SeznamBot 3 677+3204 148.02 Mo 16 Mai 2020 - 22:36
twitterbot 4 264+2518 100.64 Mo 17 Mai 2020 - 11:44
panscient 6 298+397 97.66 Mo 17 Mai 2020 - 06:37
A PHP script 6 395 13.36 Mo 17 Mai 2020 - 11:50
archive.org_bot 4 917+385 157.65 Mo 17 Mai 2020 - 11:50
vagabondo 5 022+12 197.93 Mo 17 Mai 2020 - 09:58
Feedfetcher-Google 4 808 137.78 Mo 17 Mai 2020 - 11:41
zend_http_client 4 535 20.98 Mo 17 Mai 2020 - 11:34
ia_archiver 4 411+98 302.37 Mo 17 Mai 2020 - 03:58
feed 4 401 127.40 Mo 17 Mai 2020 - 11:45
dataprovider.com 4 003+167 169.38 Mo 17 Mai 2020 - 10:31
universalfeedparser 4 156 82.26 Mo 17 Mai 2020 - 11:36
Baidu ( catchall ) 3 956 260.02 Mo 17 Mai 2020 - 11:11
coccoc 1 509+2374 33.71 Mo 17 Mai 2020 - 10:37
python 3 607+87 54.82 Mo 17 Mai 2020 - 11:44
Mail.RU Bot 1 969+1492 177.25 Mo 17 Mai 2020 - 11:13