
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 (104)
-
Soumettre améliorations et plugins supplémentaires
10 avril 2011Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...) -
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" ; -
ANNEXE : Les plugins utilisés spécifiquement pour la ferme
5 mars 2010, parLe site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)
Sur d’autres sites (11948)
-
FFMPEG memory leak on FLV video frame decoding
10 août 2014, par Michael IVI am decoding FLV video on Windows using FFMPEG latest dev version(20140810) .Monitoring memory consumption of my program process I found the memory footprint constantly increasing.I do packet deallocation and also tried to delete and then reallocate the AVFrame anew on each decode.But it doesn’t help.I read on some threads people pointing out there is an internal memory leak in H264 decoder but I have seen no official confirmation of it nor any solution.
Here is how I decode a frame :AVPacket packet;
av_read_frame(_ifmt_ctx, &packet);
if (packet.stream_index == _in_video_stream->index)
{
int isGotVideoFrame = 0;
// Decode video frame
ret = avcodec_decode_video2(_dec_in_video_ctx, _src_video_frame,
&isGotVideoFrame, &packet);
if (1 == isGotVideoFrame)
{
sws_scale(_sws_ctx, (const uint8_t * const*) _src_video_frame->data,
_src_video_frame->linesize, 0,_inVideoHeight,
_dst_video_frame->data, _dst_video_frame->linesize);
uint8_t* dest = new uint8_t[_numBytes];
memcpy(dest, _dst_video_frame->data[0], _numBytes);
av_free_packet(&packet);
_frames_cache.push_back(dest);
}
av_frame_unref(_src_video_frame);
av_frame_free(&_src_video_frame);
_src_video_frame = av_frame_alloc();
}Then in another place on each frame I delete ’dest’ from the vector :
uint8_t * fr = _frames_cache.front();
_frames_cache.erase(_frames_cache.begin());
delete [] fr ; -
Track API calls in Node.js with Piwik
When using Piwik for analytics, sometimes you don’t want to track only your website’s visitors. Especially as modern web services usually offer RESTful APIs, why not use Piwik to track those requests as well ? It really gives you a more accurate view on how users interact with your services : In which ways do your clients use your APIs compared to your website ? Which of your services are used the most ? And what kind of tools are consuming your API ?
If you’re using Node.js as your application platform, you can use piwik-tracker. It’s a lightweight wrapper for Piwik’s own Tracking HTTP API, which helps you tracking your requests.
First, start with installing
piwik-tracker
as a dependency for your project :npm install piwik-tracker --save
Then create a new tracking instance with your Piwik URL and the site ID of the project you want to track. As Piwik requires a fully qualified URL for analytics, add it in front of the actual request URL.
var PiwikTracker = require('piwik-tracker');
// Initialize with your site ID and Piwik URL
var piwik = new PiwikTracker(1, 'http://mywebsite.com/piwik.php');
// Piwik works with absolute URLs, so you have to provide protocol and hostname
var baseUrl = 'http://example.com';
// Track a request URL:
piwik.track(baseUrl + req.url);Of cause you can do more than only tracking simple URLs : All parameters offered by Piwik’s Tracking HTTP API Reference are supported, this also includes custom variables. During Piwik API calls, those are referenced as JSON string, so for better readability, you should use
JSON.stringify({})
instead of manual encoding.piwik.track({
// The full request URL
url: baseUrl + req.url,
// This will be shown as title in your Piwik backend
action_name: 'API call',
// User agent and language settings of the client
ua: req.header('User-Agent'),
lang: req.header('Accept-Language'),
// Custom request variables
cvar: JSON.stringify({
'1': ['API version', 'v1'],
'2': ['HTTP method', req.method]
})
});As you can see, you can pass along arbitrary fields of a Node.js request object like HTTP header fields, status code or request method (GET, POST, PUT, etc.) as well. That should already cover most of your needs.
But so far, all requests have been tracked with the IP/hostname of your Node.js application. If you also want the API user’s IP to show up in your analytics data, you have to override Piwik’s default setting, which requires your secret Piwik token :
function getRemoteAddr(req) {
if (req.ip) return req.ip;
if (req._remoteAddress) return req._remoteAddress;
var sock = req.socket;
if (sock.socket) return sock.socket.remoteAddress;
return sock.remoteAddress;
}
piwik.track({
// …
token_auth: '<YOUR SECRET API TOKEN>',
cip: getRemoteAddr(req)
});As we have now collected all the values that we wanted to track, we’re basically done. But if you’re using Express or restify for your backend, we can still go one step further and put all of this together into a custom middleware, which makes tracking requests even easier.
First we start off with the basic code of our new middleware and save it as
lib/express-piwik-tracker.js
:// ./lib/express-piwik-tracker.js
var PiwikTracker = require('piwik-tracker');
function getRemoteAddr(req) {
if (req.ip) return req.ip;
if (req._remoteAddress) return req._remoteAddress;
var sock = req.socket;
if (sock.socket) return sock.socket.remoteAddress;
return sock.remoteAddress;
}
exports = module.exports = function analytics(options) {
var piwik = new PiwikTracker(options.siteId, options.piwikUrl);
return function track(req, res, next) {
piwik.track({
url: options.baseUrl + req.url,
action_name: 'API call',
ua: req.header('User-Agent'),
lang: req.header('Accept-Language'),
cvar: JSON.stringify({
'1': ['API version', 'v1'],
'2': ['HTTP method', req.method]
}),
token_auth: options.piwikToken,
cip: getRemoteAddr(req)
});
next();
}
}Now to use it in our application, we initialize it in our main
app.js
file :// app.js
var express = require('express'),
piwikTracker = require('./lib/express-piwik-tracker.js'),
app = express();
// This tracks ALL requests to your Express application
app.use(piwikTracker({
siteId : 1,
piwikUrl : 'http://mywebsite.com/piwik.php',
baseUrl : 'http://example.com',
piwikToken: '<YOUR SECRET API TOKEN>'
}));This will now track each request going to every URL of your API. If you want to limit tracking to a certain path, you can also attach it to a single route instead :
var tracker = piwikTracker({
siteId : 1,
piwikUrl : 'http://mywebsite.com/piwik.php',
baseUrl : 'http://example.com',
piwikToken: '<YOUR SECRET API TOKEN>'
});
router.get('/only/track/me', tracker, function(req, res) {
// Your code that handles the route and responds to the request
});And that’s everything you need to track your API users alongside your regular website users.
-
Track API calls in Node.js with Piwik
When using Piwik for analytics, sometimes you don’t want to track only your website’s visitors. Especially as modern web services usually offer RESTful APIs, why not use Piwik to track those requests as well ? It really gives you a more accurate view on how users interact with your services : In which ways do your clients use your APIs compared to your website ? Which of your services are used the most ? And what kind of tools are consuming your API ?
If you’re using Node.js as your application platform, you can use piwik-tracker. It’s a lightweight wrapper for Piwik’s own Tracking HTTP API, which helps you tracking your requests.
First, start with installing
piwik-tracker
as a dependency for your project :npm install piwik-tracker --save
Then create a new tracking instance with your Piwik URL and the site ID of the project you want to track. As Piwik requires a fully qualified URL for analytics, add it in front of the actual request URL.
var PiwikTracker = require('piwik-tracker');
// Initialize with your site ID and Piwik URL
var piwik = new PiwikTracker(1, 'http://mywebsite.com/piwik.php');
// Piwik works with absolute URLs, so you have to provide protocol and hostname
var baseUrl = 'http://example.com';
// Track a request URL:
piwik.track(baseUrl + req.url);Of cause you can do more than only tracking simple URLs : All parameters offered by Piwik’s Tracking HTTP API Reference are supported, this also includes custom variables. During Piwik API calls, those are referenced as JSON string, so for better readability, you should use
JSON.stringify({})
instead of manual encoding.piwik.track({
// The full request URL
url: baseUrl + req.url,
// This will be shown as title in your Piwik backend
action_name: 'API call',
// User agent and language settings of the client
ua: req.header('User-Agent'),
lang: req.header('Accept-Language'),
// Custom request variables
cvar: JSON.stringify({
'1': ['API version', 'v1'],
'2': ['HTTP method', req.method]
})
});As you can see, you can pass along arbitrary fields of a Node.js request object like HTTP header fields, status code or request method (GET, POST, PUT, etc.) as well. That should already cover most of your needs.
But so far, all requests have been tracked with the IP/hostname of your Node.js application. If you also want the API user’s IP to show up in your analytics data, you have to override Piwik’s default setting, which requires your secret Piwik token :
function getRemoteAddr(req) {
if (req.ip) return req.ip;
if (req._remoteAddress) return req._remoteAddress;
var sock = req.socket;
if (sock.socket) return sock.socket.remoteAddress;
return sock.remoteAddress;
}
piwik.track({
// …
token_auth: '<YOUR SECRET API TOKEN>',
cip: getRemoteAddr(req)
});As we have now collected all the values that we wanted to track, we’re basically done. But if you’re using Express or restify for your backend, we can still go one step further and put all of this together into a custom middleware, which makes tracking requests even easier.
First we start off with the basic code of our new middleware and save it as
lib/express-piwik-tracker.js
:// ./lib/express-piwik-tracker.js
var PiwikTracker = require('piwik-tracker');
function getRemoteAddr(req) {
if (req.ip) return req.ip;
if (req._remoteAddress) return req._remoteAddress;
var sock = req.socket;
if (sock.socket) return sock.socket.remoteAddress;
return sock.remoteAddress;
}
exports = module.exports = function analytics(options) {
var piwik = new PiwikTracker(options.siteId, options.piwikUrl);
return function track(req, res, next) {
piwik.track({
url: options.baseUrl + req.url,
action_name: 'API call',
ua: req.header('User-Agent'),
lang: req.header('Accept-Language'),
cvar: JSON.stringify({
'1': ['API version', 'v1'],
'2': ['HTTP method', req.method]
}),
token_auth: options.piwikToken,
cip: getRemoteAddr(req)
});
next();
}
}Now to use it in our application, we initialize it in our main
app.js
file :// app.js
var express = require('express'),
piwikTracker = require('./lib/express-piwik-tracker.js'),
app = express();
// This tracks ALL requests to your Express application
app.use(piwikTracker({
siteId : 1,
piwikUrl : 'http://mywebsite.com/piwik.php',
baseUrl : 'http://example.com',
piwikToken: '<YOUR SECRET API TOKEN>'
}));This will now track each request going to every URL of your API. If you want to limit tracking to a certain path, you can also attach it to a single route instead :
var tracker = piwikTracker({
siteId : 1,
piwikUrl : 'http://mywebsite.com/piwik.php',
baseUrl : 'http://example.com',
piwikToken: '<YOUR SECRET API TOKEN>'
});
router.get('/only/track/me', tracker, function(req, res) {
// Your code that handles the route and responds to the request
});And that’s everything you need to track your API users alongside your regular website users.