
Recherche avancée
Médias (2)
-
Granite de l’Aber Ildut
9 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
Autres articles (40)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
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 -
Contribute to documentation
13 avril 2011Documentation is vital to the development of improved technical capabilities.
MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
To contribute, register to the project users’ mailing (...)
Sur d’autres sites (5516)
-
ffmpeg/libav - how to wirte video files with valid pts
9 mai 2017, par Kai RohmerI’m currently trying the write out a real time rendered video into a h264 encoded file. After reading a lot of (mostly) old samples and the few class references they call a documentation, I manager to write my video file and I’m also able to read it. Unfortunately, I need some metadata for each frame but I’m not having a constant frame rate. So my intension was to start with the presentation timestamps to "frametime" during recoding. But after all I tried I get no pts while reading the the file (pts stays -9223372036854775808). Before wring a lot of code, here are the basics steps I’m doing. I’m probably using the wrong container or I’m missing to set a flag and you will notice it right away.
// open a AVFormatContext
avformat_alloc_output_context2(&m_FormatContext, nullptr, "avi", m_FileName.c_str());
// open a stream
m_VideoStream = avformat_new_stream(m_FormatContext, avcodec_find_encoder(AV_CODEC_ID_H264));
// setup the codec context (including bitrate, frame size, ...)
m_CodecContext = m_VideoStream ->codec;
m_CodecContext->coder_type = FF_CODER_TYPE_VLC;
m_CodecContext->time_base = AVRational{1, 120}; // I expect 20-60 Hz
m_CodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
m_CodecContext->color_range = AVCOL_RANGE_JPEG;
...
av_opt_set(m_CodecContext->priv_data, "preset", "ultrafast", 0);
av_opt_set(m_CodecContext->priv_data, "tune", "zerolatency,fastdecode", 0);
// set the same time_base to the stream
m_VideoStream ->time_base = m_CodecContext->time_base;
// open the codec
avcodec_open2(m_CodecContext, m_CodecContext->codec, nullptr);
// open file and write header
avio_open(&m_FormatContext->pb, m_FileName.c_str(), AVIO_FLAG_WRITE);
avformat_write_header(m_FormatContext, nullptr);
// then in a loop:
// render frame, convert RGBA to YUV frame, set the frames pts (timestamp is double application time in seconds)
frameToEncode.pts = int64_t(timestamp / av_q2d(m_VideoStream->time_base));
av_init_packet(m_EncodedPacket);
avcodec_encode_video2(m_CodecContext, m_EncodedPacket, frameToEncode, &got_output);
// check packet infos
//m_EncodedPacket->pts equals frameToEncode.pts
m_EncodedPacket->dts = AV_NOPTS_VALUE; // also tried incrementing numbers, or zero
m_EncodedPacket->stream_index = m_Stream->index;
m_EncodedPacket->duration = 0;
m_EncodedPacket->pos = -1;
m_EncodedPacket->flags = 0;
m_EncodedPacket->flags |= AV_PKT_FLAG_KEY; // read that somewhere
// write the packet to stream
av_interleaved_write_frame(m_FormatContext, m_EncodedPacket);
// after the loop
// I encode delayed frames and write the trailer
av_write_trailer(m_FormatContext);Thats pretty much it. I’m not getting what is missing. Since I have some meta data per frame I tried to add side data to each package but this data also disapered after reading from file. If decode the packets directly (instead of writing them to file, the data is there)
I’m quite sure the problem is with the encoding. I managed to decode the big buck bunny movie in which case i got valid pts values.
Thanks a lot for your help !
-
The complete guide on tracking your websites and web apps into multiple Piwiks and how to do it easily & efficiently
23 février 2017, par InnoCraft — Community, DevelopmentGetting the tracking of your website and apps right is crucial to your success as you need to ensure the measured data is meaningful and correct. That’s why we, at InnoCraft, help our clients setting up their web tracking and digital measurement strategy. Some challenges include tracking your analytics data into multiple Piwik services as well as the tracking of single-page websites and web applications (covered in a previous article). In this blog post, we explain how to track your data into multiple Piwik websites correctly.
Embedding the tracking code
First of all you need to embed your JavaScript tracking code into your website or app as usual. If you haven’t done this yet : Log in to your Piwik, click on “Administration” in the top right and go to “Tracking Code”. There you have various options to adjust your tracking code to your needs.
Tracking the same data into different websites
Let’s assume you have set up the regular JavaScript tracking code and you want to track the same data into a second Piwik website. This second Piwik website can be either on the same Piwik installation or on a different Piwik. To do this, add the following line to your tracking code :
_paq.push(['addTracker', 'https://$yourPiwikDomain/piwik.php', idSite]);
It should look like this :
var u = '//$yourPiwikDomain';
_paq.push(['addTracker', u + '/piwik.php', var idSite = 2]); // adds an additional tracker
_paq.push(['setSiteId', '1']); // configures your regular Piwik tracker
_paq.push(['setTrackerUrl', u + 'piwik.php']);This will track the same data into website 1 and website 2 of your Piwik installation. You can also change the domain in
addTracker
to point it to a different Piwik installation :_paq.push(['addTracker', '//$differentPiwikDomain/piwik.php', var idSite = 2]);
All Piwik tracker methods that you call afterwards will be applied to all trackers. Say you call
_paq.push(['disableCookies']); _paq.push(['trackPageView']);
, then both methods will be called on all tracker instances assuring they will behave the same and will track the same data into both Piwik websites.Tracking different data into different websites
If you want to track only certain data into one website, and different data into an additional website, you need to configure the trackers differently. For example, you want to enable link tracking only for one tracker, but not for the other. The problem is that calling
_paq.push(['enableLinkTracking']);
enables link tracking on all of your trackers. To workaround this limitation, you can configure your trackers differently like this :window.piwikAsyncInit = function () {
Piwik.on('TrackerSetup', function (tracker) {
if (tracker.getSiteId() == 2
|| tracker.getTrackerUrl() === '//$yourPiwikDomain/piwik.php') {
tracker.enableLinkTracking();
}
});
};Now it enables link tracking only for the tracker that is configured for a certain website ID or Piwik domain.
Accessing a previously generated tracker instance
When you configure a tracker via
_paq.push
, you create a so called “Async tracker” because Piwik will be loaded asynchronously and create the tracker instance as soon as it is loaded. If you need to get the instance of such a tracker, you can use the methodPiwik.getAsyncTracker(trackerUrl, idSite)
. This can be useful if you have a single-page website and want to track different data into different websites :window.addEventListener('hashchange', function() {
if ('undefined' === typeof Piwik) {
// Piwik might not be loaded yet
return;
}
var tracker1 = Piwik.getAsyncTracker('//$yourPiwikDomain/piwik.php', var idSite = 1);
var tracker2 = Piwik.getAsyncTracker('//$yourPiwikDomain/piwik.php', var idSite = 2);
tracker1.setCurrentUrl('/' + window.location.hash.substr(1));
tracker2.setCurrentUrl('/mywebsite/' + window.location.hash.substr(1));
});Tracking different data into multiple Piwik installations without using “_paq”
Some users prefer to not use
_paq.push
and instead directly create tracker instances themselves using the methodPiwik.getTracker(trackerUrl, idSite)
like this :window.piwikAsyncInit = function () {
var tracker1 = Piwik.getTracker('//$yourPiwikdomain/piwik.php', var idSite = 1);
tracker1.disableCookies();
var tracker2 = Piwik.getTracker('//$yourPiwikdomain/piwik.php', var idSite = 2);
tracker2.enableLinkTracking();
tracker1.trackPageView();
tracker2.trackPageView();
};We usually don’t recommend creating trackers manually as it is more complicated and you need to make sure to configure trackers in the right order. For example to prevent the setting of any cookies, it is recommended to call
disableCookies
before calling any other methods. If you want to create your trackers manually and you use any of the following methods, make sure to call them in this order :disableCookies(), setAPIUrl(), enableCrossDomainLinking(), setCookiePath(), setCookieDomain(), setDomains(), setUserId(), enableLinkTracking()
Roll-Up Reporting – the easy and efficient way
Often users track data into multiple websites because they need aggregated data over all their websites. They want to see all statistics for a single website, but also which pages were viewed across all their websites, or how much traffic they got from a specific website or search engine across all websites. This means they add a second tracker to all their websites and track data not only into the regular Piwik website, but also into one additional website that gives them statistics over all websites. This has several disadvantages :
- Complexity in getting the tracking code right and the time needed to integrate and maintain it
- Slower website performance because everything needs to be tracked into several websites. This can decrease your conversions and sales
- Slower Piwik performance because it has to handle twice as much traffic. This means tracking becomes slower, generating the report becomes slower, and the database gets twice as big
Luckily, there is a better solution called Roll-Up Reporting. With Roll-Up Reporting, you can get aggregated data over all websites and / or for a group of websites without any of these disadvantages. It lets you create as many Roll-Ups as you wish and you can choose which websites’ data should be aggregated together into a new website.
We had customers who were able to remove one Piwik tracker because of this feature which resulted in less server costs, a faster website, and a faster Piwik. On top of all these advantages, it also lets you view the Visitor Log, Real-time Map, and other widgets and reports across several websites.
Questions ?
If you got any questions, please let us know and get in touch with us. You can find more information about the Piwik JavaScript tracker on the Piwik Developer Zone. There is a section dedicated to Multiple Piwik Trackers.
-
How to track single-page websites and web applications using Piwik Analytics
21 février 2017, par InnoCraft — Community, DevelopmentSingle-page websites and web applications have become a standard over the last years. Getting the tracking of such websites and apps right is crucial to your success as you need to ensure the measured data is meaningful and correct. That’s why we, at InnoCraft, help our clients setting up their web tracking and measurement strategy. Some challenges our clients face are the tracking of single-page websites and web applications. We will cover this challenge in this post with a complete example at the bottom.
Embedding the Tracking Code
First you need to embed your JavaScript tracking code into your single-page website or web application as usual. To do this go to “Administration” in the top right in your Piwik, click on “Tracking Code” and adjust the tracking code to your needs.
Tracking a New Page View
The challenge begins when you need to track a new page view. A single-page app is different from a usual website as there is no regular new page load and Piwik cannot detect automatically when a new page is viewed. This means you need to let Piwik know whenever the URL and the page title changes. You can do this using the methods
setCustomUrl
andsetDocumentTitle
like this :window.addEventListener('hashchange', function() {
_paq.push(['setCustomUrl', '/' + window.location.hash.substr(1)']);
_paq.push(['setDocumentTitle', 'My New Title']);
_paq.push(['trackPageView']);
}Resetting previously set custom variables
If you have set any Custom Variables in scope “page”, you need to make sure to delete these custom variables again as they would be attributed to the new page view as well otherwise. The following code requires Piwik 3.0.2 :
_paq.push(['deleteCustomVariables', 'page']);
_paq.push(['trackPageView']);Updating the generation time
Next you need to update the generation time before tracking a new page view. Otherwise, the initial page generation time will be attributed to all of your subsequent pageviews.
If you don’t load new content from the server when the page changes, simply set the value to zero :
_paq.push(['setGenerationTimeMs', 0]);
_paq.push(['trackPageView']);In case you load new content from the server, we recommend to measure the time it took to load this content (in milliseconds) and set the needed time :
_paq.push(['setGenerationTimeMs', timeItTookToLoadPage]);
_paq.push(['trackPageView']);Updating the referrer
Depending on whether you want to track the previous page as a referrer for the new page view, you should update the referrer URL by setting it to the previous page URL :
_paq.push(['setReferrerUrl', previousPageUrl]);
_paq.push(['trackPageView']);Making Piwik Aware of New Content
When you show a new page, your single-page DOM might change as well. For example, you might replace parts of your page with new content that you loaded from your server via Ajax. This means you need to instruct Piwik to scan the DOM for new content. We’ll now go over various content types (Videos & Audio, Forms, Links and Downloads, Content tracking).
Video and Audio tracking
If you use the Media Analytics feature to track your videos and audios, whenever a new page is displayed you need to call the following method :
_paq.push(['MediaAnalytics::scanForMedia', documentOrElement]);
When you don’t pass any parameter, it will scan the entire DOM for new media. Alternatively, you can pass an element to scan only a certain area of your website or app for new media.
Form tracking
If you use the Form Analytics feature to measure the performance of your online forms, whenever a new page is displayed you need to call the following method :
_paq.push(['FormAnalytics::scanForForms', docuemntOrElement]);
Where
documentOrElement
points either todocument
to re-scan the entire DOM (the default when no parameter is set) or you can pass an element to restrict the re-scan to a specific area.Link tracking
Supposing that you use the link tracking feature to measure outlinks and downloads, Piwik needs to re-scan the entire DOM for newly added links whenever your DOM changes. To make sure Piwik will track such links, call this method :
_paq.push(['enableLinkTracking']);
Content tracking
If you use the Content Tracking feature, whenever a new page is displayed and some parts of your DOM changes, you need to call this method :
_paq.push(['trackContentImpressionsWithinNode', documentOrElement]);
Where
documentOrElement
points either todocument
or an element similar to the other methods. Piwik will then scan the page for newly added content blocks.Measuring Single-Page Apps : Complete Example
In this example we show how everything works together assuming you want to track a new page whenever a hash changes :
var currentUrl = location.href;
window.addEventListener('hashchange', function() {
_paq.push(['setReferrerUrl', currentUrl]);
currentUrl = '' + window.location.hash.substr(1);
_paq.push(['setCustomUrl', currentUrl]);
_paq.push(['setDocumentTitle', 'My New Title']);
// remove all previously assigned custom variables, requires Piwik 3.0.2
_paq.push(['deleteCustomVariables', 'page']);
_paq.push(['setGenerationTimeMs', 0]);
_paq.push(['trackPageView']);
// make Piwik aware of newly added content
var content = document.getElementById('content');
_paq.push(['MediaAnalytics::scanForMedia', content]);
_paq.push(['FormAnalytics::scanForForms', content]);
_paq.push(['trackContentImpressionsWithinNode', content]);
_paq.push(['enableLinkTracking']);
});Questions ?
If you have any questions or need help, please get in touch with us. You can find more information about the Piwik JavaScript tracker on the Piwik Developer Zone.