Recherche avancée

Médias (0)

Mot : - Tags -/formulaire

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (22)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (4972)

  • Can't lock std::mutex again

    16 juillet 2017, par user3567631

    Sorry for poor English.
    I referenced this FFMPEG to make ffmpeg decoder.
    The open will block, I make it run in detach thread.
    I added std::unique_lock to lock mutex in beginning of open.

    bool FFmpegWrapper::open(std::string strFileName)
    {
    std::unique_lock lock(g_Mutex, std::try_to_lock);

    m_pFormatContext = avformat_alloc_context();
    m_pFormatContext->probesize = 4 * 1024 *100;
    m_pFormatContext->max_analyze_duration = 0 * AV_TIME_BASE;

    if (avformat_open_input(&m_pFormatContext, strFileName.c_str(), nullptr, nullptr) != 0)
       return false;

    if (avformat_find_stream_info(m_pFormatContext, NULL) < 0)
       return false;

    m_iVideoStream = m_iAudioStream = -1;
    for (unsigned int i = 0; i < m_pFormatContext->nb_streams; i++)
    {
       if ((m_iVideoStream < 0) && (m_pFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO))
       {
           m_iVideoStream = i;
       }
       else if ((m_iAudioStream < 0) && (m_pFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO))
       {
           m_iAudioStream = i;
       }
    }

    if (!(hasVideo() || hasAudio()))
       return false; // Didn't find video or audio stream

    if (hasVideo())
    {
       if (!openVideoStream())
           return false;
    }

    if (hasAudio())
    {
       if (!openAudioStream())
           return false;
    }

    retrieveFileInfo();

    m_bIsFileOpen = true;
    m_strFileName = strFileName;

    if (isImage())
    {
       m_dDurationInMs = 0;
       m_dFps = 0;
       m_lCurrentFrameNumber = 1;
       decodeImage();
    }

    m_bIsThreadRunning = false;
    if (m_bIsFileOpen)
       CCLOG("FFmpeg open stream succeed");
    else
       CCLOG("FFmpeg open stream failed");
    m_iState = eOpened;

    return m_bIsFileOpen;
    }

    and added unique_lock in close beginning like this.

    void FFmpegWrapper::close()
    {
    std::unique_lock lock(g_Mutex, std::try_to_lock);
    while (!lock.owns_lock())
    {
       lock.try_lock()
    }

    stop();

    if (m_pVideoBuffer != nullptr)
    {
       delete m_pVideoBuffer;
       m_pVideoBuffer = nullptr;
    }

    if (m_pVideoFrameRGB != nullptr)
    {
       av_free(m_pVideoFrameRGB);
       m_pVideoFrameRGB = nullptr;
    }

    if (m_pVideoFrame != nullptr)
    {
       av_free(m_pVideoFrame);
       m_pVideoFrame = nullptr;
    }

    if (m_pAudioFrame != nullptr)
    {
       av_free(m_pAudioFrame);
       m_pAudioFrame = nullptr;
    }


    if (m_pSwScalingContext != nullptr)
    {
       sws_freeContext(m_pSwScalingContext);
       m_pSwScalingContext = nullptr;
    }

    if (m_pVideoCodecContext != nullptr)
    {
       avcodec_close(m_pVideoCodecContext);
       m_pVideoCodecContext = nullptr;
    }
    if (m_pAudioCodecContext != nullptr)
    {
       avcodec_close(m_pAudioCodecContext);
       m_pAudioCodecContext = nullptr;
    }

    if (m_pFormatContext != nullptr)
    {
       avformat_free_context(m_pFormatContext);    
       m_pFormatContext = nullptr;
    }
    if(m_pSwr != nullptr)
       swr_free(&m_pSwr);

    CCLOG("CLOSE DONE");
    }

    When open is still running ,I want lock mutex again in close in main thread.
    it failed to get mutex ownership it is no problem. But even while loop waited the open() done, try_lock still can’t get the mutex ownership.I thought unique_lock out of scope will unlock mutex ,but it didn’t. I want to know how can I lock the mutex correctly.Thank you !

  • Translating Return To Ringworld

    17 août 2016, par Multimedia Mike — Game Hacking

    As indicated in my previous post, the Translator has expressed interest in applying his hobby towards another DOS adventure game from the mid 1990s : Return to Ringworld (henceforth R2RW) by Tsunami Media. This represents significantly more work than the previous outing, Phantasmagoria.


    Return to Ringworld Title Screen
    Return to Ringworld Title Screen

    I have been largely successful thus far in crafting translation tools. I have pushed the fruits of these labors to a Github repository named improved-spoon (named using Github’s random name generator because I wanted something more interesting than ‘game-hacking-tools’).

    Further, I have recorded everything I have learned about the game’s resource format (named RLB) at the XentaxWiki.

    New Challenges
    The previous project mostly involved scribbling subtitle text on an endless series of video files by leveraging a separate software library which took care of rendering fonts. In contrast, R2RW has at least 30k words of English text contained in various blocks which require translation. Further, the game encodes its own fonts (9 of them) which stubbornly refuse to be useful for rendering text in nearly any other language.

    Thus, the immediate 2 challenges are :

    1. Translating volumes of text to Spanish
    2. Expanding the fonts to represent Spanish characters

    Normally, “figuring out the file format data structures involved” is on the list as well. Thankfully, understanding the formats is not a huge challenge since the folks at the ScummVM project already did all the heavy lifting of reverse engineering the file formats.

    The Pitch
    Here was the plan :

    • Create a tool that can dump out the interesting data from the game’s master resource file.
    • Create a tool that can perform the elaborate file copy described in the previous post. The new file should be bit for bit compatible with the original file.
    • Modify the rewriting tool to repack some modified strings into the new resource file.
    • Unpack the fonts and figure out a way to add new characters.
    • Repack the new fonts into the resource file.
    • Repack message strings with Spanish characters.

    Showing The Work : Modifying Strings
    First, I created the tool to unpack blocks of message string resources. I elected to dump the strings to disk as JSON data since it’s easy to write and read JSON using Python, and it’s quick to check if any mistakes have crept in.

    The next step is to find a string to focus on. So I started the game and looked for the first string I could trigger :


    Return to Ringworld: Original text

    This shows up in the JSON string dump as :

      
        "Spanish" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle.",
        "English" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle."
      ,
    

    As you can see, many of the strings are encoded with an ID key as part of the string which should probably be left unmodified. I changed the Spanish string :

      
        "Spanish" : " !0205Hey, is this thing on ?",
        "English" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle."
      ,
    

    And then I wrote the repacking tool to substitute this message block for the original one. Look ! The engine liked it !


    Return to Ringworld: Modified text

    Little steps, little steps.

    Showing The Work : Modifying Fonts
    The next little step is to find a place to put the new characters. First, a problem definition : The immediate goal is to translate the game into Spanish. The current fonts encoded in the game resource only support 128 characters, corresponding to 7-bit ASCII. In order to properly express Spanish, 16 new characters are required : á, é, í, ó, ú, ü, ñ (each in upper and lower case for a total of 14 characters) as well as the inverted punctuation symbols : ¿, ¡.

    Again, ScummVM already documents (via code) the font coding format. So I quickly determined that each of the 9 fonts is comprised of 128 individual bitmaps with either 1 or 2 bits per pixel. I wrote a tool to unpack each character into an individual portable grey map (PGM) image. These can be edited with graphics editors or with text editors since they are just text files.

    Where to put the 16 new Spanish characters ? ASCII characters 1-31 are non-printable, so my first theory was that these characters would be empty and could be repurposed. However, after dumping and inspecting, I learned that they represent the same set of characters as seen in DOS Code Page 437. So that’s a no-go (so I assumed ; I didn’t check if any existing strings leveraged those characters).

    My next plan was hope that I could extend the font beyond index 127 and use positions 128-143. This worked superbly. This is the new example string :

      
        "Spanish" : " !0205¿Ves esto ? ¡La puntuacion se hace girar !",
        "English" : " !0205Your quarters on the Lance of Truth are spartan, in accord with your mercenary lifestyle."
      ,
    

    Fortunately, JSON understands UTF-8 and after mapping the 16 necessary characters down to the numeric range of 128-143, I repacked the new fonts and the new string :


    Return to Ringworld: Espanol
    Translation : “See this ? The punctuation is rotated !”

    Another victory. Notice that there are no diacritics in this string. None are required for this translation (according to Google Translate). But adding the diacritics to the 14 characters isn’t my department. My tool does help by prepopulating [aeiounAEIOUN] into the right positions to make editing easier for the Translator. But the tool does make the effort to rotate the punctuation since that is easy to automate.

    Next Steps and Residual Weirdness
    There is another method for storing ASCII text inside the R2RW resource called strip resources. These store conversation scripts. There are plenty of fields in the data structures that I don’t fully understand. So, following the lessons I learned from my previous translation outing, I was determined to modify as little as possible. This means copying over most of the original data structures intact, but changing the field representing the relative offset that points to the corresponding string. This works well since the strings are invariably stored NULL-terminated in a concatenated manner.

    I wanted to document for the record that the format that R2RW uses has some weirdness in they way it handles residual bytes in a resource. The variant of the resource format that R2RW uses requires every block to be aligned on a 16-byte boundary. If there is space between the logical end of the resource and the start of the next resource, there are random bytes in that space. This leads me to believe that these bytes were originally recorded from stale/uninitialized memory. This frustrates me because when I write the initial file copy tool which unpacks and repacks each block, I want the new file to be identical to the original. However, these apparent nonsense bytes at the end thwart that effort.

    But leaving those bytes as 0 produces an acceptable resource file.

    Text On Static Images
    There is one last resource type we are working on translating. There are various bits of text that are rendered as images. For example, from the intro :


    Return to Ringworld: Static text

    It’s possible to locate and extract the exact image that is overlaid on this scene, though without the colors :


    Original static text

    The palettes are stored in a separate resource type. So it seems the challenge is to figure out the palette in use for these frames and render a transparent image that uses the same palette, then repack the new text-image into the new resource file.

    The post Translating Return To Ringworld first appeared on Breaking Eggs And Making Omelettes.

  • Android + ffmpeg + AudioTrack produces bad audio output

    12 septembre 2014, par Goddchen

    here is what I am trying to do : use an AudioRecord and "pipe" the output of AudioRecord.read(byte[],...) to an ffmpeg process’ stdin that will convert to a 3gp (AAC) file.

    The ffmpeg call is as follows :

           ProcessBuilder processBuilder = new ProcessBuilder(BINARY.getAbsolutePath(),
                   "-y",
                   "-ar", "44100", "-c:a", "pcm_s16le", "-ac", "1","-f","s16le",
                   "-i", "-",
                   "-strict", "-2", "-c:a", "aac",
                   outFile.getAbsolutePath());

    The AudioRecord is setup as follows :

    AudioRecord record = new AudioRecord(/*AudioSource.VOICE_RECOGNITION,*/ AudioSource.MIC,
               SAMPLING_RATE,
               AudioFormat.CHANNEL_IN_MONO,
               AudioFormat.ENCODING_PCM_16BIT,
               bufferSize);

    SAMPLING_RATE = 44100 and bufferSize is the one returned by AudioRecord.getMinBufferSize(...)

    I am writing the data to ffmpeg like this :

    try {
                           IOUtils.write(data, getFFmpegHelper().getCurrentProcessOutputStream());
                       } catch (Exception e) {
                           Log.e(Application.LOG_TAG, "Error writing data to ffmpeg process", e);
                           //TODO notify user, stop the recording, etc...
                       }

    So far so good, the ffmpeg runs and created a proper 3gp file. But the audio in the file is totally off. It seems "choppy" (not sure if this is the correct english word ;) ) and also the pace is wrong, is plays too fast.

    Check out this sample : http://goddchen.de/android/tmp/tmp.3gp

    This is the output of the ffmpeg process :

       [s16le @ 0x23634d0] Estimating duration from bitrate, this may be inaccurate
       Guessed Channel Layout for  Input Stream #0.0 : mono
       Input #0, s16le, from 'pipe:':
       Duration: N/A, start: 0.000000, bitrate: 705 kb/s
       Stream #0:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
       [aformat @ 0x2363100] auto-inserting filter 'auto-inserted resampler 0' between the filter 'src' and the filter 'aformat'
       [aresample @ 0x235b0a0] chl:mono fmt:s16 r:44100Hz -> chl:mono fmt:flt r:44100Hz
       Output #0, 3gp, to '/data/data/com.test.audio/files/tmp.3gp':
       Metadata:
       encoder         : Lavf54.6.100
       Stream #0:0: Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, flt, 128 kb/s
       Stream mapping:
       Stream #0:0 -> #0:0 (pcm_s16le -> aac)
       size=       3kB time=00:00:00.18 bitrate= 132.5kbits/s    
    size=       8kB time=00:00:00.55 bitrate= 120.9kbits/s    
    size=      12kB time=00:00:00.83 bitrate= 121.8kbits/s    
    size=      16kB time=00:00:01.04 bitrate= 122.8kbits/s    
    size=      20kB time=00:00:01.32 bitrate= 122.5kbits/s    
    size=      23kB time=00:00:01.53 bitrate= 121.6kbits/s    
    size=      27kB time=00:00:01.81 bitrate= 121.0kbits/s    
    size=      31kB time=00:00:02.11 bitrate= 120.7kbits/s    
    size=      35kB time=00:00:02.32 bitrate= 123.4kbits/s
       video:0kB audio:34kB global headers:0kB muxing overhead 3.031610%