Recherche avancée

Médias (91)

Autres articles (19)

  • Contribute to documentation

    13 avril 2011

    Documentation 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 (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

Sur d’autres sites (3550)

  • Perspective transformations

    9 juin 2010, par Mikko Koppanen — Imagick, PHP stuff

    Finally (after a long break) I managed to force myself to update the PHP documentation and this time it was distortImage code example. Things have been hectic lately but that does not quite explain the 6 months(?) break between this and the previous post. As a matter of a fact there is no excuse for such a long silence so I will try to update this blog a bit more often from now on.

    Back in the day I used to blog the examples and update the documentation if I remembered but I am trying to fix this bad habit. Most of the latest examples have been updated in to the manual. In the case of the two last examples I updated the documentation first and then blogged on the subject.

    I took some time to actually understand the perspective transformations properly using the excellent ImageMagick examples (mainly created by Anthony Thyssen) as a reference. The basic idea of perspective distortion seems simple : to distort the control points to new locations. Grabbing the syntax for Imagick was easy, an array of control point pairs in the form of :

    1. array(source_x, source_y, dest_x, dest_y ... )

    The following example uses the built-in checkerboard pattern to demonstrate perspective distortion :

    1. < ?php
    2. /* Create new object */
    3. $im = new Imagick() ;
    4.  
    5. /* Create new checkerboard pattern */
    6. $im->newPseudoImage(100, 100, "pattern:checkerboard") ;
    7.  
    8. /* Set the image format to png */
    9. $im->setImageFormat(’png’) ;
    10.  
    11. /* Fill background area with transparent */
    12. $im->setImageVirtualPixelMethod(Imagick: :VIRTUALPIXELMETHOD_TRANSPARENT) ;
    13.  
    14. /* Activate matte */
    15. $im->setImageMatte(true) ;
    16.  
    17. /* Control points for the distortion */
    18. $controlPoints = array( 10, 10,
    19.             10, 5,
    20.  
    21.             10, $im->getImageHeight() - 20,
    22.             10, $im->getImageHeight() - 5,
    23.  
    24.             $im->getImageWidth() - 10, 10,
    25.             $im->getImageWidth() - 10, 20,
    26.  
    27.             $im->getImageWidth() - 10, $im->getImageHeight() - 10,
    28.             $im->getImageWidth() - 10, $im->getImageHeight() - 30) ;
    29.  
    30. /* Perform the distortion */ 
    31. $im->distortImage(Imagick: :DISTORTION_PERSPECTIVE, $controlPoints, true) ;
    32.  
    33. /* Ouput the image */ 
    34. header("Content-Type : image/png") ;
    35. echo $im ;
    36.  ?>

    Here is the source image :
    checker before

    And the result :
    after

  • Node js async/await promise problem with ytdl and ffmpeg

    31 août 2020, par WorkoutBuddy

    I built a simple youtube downloader cli. It looks like this (without any arg parsing for easier reproduction) :

    &#xA;

    const ytdl = require(&#x27;ytdl-core&#x27;);&#xA;const config = require(&#x27;config&#x27;);&#xA;const progressBar = require(&#x27;./progressBar&#x27;);&#xA;const logger = require(&#x27;./logger&#x27;);&#xA;const ffmpeg = require(&#x27;fluent-ffmpeg&#x27;);&#xA;&#xA;const url = &#x27;https://www.youtube.com/watch?v=Np8ibIagn3M&#x27;;&#xA;&#xA;const getInfo = async (url) => {&#xA;    logger.info(`Getting metadata for ${url}`);&#xA;    const response = await ytdl.getBasicInfo(url);&#xA;    const info = response.videoDetails.title;&#xA;    logger.info(`Title: ${info}`);&#xA;    return info;&#xA;};&#xA;&#xA;const getStream = async (url) => {&#xA;    logger.info(`Downloading from ${url} ...`);&#xA;&#xA;    let allReceived = false;&#xA;    return new Promise((resolve, reject) => {&#xA;        const stream = ytdl(url, {&#xA;            quality: &#x27;highest&#x27;,&#xA;            filter: (format) => format.container === &#x27;mp4&#x27;,&#xA;        })&#xA;            .on(&#x27;progress&#x27;, (_, totalDownloaded, total) => {&#xA;                if (!allReceived) {&#xA;                    progressBar.start(total, 0, {&#xA;                        mbTotal: (total / 1024 / 1024).toFixed(2),&#xA;                        mbValue: 0,&#xA;                    });&#xA;                    allReceived = true;&#xA;                }&#xA;                progressBar.increment();&#xA;                progressBar.update(totalDownloaded, {&#xA;                    mbValue: (totalDownloaded / 1024 / 1024).toFixed(2),&#xA;                });&#xA;            })&#xA;            .on(&#x27;end&#x27;, () => {&#xA;                progressBar.stop();&#xA;                logger.info(&#x27;Successfully downloaded the stream!&#x27;);&#xA;            });&#xA;        return resolve(stream);&#xA;    });&#xA;};&#xA;&#xA;const convertToMp3 = async (stream, title) => {&#xA;    return new Promise((resolve, reject) => {&#xA;        ffmpeg({ source: stream })&#xA;            .output(`${config.get(&#x27;audioDir&#x27;)}/${title}.mp3`)&#xA;            .audioBitrate(&#x27;192k&#x27;)&#xA;            .run();&#xA;        return resolve();&#xA;    });&#xA;};&#xA;&#xA;const main = async (url) => {&#xA;    const info = await getInfo(url);&#xA;    console.log(&#x27;here 1&#x27;);&#xA;    const stream = await getStream(url);&#xA;    console.log(&#x27;here 2&#x27;);&#xA;    await convertToMp3(stream, info);&#xA;    console.log(&#x27;done&#x27;);&#xA;};&#xA;&#xA;main(url);&#xA;

    &#xA;

    The output looks like :

    &#xA;

    ➜ node youtube.js&#xA;info:    Getting metadata for https://www.youtube.com/watch?v=Np8ibIagn3M&#xA;info:    Title: Tu boca -  (Bachata Remix Dj Khalid)&#xA;here 1&#xA;info:    Downloading from https://www.youtube.com/watch?v=Np8ibIagn3M ...&#xA;here 2&#xA;done&#xA;[Progress] [████████████████████████████████████████] 100% | Downloaded: 7.15/7.15 MB | Elapsed Time: 5s&#xA;info:    Successfully downloaded the stream!&#xA;

    &#xA;

    However, I would expect this output :

    &#xA;

    ➜ node youtube.js&#xA;info:    Getting metadata for https://www.youtube.com/watch?v=Np8ibIagn3M&#xA;info:    Title: Tu boca -  (Bachata Remix Dj Khalid)&#xA;here 1&#xA;info:    Downloading from https://www.youtube.com/watch?v=Np8ibIagn3M ...&#xA;[Progress] [████████████████████████████████████████] 100% | Downloaded: 7.15/7.15 MB | Elapsed Time: 5s&#xA;here 2&#xA;info:    Successfully downloaded the stream!&#xA;done&#xA;

    &#xA;

    I think I have troubles to understand async/await. As far as I understood, promisifying a function allows me wait for the result. However, it seems that it does not work. I do not know why and how to properly debug it.

    &#xA;

    EDITED :

    &#xA;

    const getStream = async (url) => {&#xA;    logger.info(`Downloading from ${url} ...`);&#xA;&#xA;    let allReceived = false;&#xA;    return new Promise((resolve, reject) => {&#xA;        const stream = ytdl(url, {&#xA;            quality: &#x27;highest&#x27;,&#xA;            filter: (format) => format.container === &#x27;mp4&#x27;,&#xA;        })&#xA;            .on(&#x27;progress&#x27;, (_, totalDownloaded, total) => {&#xA;                console.log(&#x27;totalDownloaded: &#x27; &#x2B; totalDownloaded);&#xA;                if (!allReceived) {&#xA;                    console.log(&#x27;total: &#x27; &#x2B; total);&#xA;                    progressBar.start(total, 0, {&#xA;                        mbTotal: (total / 1024 / 1024).toFixed(2),&#xA;                        mbValue: 0,&#xA;                    });&#xA;                    allReceived = true;&#xA;                }&#xA;                progressBar.increment();&#xA;                progressBar.update(totalDownloaded, {&#xA;                    mbValue: (totalDownloaded / 1024 / 1024).toFixed(2),&#xA;                });&#xA;            })&#xA;            .on(&#x27;end&#x27;, () => {&#xA;                progressBar.stop();&#xA;                logger.info(&#x27;Successfully downloaded the stream!&#x27;);&#xA;                resolve(stream);&#xA;            });&#xA;    });&#xA;};&#xA;

    &#xA;

    But now it is like this :

    &#xA;

    ➜ node youtube.js&#xA;info:    Getting metadata for https://www.youtube.com/watch?v=Np8ibIagn3M&#xA;info:    Title: Tu boca -  (Bachata Remix Dj Khalid)&#xA;here 1&#xA;info:    Downloading from https://www.youtube.com/watch?v=Np8ibIagn3M ...&#xA;[Progress] [██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 14% | Downloaded: 1.02/7.15 MB | Elapsed Time: 52s&#xA;

    &#xA;

    Added console.log :

    &#xA;

    totalDownloaded: 16384&#xA;total: 7493903&#xA;[Progress] [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 0% | Downloaded: 0/7.15 MB | Elapsed Time: 0stotalDownloaded: 32768&#xA;totalDownloaded: 49152&#xA;totalDownloaded: 65536&#xA;totalDownloaded: 81920&#xA;totalDownloaded: 98304&#xA;totalDownloaded: 114688&#xA;totalDownloaded: 131072&#xA;totalDownloaded: 147456&#xA;totalDownloaded: 163840&#xA;totalDownloaded: 180224&#xA;totalDownloaded: 196608&#xA;totalDownloaded: 212992&#xA;totalDownloaded: 229376&#xA;totalDownloaded: 245760&#xA;totalDownloaded: 262144&#xA;totalDownloaded: 278528&#xA;totalDownloaded: 294912&#xA;totalDownloaded: 311296&#xA;totalDownloaded: 327680&#xA;totalDownloaded: 344064&#xA;totalDownloaded: 360448&#xA;totalDownloaded: 376832&#xA;totalDownloaded: 393216&#xA;totalDownloaded: 409600&#xA;totalDownloaded: 425984&#xA;totalDownloaded: 442368&#xA;totalDownloaded: 458752&#xA;totalDownloaded: 475136&#xA;totalDownloaded: 491520&#xA;totalDownloaded: 507904&#xA;totalDownloaded: 524288&#xA;totalDownloaded: 540672&#xA;totalDownloaded: 557056&#xA;totalDownloaded: 573440&#xA;totalDownloaded: 589824&#xA;totalDownloaded: 606208&#xA;totalDownloaded: 622592&#xA;totalDownloaded: 638976&#xA;totalDownloaded: 655360&#xA;totalDownloaded: 671744&#xA;totalDownloaded: 688128&#xA;totalDownloaded: 704512&#xA;totalDownloaded: 720896&#xA;totalDownloaded: 737280&#xA;totalDownloaded: 753664&#xA;totalDownloaded: 770048&#xA;totalDownloaded: 786432&#xA;totalDownloaded: 802816&#xA;totalDownloaded: 819200&#xA;totalDownloaded: 835584&#xA;totalDownloaded: 851968&#xA;totalDownloaded: 868352&#xA;totalDownloaded: 884736&#xA;totalDownloaded: 901120&#xA;totalDownloaded: 917504&#xA;totalDownloaded: 933888&#xA;totalDownloaded: 950272&#xA;totalDownloaded: 966656&#xA;totalDownloaded: 983040&#xA;totalDownloaded: 999424&#xA;totalDownloaded: 1015808&#xA;totalDownloaded: 1032192&#xA;totalDownloaded: 1048576&#xA;totalDownloaded: 1064960&#xA;[Progress] [██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 14% | Downloaded: 1.02/7.15 MB | Elapsed Time: 25s&#xA;

    &#xA;

  • Revision 34626 : l’ajout de par [34537] avait oublie un ...

    21 janvier 2010, par cedric@… — Log

    l’ajout de par pour englober le contenu principal de ...">[34537] avait oublie un