
Recherche avancée
Médias (3)
-
The Slip - Artworks
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (61)
-
Le plugin : Podcasts.
14 juillet 2010, parLe problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
Types de fichiers supportés dans les flux
Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Récupération d’informations sur le site maître à l’installation d’une instance
26 novembre 2010, parUtilité
Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)
Sur d’autres sites (6366)
-
Working on images asynchronously
To get my quota on buzzwords for the day we are going to look at using ZeroMQ and Imagick to create a simple asynchronous image processing system. Why asynchronous ? First of all, separating the image handling from a interactive PHP scripts allows us to scale the image processing separately from the web heads. For example we could do the image processing on separate servers, which have SSDs attached and more memory. In this example making the images available to all worker nodes is left to the reader.
Secondly, separating the image processing from a web script can provide more responsive experience to the user. This doesn’t necessarily mean faster, but let’s say in a multiple image upload scenario this method allows the user to do something else on the site while we process the images in the background. This can be beneficial especially in cases where users upload hundreds of images at a time. To achieve a simple distributed image processing infrastructure we are going to use ZeroMQ for communicating between different components and Imagick to work on the images.
The first part we are going to create is a simple “Worker” -process skeleton. Naturally for a live environment you would like to have more error handling and possibly use pcntl for process control, but for the sake of brewity the example is barebones :
-
< ?php
-
-
define (’THUMBNAIL_ADDR’, ’tcp ://127.0.0.1:5000’) ;
-
define (’COLLECTOR_ADDR’, ’tcp ://127.0.0.1:5001’) ;
-
-
class Worker {
-
-
private $in ;
-
private $out ;
-
-
public function __construct ($in_addr, $out_addr)
-
{
-
$context = new ZMQContext () ;
-
-
$this->in = new ZMQSocket ($context, ZMQ: :SOCKET_PULL) ;
-
$this->in->bind ($in_addr) ;
-
-
$this->out = new ZMQSocket ($context, ZMQ: :SOCKET_PUSH) ;
-
$this->out->connect ($out_addr) ;
-
}
-
-
public function work () {
-
while ($command = $this->in->recvMulti ()) {
-
if (isset ($this->commands [$command [0]])) {
-
echo "Received work" . PHP_EOL ;
-
-
$callback = $this->commands [$command [0]] ;
-
-
array_shift ($command) ;
-
$response = call_user_func_array ($callback, $command) ;
-
-
if (is_array ($response))
-
$this->out->sendMulti ($response) ;
-
else
-
$this->out->send ($response) ;
-
}
-
else {
-
error_log ("There is no registered worker for $command [0]") ;
-
}
-
}
-
}
-
-
public function register ($command, $callback)
-
{
-
$this->commands [$command] = $callback ;
-
}
-
}
-
?>
The Worker class allows us to register commands with callbacks associated with them. In our case the Worker class doesn’t actually care or know about the parameters being passed to the actual callback, it just blindly passes them on. We are using two separate sockets in this example, one for incoming work requests and one for passing the results onwards. This allows us to create a simple pipeline by adding more workers in the mix. For example we could first have a watermark worker, which takes the original image and composites a watermark on it, passes the file onwards to thumbnail worker, which then creates different sizes of thumbnails and passes the final results to event collector.
The next part we are going to create a is a simple worker script that does the actual thumbnailing of the images :
-
< ?php
-
include __DIR__ . ’/common.php’ ;
-
-
// Create worker class and bind the inbound address to ’THUMBNAIL_ADDR’ and connect outbound to ’COLLECTOR_ADDR’
-
$worker = new Worker (THUMBNAIL_ADDR, COLLECTOR_ADDR) ;
-
-
// Register our thumbnail callback, nothing special here
-
$worker->register (’thumbnail’, function ($filename, $width, $height) {
-
$info = pathinfo ($filename) ;
-
-
$out = sprintf ("%s/%s_%dx%d.%s",
-
$info [’dirname’],
-
$info [’filename’],
-
$width,
-
$height,
-
$info [’extension’]) ;
-
-
$status = 1 ;
-
$message = ’’ ;
-
-
try {
-
$im = new Imagick ($filename) ;
-
$im->thumbnailImage ($width, $height) ;
-
$im->writeImage ($out) ;
-
}
-
catch (Exception $e) {
-
$status = 0 ;
-
$message = $e->getMessage () ;
-
}
-
-
return array (
-
’status’ => $status,
-
’filename’ => $filename,
-
’thumbnail’ => $out,
-
’message’ => $message,
-
) ;
-
}) ;
-
-
// Run the worker, will block
-
echo "Running thumbnail worker.." . PHP_EOL ;
-
$worker->work () ;
As you can see from the code the thumbnail worker registers a callback for ‘thumbnail’ command. The callback does the thumbnailing based on input and returns the status, original filename and the thumbnail filename. We have connected our Workers “outbound” socket to event collector, which will receive the results from the thumbnail worker and do something with them. What the “something” is depends on you. For example you could push the response into a websocket to show immediate feeedback to the user or store the results into a database.
Our example event collector will just do a var_dump on every event it receives from the thumbnailer :
-
< ?php
-
include __DIR__ . ’/common.php’ ;
-
-
$socket = new ZMQSocket (new ZMQContext (), ZMQ: :SOCKET_PULL) ;
-
$socket->bind (COLLECTOR_ADDR) ;
-
-
echo "Waiting for events.." . PHP_EOL ;
-
while (($message = $socket->recvMulti ())) {
-
var_dump ($message) ;
-
}
-
?>
The final piece of the puzzle is the client that pumps messages into the pipeline. The client connects to the thumbnail worker, passes on filename and desired dimensions :
-
< ?php
-
include __DIR__ . ’/common.php’ ;
-
-
$socket = new ZMQSocket (new ZMQContext (), ZMQ: :SOCKET_PUSH) ;
-
$socket->connect (THUMBNAIL_ADDR) ;
-
-
$socket->sendMulti (
-
array (
-
’thumbnail’,
-
realpath (’./test.jpg’),
-
50,
-
50,
-
)
-
) ;
-
echo "Sent request" . PHP_EOL ;
-
?>
After this our processing pipeline will look like this :
Now, if we notice that thumbnail workers or the event collectors can’t keep up with the rate of images we are pushing through we can start scaling the pipeline by adding more processes on each layer. ZeroMQ PUSH socket will automatically round-robin between all connected nodes, which makes adding more workers and event collectors simple. After adding more workers our pipeline will look like this :
Using ZeroMQ also allows us to create more flexible architectures by adding forwarding devices in the middle, adding request-reply workers etc. So, the last thing to do is to run our pipeline and see the results :
Let’s create our test image first :
$ convert magick:rose test.jpg
From the command-line run the thumbnail script :
$ php thumbnail.php Running thumbnail worker..
In a separate terminal window run the event collector :
$ php collector.php Waiting for events..
And finally run the client to send the thumbnail request :
$ php client.php Sent request $
If everything went according to the plan you should now see the following output in the event collector window :
array(4) [0]=> string(1) "1" [1]=> string(56) "
/test.jpg" [2]=> string(62) " /test_50x50.jpg" [3]=> string(0) "" Happy hacking !
-
-
Evolution #2173 (Résolu) : Date de création / publication
13 janvier 2018, par nico d_J’ai ajouté la doc du plugin : https://contrib.spip.net/ecrire/?exec=article&id_article=4967
Pas encore publiée, mais je propose de fermer ce ticket dès qu’elle le sera, et de continuer la discussion sur le forum du plugin sur contrib.
-
Streaming Video from RTMP to EMGUCV
22 juillet 2017, par IsuruI’m trying to stream a webcam using RTMP to an EMGUCV project in order to process the video. I have set up a private RTMP server in a linux box using this tutorial,
https://obsproject.com/forum/resources/how-to-set-up-your-own-private-rtmp-server-using-nginx.50/I’m testing the webcam stream using ffmpeg with the following commands,
-
Write to the rtmp server using,
ffmpeg -y -f vfwcap -framerate 25 -video_size 640x480 -i 0 -an -f flv rtmp://rtmp-server:1935/live/stream
-
Read from the rtmp server using,
ffplay -fflags nobuffer rtmp ://rtmp-server:1935/live/stream -loglevel verbose
I’m able to write a simple OpenCV C++ application to read the stream and display it. Code below,
cv::VideoCapture vcap;
cv::Mat image;
const std::string videoStreamAddress = "rtmp://rtmp-server:1935/live/stream";
if(!vcap.open(videoStreamAddress)) {
printf("Error opening video stream or file");
return -1;
}
cv::namedWindow("Output Window");
cv::Mat edges;
for(;;) {
if(!vcap.read(image)) {
printf("No frame");
cv::waitKey();
}
cv::imshow("Output Window", image);
if(cv::waitKey(1) >= 0) break;
}
return 0;The above code works properly. However when I try it using EMGUCV C#, I get the error message
unable to create to capture from rtmp://rtmp-server:1935/live/stream
This is my C# Code,
public partial class MainForm : Form
{
private static Capture _cameraCapture;
public MainForm()
{
InitializeComponent();
Run();
}
void Run()
{
try
{
_cameraCapture = new Capture("rtmp://192.168.56.101:1935/live/stream");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return;
}
}
}Do I need a specific build of EMGUCV with FFMPEG or is RTMP capturing not available in EMGUCV ?
-