Recherche avancée

Médias (91)

Autres articles (88)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • Encodage et transformation en formats lisibles sur Internet

    10 avril 2011

    MediaSPIP transforme et ré-encode les documents mis en ligne afin de les rendre lisibles sur Internet et automatiquement utilisables sans intervention du créateur de contenu.
    Les vidéos sont automatiquement encodées dans les formats supportés par HTML5 : MP4, Ogv et WebM. La version "MP4" est également utilisée pour le lecteur flash de secours nécessaire aux anciens navigateurs.
    Les documents audios sont également ré-encodés dans les deux formats utilisables par HTML5 :MP3 et Ogg. La version "MP3" (...)

  • Monitoring de fermes de MediaSPIP (et de SPIP tant qu’à faire)

    31 mai 2013, par

    Lorsque l’on gère plusieurs (voir plusieurs dizaines) de MediaSPIP sur la même installation, il peut être très pratique d’obtenir d’un coup d’oeil certaines informations.
    Cet article a pour but de documenter les scripts de monitoring Munin développés avec l’aide d’Infini.
    Ces scripts sont installés automatiquement par le script d’installation automatique si une installation de munin est détectée.
    Description des scripts
    Trois scripts Munin ont été développés :
    1. mediaspip_medias
    Un script de (...)

Sur d’autres sites (14506)

  • Calculate in Node audio bitrate given bytes and duration and viceversa

    6 mai 2016, par loretoparisi

    Supposed to not have access to ffmpeg I need a simple way to calculate the bitrate of an audio (or video) file given media length (bytes) and duration (seconds), i.e. the function

    bitrate = MediaInfo.bitrate(bytes, duration);

    Also I need to do the opposite, so that given approximate media bitrate and length I need calculate the duration :

    duration = MediaInfo.duration(bytes, bitrate);

    So, this is my attempt, inspired by bitrate node module :

    var console = {
       log: function(s) {
         document.getElementById("console").innerHTML += s + "<br />"
       }
    }

    /**
    * Get media file info
    * @see https://www.npmjs.com/package/bitrate
    * * @author Loreto Parisi (loretoparisi at gmail dot com)
    */
    var MediaInfo = {

       /** unit divisors */
       DIVISORS : {
         bps: 0.125,
         kbps: 125,
         mbps: 125000,
         Bps: 1,
         KBps: 1000,
         MBps: 1000000
       },

       /**
        * Calcuate approximate bitrate
        * @param bytes integer media length in bytes
        * @param seconds float media duration
        * @param format string: bps|kbps|Bps|KBps|MBps
        * @param pos integer decimal approximation
       */
       bitrate : function(bytes, seconds, format, pos) {
               if (typeof format !== 'string') throw new TypeError('Expected \'format\' to be a string')
               format = format.replace('/', 'p')

         var divisor = this.DIVISORS[format];
               if (!divisor) throw new Error('\'format\' is an invalid string')
         var bitrate = bytes / seconds / divisor;
         pos=pos||4;

         return (Math.round(bitrate * Math.pow(10,pos)) / Math.pow(10,pos) );

       },

       /**
        * Calcuate approximate duration
        * @param bytes integer media length in bytes
        * @param bitrate float media bitrate per seconds
        * @param format string: bps|kbps|Bps|KBps|MBps
        * @param pos integer decimal approximation
       */
       duration : function(bytes, bitrate, format, pos) {
         if (typeof format !== 'string') throw new TypeError('Expected \'format\' to be a string')
               format = format.replace('/', 'p')

         var divisor = this.DIVISORS[format];
         if (!divisor) throw new Error('\'format\' is an invalid string')
         var seconds = bytes / bitrate / divisor;
         pos=pos||4;

         return (Math.round(seconds * Math.pow(10,pos)) / Math.pow(10,pos) );
       }
     } //MediaInfo

    // example of usage
     var bytes = 57511; // media file size in bytes
     var seconds = 20.35 // media file duration in seconds

     // calculate media bitrate given media length and duration
     var kilobitsPerSecond = MediaInfo.bitrate(bytes, seconds, 'kbps', 3) // => 326.3
     var bitsPerSecond = MediaInfo.bitrate(bytes, seconds, 'bps', 3) // => 326279
     var BytesPerSecond = MediaInfo.bitrate(bytes, seconds, 'Bps', 3) // => 40785

     // inverse: calculate media duration given media length and bitrate
     var duration = MediaInfo.duration(bytes, kilobitsPerSecond, 'kbps', 3);

     var data = {
         bytes : bytes,
         seconds : seconds,
         kilobitsPerSecond : kilobitsPerSecond + " kb/s",
         bitsPerSecond : bitsPerSecond + " b/s",
         BytesPerSecond : BytesPerSecond + " B/s",
         duration : duration
     }

     console.log( JSON.stringify(data, null, 2) );
    <div></div>

    The result media info are

    {
       "bytes": 57511,
       "seconds": 20.35,
       "kilobitsPerSecond": "22.609 kb/s",
       "bitsPerSecond": "22608.747 b/s",
       "BytesPerSecond": "2826.093 B/s",
       "duration": 20.35
    }

    while ffmpeg gives

    Duration: 00:00:20.35, start: 0.000000, bitrate: 22 kb/s
       Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 16 kb/s (default)

    Of course, the problem here is the assumption that I have a fixed bitrate when calculating the duration. But, is there any other way without having ffprobe or lame in node ?

  • ffmpeg error : Data doesn't look like RTP packets, make sure the RTP muxer is used

    29 juin 2016, par SOFuser

    I am trying to stream both video&audio from usbcam&mic throw ffmpeg over ffserver
    I got 2 errors :
    - ffmpeg seems functionning but showing "Data doesn’t look like RTP packets, make sure the RTP muxer is used"
    - i can connect to ffserver only for static files

    here is server.conf file :

    HTTPPort 1235
    RTSPPort 1234
    HTTPBindAddress 0.0.0.0
    MaxHTTPConnections 2000
    MaxClients 1000
    MaxBandwidth 100000
    #CustomLog –

    ########################################
    ##  static file for testing
    ########################################
    #HTTP requests
    <stream>
    File "/home/username/media.flv"
    Format flv
    </stream>

    #RTSP requests
    <stream>
    #preconverted file:
    File "/home/username/media.mpg"
    Format rtp
    VideoFrameRate 30
    VideoCodec libx264
    VideoSize 720x720
    StartSendOnKey
    Preroll 0
    </stream>

    ##################################################
    ## usb cam
    ###################################################
    <feed>
    File /tmp/test.ffm
    FileMaxSize 20K
    ACL allow 192.168.1.149
    </feed>

    <stream>
    Feed test.ffm
    Format rtp
    VideoFrameRate 25
    VideoCodec libx264
    VideoSize 720x720
    PreRoll 0
    StartSendOnKey
    </stream>

    my ffmpeg cmd is

    ffmpeg -s 720x720 -f video4linux2 -i /dev/video0 -r 25 -f alsa -i hw:0 -c:v libx264 -c:a aac -strict -2 rtp://192.168.1.149:1234/test.ffm

    it seems working but showing this error :

    "Data doesn’t look like RTP packets, make sure the RTP muxer is used"

    when i stream the static files it works
    but when i try to play usbcam stream throw ffplay and vlc nothing works

    thank you in advance,

  • How to estimate in Node audio bitrate, bytes, duration without ffmpeg

    6 mai 2016, par loretoparisi

    Supposed to not have access to ffmpeg I need a simple way to calculate the bitrate of an audio (or video) file given media length (bytes) and duration (seconds), i.e. the function

    bitrate = MediaInfo.bitrate(bytes, duration);

    Also I need to do the opposite, so that given approximate media bitrate and length I need calculate the duration :

    duration = MediaInfo.duration(bytes, bitrate);

    So, this is my attempt, inspired by bitrate node module :

    var console = {
       log: function(s) {
         document.getElementById("console").innerHTML += s + "<br />"
       }
    }

    /**
    * Get media file info
    * @see https://www.npmjs.com/package/bitrate
    * * @author Loreto Parisi (loretoparisi at gmail dot com)
    */
    var MediaInfo = {

       /** unit divisors */
       DIVISORS : {
         bps: 0.125,
         kbps: 125,
         mbps: 125000,
         Bps: 1,
         KBps: 1000,
         MBps: 1000000
       },

       /**
        * Calcuate approximate bitrate
        * @param bytes integer media length in bytes
        * @param seconds float media duration
        * @param format string: bps|kbps|Bps|KBps|MBps
        * @param pos integer decimal approximation
       */
       bitrate : function(bytes, seconds, format, pos) {
               if (typeof format !== 'string') throw new TypeError('Expected \'format\' to be a string')
               format = format.replace('/', 'p')

         var divisor = this.DIVISORS[format];
               if (!divisor) throw new Error('\'format\' is an invalid string')
         var bitrate = bytes / seconds / divisor;
         pos=pos||4;

         return (Math.round(bitrate * Math.pow(10,pos)) / Math.pow(10,pos) );

       },

       /**
        * Calcuate media bytes
        * @param bitrate float media bitrate per seconds
        * @param seconds float media duration
        * @param format string: bps|kbps|Bps|KBps|MBps
        * @param pos integer decimal approximation
       */
       bytes : function(bitrate, seconds, format) {
          if (typeof format !== 'string') throw new TypeError('Expected \'format\' to be a string')
          format = format.replace('/', 'p')

          var divisor = this.DIVISORS[format];
          if (!divisor) throw new Error('\'format\' is an invalid string')
          var bytes = bitrate * seconds * divisor;

          return ( Math.round(bytes) );

        }, //bytes

       /**
        * Calcuate approximate duration
        * @param bytes integer media length in bytes
        * @param bitrate float media bitrate per seconds
        * @param format string: bps|kbps|Bps|KBps|MBps
        * @param pos integer decimal approximation
       */
       duration : function(bytes, bitrate, format, pos) {
         if (typeof format !== 'string') throw new TypeError('Expected \'format\' to be a string')
               format = format.replace('/', 'p')

         var divisor = this.DIVISORS[format];
         if (!divisor) throw new Error('\'format\' is an invalid string')
         var seconds = bytes / bitrate / divisor;
         pos=pos||4;

         return (Math.round(seconds * Math.pow(10,pos)) / Math.pow(10,pos) );
       }
     } //MediaInfo

    // example of usage
     var bytes = 57511; // media file size in bytes
     var seconds = 20.35 // media file duration in seconds

     // calculate media bitrate given media length and duration
     var kilobitsPerSecond = MediaInfo.bitrate(bytes, seconds, 'kbps', 3) // => 326.3
     var bitsPerSecond = MediaInfo.bitrate(bytes, seconds, 'bps', 3) // => 326279
     var BytesPerSecond = MediaInfo.bitrate(bytes, seconds, 'Bps', 3) // => 40785

     // inverse: calculate media duration given media length and bitrate
     var duration = MediaInfo.duration(bytes, kilobitsPerSecond, 'kbps', 3);
     
     // estimated bytes length given bitrate and duration
     var estimatedBytes = MediaInfo.bytes(kilobitsPerSecond, duration, 'kbps', 3);

     var data = {
         bytes : bytes,
         seconds : seconds,
         kilobitsPerSecond : kilobitsPerSecond + " kb/s",
         bitsPerSecond : bitsPerSecond + " b/s",
         BytesPerSecond : BytesPerSecond + " B/s",
         duration : duration,
        estimatedBytes : estimatedBytes
     }

     console.log( JSON.stringify(data, null, 2) );
    <div></div>

    The result media info are

    {
     "bytes": 57511,
     "seconds": 20.35,
     "kilobitsPerSecond": "22.609 kb/s",
     "bitsPerSecond": "22608.747 b/s",
     "BytesPerSecond": "2826.093 B/s",
     "duration": 20.35,
     "estimatedBytes": 57512
    }

    while ffmpeg gives

    Duration: 00:00:20.35, start: 0.000000, bitrate: 22 kb/s
       Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 16 kb/s (default)

    Of course, the problem here is the assumption that I have a fixed bitrate when calculating the duration. But, is there any other way without having ffprobe or lame in node ?

    Note. A good options, where the media file has ID3 tagging, is to use the JSMediaTags node module that supports ID3 and MP4 tagging for media files and works both in the browser that in node :

    var jsmediatags = require("jsmediatags");
    jsmediatags.read("./music-file.mp3", {
     onSuccess: function(tag) {
       console.log(tag);
     },
     onError: function(error) {
       console.log(':(', error.type, error.info);
     }
    });

    This will not work for streaming media files or for files coming from direct audio sources of course.