Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (59)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

  • Mediabox : ouvrir les images dans l’espace maximal pour l’utilisateur

    8 février 2011, par

    La visualisation des images est restreinte par la largeur accordée par le design du site (dépendant du thème utilisé). Elles sont donc visibles sous un format réduit. Afin de profiter de l’ensemble de la place disponible sur l’écran de l’utilisateur, il est possible d’ajouter une fonctionnalité d’affichage de l’image dans une boite multimedia apparaissant au dessus du reste du contenu.
    Pour ce faire il est nécessaire d’installer le plugin "Mediabox".
    Configuration de la boite multimédia
    Dès (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-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

Sur d’autres sites (7262)

  • Things I Have Learned About Emscripten

    1er septembre 2015, par Multimedia Mike — Cirrus Retro

    3 years ago, I released my Game Music Appreciation project, a website with a ludicrously uninspired title which allowed users a relatively frictionless method to experience a range of specialized music files related to old video games. However, the site required use of a special Chrome plugin. Ever since that initial release, my #1 most requested feature has been for a pure JavaScript version of the music player.

    “Impossible !” I exclaimed. “There’s no way JS could ever run fast enough to run these CPU emulators and audio synthesizers in real time, and allow for the visualization that I demand !” Well, I’m pleased to report that I have proved me wrong. I recently quietly launched a new site with what I hope is a catchier title, meant to evoke a cloud-based retro-music-as-a-service product : Cirrus Retro. Right now, it’s basically the same as the old site, but without the wonky Chrome-specific technology.

    Along the way, I’ve learned a few things about using Emscripten that I thought might be useful to share with other people who wish to embark on a similar journey. This is geared more towards someone who has a stronger low-level background (such as C/C++) vs. high-level (like JavaScript).

    General Goals
    Do you want to cross-compile an entire desktop application, one that relies on an extensive GUI toolkit ? That might be difficult (though I believe there is a path for porting qt code directly with Emscripten). Your better wager might be to abstract out the core logic and processes of the program and then create a new web UI to access them.

    Do you want to compile a game that basically just paints stuff to a 2D canvas ? You’re in luck ! Emscripten has a porting path for SDL. Make a version of your C/C++ software that targets SDL (generally not a tall order) and then compile that with Emscripten.

    Do you just want to cross-compile some functionality that lives in a library ? That’s what I’ve done with the Cirrus Retro project. For this, plan to compile the library into a JS file that exports some public functions that other, higher-level, native JS (i.e., JS written by a human and not a computer) will invoke.

    Memory Levels
    When porting C/C++ software to JavaScript using Emscripten, you have to think on 2 different levels. Or perhaps you need to force JavaScript into a low level C lens, especially if you want to write native JS code that will interact with Emscripten-compiled code. This often means somehow allocating chunks of memory via JS and passing them to the Emscripten-compiled functions. And you wouldn’t believe the type of gymnastics you need to execute to get native JS and Emscripten-compiled JS to cooperate.

    “Emscripten : Pointers and Pointers” is the best (and, really, ONLY) explanation I could find for understanding the basic mechanics of this process, at least when I started this journey. However, there’s a mistake in the explanation that left me confused for a little while, and I’m at a loss to contact the author (doesn’t anyone post a simple email address anymore ?).

    Per the best of my understanding, Emscripten allocates a large JS array and calls that the memory space that the compiled C/C++ code is allowed to operate in. A pointer in C/C++ code will just be an index into that mighty array. Really, that’s not too far off from how a low-level program process is supposed to view memory– as a flat array.

    Eventually, I just learned to cargo-cult my way through the memory allocation process. Here’s the JS code for allocating an Emscripten-compatible byte buffer, taken from my test harness (more on that later) :

    var musicBuffer = fs.readFileSync(testSpec[’filename’]) ;
    var musicBufferBytes = new Uint8Array(musicBuffer) ;
    var bytesMalloc = player._malloc(musicBufferBytes.length) ;
    var bytes = new Uint8Array(player.HEAPU8.buffer, bytesMalloc, musicBufferBytes.length) ;
    bytes.set(new Uint8Array(musicBufferBytes.buffer)) ;
    

    So, read the array of bytes from some input source, create a Uint8Array from the bytes, use the Emscripten _malloc() function to allocate enough bytes from the Emscripten memory array for the input bytes, then create a new array… then copy the bytes…

    You know what ? It’s late and I can’t remember how it works exactly, but it does. It has been a few months since I touched that code (been fighting with front-end website tech since then). You write that memory allocation code enough times and it begins to make sense, and then you hope you don’t have to write it too many more times.

    Multithreading
    You can’t port multithreaded code to JS via Emscripten. JavaScript has no notion of threads ! If you don’t understand the computer science behind this limitation, a more thorough explanation is beyond the scope of this post. But trust me, I’ve thought about it a lot. In fact, the official Emscripten literature states that you should be able to port most any C/C++ code as long as 1) none of the code is proprietary (i.e., all the raw source is available) ; and 2) there are no threads.

    Yes, I read about the experimental pthreads support added to Emscripten recently. Don’t get too excited ; that won’t be ready and widespread for a long time to come as it relies on a new browser API. In the meantime, figure out how to make your multithreaded C/C++ code run in a single thread if you want it to run in a browser.

    Printing Facility
    Eventually, getting software to work boils down to debugging, and the most primitive tool in many a programmer’s toolbox is the humble print statement. A print statement allows you to inspect a piece of a program’s state at key junctures. Eventually, when you try to cross-compile C/C++ code to JS using Emscripten, something is not going to work correctly in the generated JS “object code” and you need to understand what. You’ll be pleading for a method of just inspecting one variable deep in the original C/C++ code.

    I came up with this simple printf-workalike called emprintf() :

    #ifndef EMPRINTF_H
    #define EMPRINTF_H
    

    #include <stdio .h>
    #include <stdarg .h>
    #include <emscripten .h>

    #define MAX_MSG_LEN 1000

    /* NOTE : Don’t pass format strings that contain single quote (’) or newline
    * characters. */
    static void emprintf(const char *format, ...)

    char msg[MAX_MSG_LEN] ;
    char consoleMsg[MAX_MSG_LEN + 16] ;
    va_list args ;

    /* create the string */
    va_start(args, format) ;
    vsnprintf(msg, MAX_MSG_LEN, format, args) ;
    va_end(args) ;

    /* wrap the string in a console.log(’’) statement */
    snprintf(consoleMsg, MAX_MSG_LEN + 16, "console.log(’%s’)", msg) ;

    /* send the final string to the JavaScript console */
    emscripten_run_script(consoleMsg) ;

    #endif /* EMPRINTF_H */

    Put it in a file called “emprint.h”. Include it into any C/C++ file where you need debugging visibility, use emprintf() as a replacement for printf() and the output will magically show up on the browser’s JavaScript debug console. Heed the comments and don’t put any single quotes or newlines in strings, and keep it under 1000 characters. I didn’t say it was perfect, but it has helped me a lot in my Emscripten adventures.

    Optimization Levels
    Remember to turn on optimization when compiling. I have empirically found that optimizing for size (-Os) leads to the best performance all around, in addition to having the smallest size. Just be sure to specify some optimization level. If you don’t, the default is -O0 which offers horrible performance when running in JS.

    Static Compression For HTTP Delivery
    JavaScript code compresses pretty efficiently, even after it has been optimized for size using -Os. I routinely see compression ratios between 3.5:1 and 5:1 using gzip.

    Web servers in this day and age are supposed to be smart enough to detect when a requesting web browser can accept gzip-compressed data and do the compression on the fly. They’re even supposed to be smart enough to cache compressed output so the same content is not recompressed for each request. I would have to set up a series of tests to establish whether either of the foregoing assertions are correct and I can’t be bothered. Instead, I took it into my own hands. The trick is to pre-compress the JS files and then instruct the webserver to serve these files with a ‘Content-Type’ of ‘application/javascript’ and a ‘Content-Encoding’ of ‘gzip’.

    1. Compress your large Emscripten-build JS files with ‘gzip’ : ‘gzip compiled-code.js’
    2. Rename them from extension .js.gz to .jsgz
    3. Tell the webserver to deliver .jsgz files with the correct Content-Type and Content-Encoding headers

    To do that last step with Apache, specify these lines :

    AddType application/javascript jsgz
    AddEncoding gzip jsgz
    

    They belong in either a directory’s .htaccess file or in the sitewide configuration (/etc/apache2/mods-available/mime.conf works on my setup).

    Build System and Build Time Optimization
    Oh goodie, build systems ! I had a very specific manner in which I wanted to build my JS modules using Emscripten. Can I possibly coerce any of the many popular build systems to do this ? It has been a few months since I worked on this problem specifically but I seem to recall that the build systems I tried to used would freak out at the prospect of compiling stuff to a final binary target of .js.

    I had high hopes for Bazel, which Google released while I was developing Cirrus Retro. Surely, this is software that has been battle-tested in the harshest conditions of one of the most prominent software-developing companies in the world, needing to take into account the most bizarre corner cases and still build efficiently and correctly every time. And I have little doubt that it fulfills the order. Similarly, I’m confident that Google also has a team of no fewer than 100 or so people dedicated to developing and supporting the project within the organization. When you only have, at best, 1-2 hours per night to work on projects like this, you prefer not to fight with such cutting edge technology and after losing 2 or 3 nights trying to make a go of Bazel, I eventually put it aside.

    I also tried to use Autotools. It failed horribly for me, mostly for my own carelessness and lack of early-project source control.

    After that, it was strictly vanilla makefiles with no real dependency management. But you know what helps in these cases ? ccache ! Or at least, it would if it didn’t fail with Emscripten.

    Quick tip : ccache has trouble with LLVM unless you set the CCACHE_CPP2 environment variable (e.g. : “export CCACHE_CPP2=1”). I don’t remember the specifics, but it magically fixes things. Then, the lazy build process becomes “make clean && make”.

    Testing
    If you have never used Node.js, testing Emscripten-compiled JS code might be a good opportunity to start. I was able to use Node.js to great effect for testing the individually-compiled music player modules, wiring up a series of invocations using Python for a broader test suite (wouldn’t want to go too deep down the JS rabbit hole, after all).

    Be advised that Node.js doesn’t enjoy the same kind of JIT optimizations that the browser engines leverage. Thus, in the case of time critical code like, say, an audio synthesis library, the code might not run in real time. But as long as it produces the correct bitwise waveform, that’s good enough for continuous integration.

    Also, if you have largely been a low-level programmer for your whole career and are generally unfamiliar with the world of single-threaded, event-driven, callback-oriented programming, you might be in for a bit of a shock. When I wanted to learn how to read the contents of a file in Node.js, this is the first tutorial I found on the matter. I thought the code presented was a parody of bad coding style :

    var fs = require("fs") ;
    var fileName = "foo.txt" ;
    

    fs.exists(fileName, function(exists)
    if (exists)
    fs.stat(fileName, function(error, stats)
    fs.open(fileName, "r", function(error, fd)
    var buffer = new Buffer(stats.size) ;

    fs.read(fd, buffer, 0, buffer.length, null, function(error, bytesRead, buffer)
    var data = buffer.toString("utf8", 0, buffer.length) ;

    console.log(data) ;
    fs.close(fd) ;
    ) ;
    ) ;
    ) ;
    ) ;

    Apparently, this kind of thing doesn’t raise an eyebrow in the JS world.

    Now, I understand and respect the JS programming model. But this was seriously frustrating when I first encountered it because a simple script like the one I was trying to write just has an ordered list of tasks to complete. When it asks for bytes from a file, it really has nothing better to do than to wait for the answer.

    Thankfully, it turns out that Node’s fs module includes synchronous versions of the various file access functions. So it’s all good.

    Conclusion
    I’m sure I missed or underexplained some things. But if other brave souls are interested in dipping their toes in the waters of Emscripten, I hope these tips will come in handy.

  • trying to play corrupted mpeg-ts video using android video view

    20 avril 2015, par asafb

    i am having issue playing partial content of mepg-ts files

    the video files cannot be changed / reformatted / remuxed etc

    server setup :
    contains mpeg-ts video files with h264/acc
    has script that when requested using parameters returns on of the videos "cut"
    according to parameters

    -player :

    (i have no problem playing the full videos "uncut")
    i am trying to play this using android videoview,
    during researching i have found that vlc is the only player able to play the "cut" videos (aka windows mediaplayer, google exoplayer and chrome html5 video player are unable to play)
    running vlc at debug mode revealed error when playing cut video :
    ts error : MPEG-4 descriptor not found
    remuxing the partial content using ffmepg fixes the video

    solutions tried till now :
    1.tried remuxing on the fly using android MediaExtractor and MediaMuxer - but then found out that its not possiable doing that on the fly and anyway that MediaExtractor is unable to open "cut" video
    2.tried getting the first 10K of the full video and then append them to the rest of the "cut" video - the behvior stays the same (vlc able to play while rest wont)

    video files info :

    General
    Count : 278
    Count of stream of this kind : 1
    Kind of stream : General
    Kind of stream : General
    Stream identifier : 0
    ID : 55427
    ID : 55427 (0xD883)
    Count of video streams : 1
    Count of audio streams : 1
    Video_Format_List : AVC
    Video_Format_WithHint_List : AVC
    Codecs Video : AVC
    Audio_Format_List : AAC
    Audio_Format_WithHint_List : AAC
    Audio codecs : AAC LC
    Complete name : 20150416-12.mpg
    File name : 20150416-12
    File extension : mpg
    Format : MPEG-TS
    Format : MPEG-TS
    Format/Extensions usually used : ts m2t m2s m4t m4s ts tp trp
    Commercial name : MPEG-TS
    Internet media type : video/MP2T
    Codec : MPEG-TS
    Codec : MPEG-TS
    Codec/Extensions usually used : ts m2t m2s m4t m4s ts tp trp
    File size : 338329600
    File size : 323 MiB
    File size : 323 MiB
    File size : 323 MiB
    File size : 323 MiB
    File size : 322.7 MiB
    Duration : 27322.311111
    Duration : 27s 322ms
    Duration : 27s 322ms
    Duration : 27s 322ms
    Duration : 00:00:27.322
    Overall bit rate : 1567617
    Overall bit rate : 1 568 Kbps
    Delay : 5542662.322222
    Delay : 1h 32mn
    Delay : 1h 32mn 22s 662ms
    Delay : 1h 32mn
    Delay : 01:32:22.662
    File last modification date : UTC 2015-04-16 09:29:29
    File last modification date (local) : 2015-04-16 12:29:29

    Video
    Count : 205
    Count of stream of this kind : 1
    Kind of stream : Video
    Kind of stream : Video
    Stream identifier : 0
    ID : 68
    ID : 68 (0x44)
    Menu ID : 1
    Menu ID : 1 (0x1)
    Format : AVC
    Format/Info : Advanced Video Codec
    Format/Url : http://developers.videolan.org/x264.html
    Commercial name : AVC
    Format profile : Baseline@L3.0
    Format settings : 3 Ref Frames
    Format settings, CABAC : No
    Format settings, CABAC : No
    Format settings, ReFrames : 3
    Format settings, ReFrames : 3 frames
    Format settings, GOP : M=1, N=25
    Internet media type : video/H264
    Codec ID : 27
    Codec : AVC
    Codec : AVC
    Codec/Family : AVC
    Codec/Info : Advanced Video Codec
    Codec/Url : http://developers.videolan.org/x264.html
    Codec profile : Baseline@L3.0
    Codec settings : 3 Ref Frames
    Codec settings, CABAC : No
    Codec_Settings_RefFrames : 3
    Duration : 4100
    Duration : 4s 100ms
    Duration : 4s 100ms
    Duration : 4s 100ms
    Duration : 00:00:04.100
    Nominal bit rate : 1300000
    Nominal bit rate : 1 300 Kbps
    Width : 704
    Width : 704 pixels
    Height : 576
    Height : 576 pixels
    Pixel aspect ratio : 1.455
    Display aspect ratio : 1.778
    Display aspect ratio : 16:9
    Frame rate : 25.000
    Frame rate : 25.000 fps
    Frame count : 102
    Standard : PAL
    Resolution : 8
    Resolution : 8 bits
    Colorimetry : 4:2:0
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8
    Bit depth : 8 bits
    Scan type : Progressive
    Scan type : Progressive
    Interlacement : PPF
    Interlacement : Progressive
    Bits/(Pixel*Frame) : 0.128
    Writing library : x264 - core 115
    Writing library : x264 core 115
    Writing library/Name : x264
    Writing library/Version : core 115
    Encoding settings : cabac=0 / ref=3 / deblock=1:0:0 / analyse=0x1:0x11 / me=dia / subme=1 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=12 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=25 / keyint_min=2 / scenecut=40 / intra_refresh=0 / rc_lookahead=5 / rc=cbr / mbtree=1 / bitrate=1300 / ratetol=10.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / vbv_maxrate=1300 / vbv_bufsize=2000 / nal_hrd=none / ip_ratio=1.40 / aq=1:1.00

    Audio
    Count : 173
    Count of stream of this kind : 1
    Kind of stream : Audio
    Kind of stream : Audio
    Stream identifier : 0
    ID : 69
    ID : 69 (0x45)
    Menu ID : 1
    Menu ID : 1 (0x1)
    Format : AAC
    Format/Info : Advanced Audio Codec
    Commercial name : AAC
    Format version : Version 4
    Format profile : LC
    Muxing mode : ADTS
    Codec ID : 15
    Codec : AAC LC
    Codec : AAC LC
    Duration : 27322
    Duration : 27s 322ms
    Duration : 27s 322ms
    Duration : 27s 322ms
    Duration : 00:00:27.322
    Bit rate mode : VBR / VBR
    Bit rate mode : Variable / Variable
    Minimum bit rate : 99375
    Minimum bit rate : 99.4 Kbps
    Maximum bit rate : 159750
    Maximum bit rate : 160 Kbps
    Channel(s) : 2
    Channel(s) : 2 channels
    Channel positions : Front : L R
    Channel positions : 2/0/0
    Sampling rate : 48000
    Sampling rate : 48.0 KHz
    Samples count : 1311456
    Compression mode : Lossy
    Compression mode : Lossy

    i prefer finding solution without the need of NDK

    anyone has an idea how to tackle this issue ?
    Thanks

  • ffmpeg transcoding errors with an embedded cover

    31 décembre 2012, par Val Noch

    Im trying to transcode mp3 files into wav format, so that they can be used in another script.
    The script requires the file to be 44.1Khz, so i add that to ffmpeg command.

    The problem comes when a file has an embedded cover image :

     Duration : 00:05:53.85, start : 0.000000, bitrate : 319 kb/s
        Stream #0:0 : Audio : mp3, 44100 Hz, stereo, s16p, 320 kb/s
        Stream #0:1 : Video : mjpeg, gray, 938x936 [SAR 300:300 DAR 469:468], 90k tbr, 90k tbn, 90k tbc
        Metadata :
          title : 
          comment : Cover (front)
        Stream #0:2 : Video : mjpeg, yuvj420p, 88x31 [SAR 96:96 DAR 88:31], 90k tbr, 90k tbn, 90k tbc
        Metadata :
          title : 
          comment : Cover (front)
    

    The ffmpeg command i use is :

    ffmpeg -loglevel warning -y -i :source -vn -ac 2 -ar 44100 -f wav :dest

    So when transcoding a file this throws warnings :

    [mp3 @ 0xa0bba60] Format mp3 detected only with low score of 24, misdetection possible!
    [mp3 @ 0xa0bba60] max_analyze_duration 5000000 reached at 5015510
    [mp3 @ 0xa0bba60] Estimating duration from bitrate, this may be inaccurate

    The resulting wav file has some problems (perhaps wrong header info ?), i think it reports to have more frames than are in the file so the follow-up script overshoots the end of data.

    I believe the problem is with extra streams (cover images) in the mp3 file, but i cant seem to tell ffmpeg to just deal with audio.

    The file i am using for the example is :
    07-Zimmer070-KOSMORAUM-_Junior85-For_reason_forgotten.mp3 (http://archive.org/details/ZIMMER070)

    And the ffmpeg is the latest from their git repo : git ://source.ffmpeg.org/ffmpeg.git

    Many thanks for any info in advance !