Recherche avancée

Médias (0)

Mot : - Tags -/logo

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

Autres articles (61)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

  • Dépôt de média et thèmes par FTP

    31 mai 2013, par

    L’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
    Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

Sur d’autres sites (7101)

  • Sequencing MIDI From A Chiptune

    28 avril 2013, par Multimedia Mike — Outlandish Brainstorms

    The feature requests for my game music appreciation website project continue to pour in. Many of them take the form of “please add player support for system XYZ and the chiptune library to go with it.” Most of these requests are A) plausible, and B) in process. I have also received recommendations for UI improvements which I take under consideration. Then there are the numerous requests to port everything from Native Client to JavaScript so that it will work everywhere, even on mobile, a notion which might take a separate post to debunk entirely.

    But here’s an interesting request about which I would like to speculate : Automatically convert a chiptune into a MIDI file. I immediately wanted to dismiss it as impossible or highly implausible. But, as is my habit, I started pondering the concept a little more carefully and decided that there’s an outside chance of getting some part of the idea to work.

    Intro to MIDI
    MIDI stands for Musical Instrument Digital Interface. It’s a standard musical interchange format and allows music instruments and computers to exchange musical information. The file interchange format bears the extension .mid and contains a sequence of numbers that translate into commands separated by time deltas. E.g. : turn key on (this note, this velocity) ; wait x ticks ; turn key off ; wait y ticks ; etc. I’m vastly oversimplifying, as usual.

    MIDI fascinated me back in the days of dialup internet and discrete sound cards (see also my write-up on the Gravis Ultrasound). Typical song-length MIDI files often ranged from a few kilobytes to a few 10s of kilobytes. They were significantly smaller than the MOD et al. family of tracker music formats mostly by virtue of the fact that MIDI files aren’t burdened by transporting digital audio samples.

    I know I’m missing a lot of details. I haven’t dealt much with MIDI in the past… 15 years or so (ever since computer audio became a blur of MP3 and AAC audio). But I’m led to believe it’s still relevant. The individual who requested this feature expressed an interest in being able to import the sequenced data into any of the many music programs that can interpret .mid files.

    The Pitch
    To limit the scope, let’s focus on music that comes from the 8-bit Nintendo Entertainment System or the original Game Boy. The former features 2 square wave channels, a triangle wave, a noise channel, and a limited digital channel. The latter creates music via 2 square waves, a wave channel, and a noise channel. The roles that these various channels usually play typically break down as : square waves represent the primary melody, triangle wave is used to simulate a bass line, noise channel approximates a variety of percussive sounds, and the DPCM/wave channels are fairly free-form. They can have random game sound effects or, if they are to assist in the music, are often used for more authentic percussive sounds.

    The various channels are controlled via an assortment of memory-mapped hardware registers. These registers are fed values such as frequency, volume, and duty cycle. My idea is to modify the music playback engine to track when various events occur. Whenever a channel is turned on or off, that corresponds to a MIDI key on or off event. If a channel is already playing but a new frequency is written, that would likely count as a note change, so log a key off event followed by a new key on event.

    There is the major obstacle of what specific note is represented by a channel in a particular state. The MIDI standard defines 128 different notes spanning 11 octaves. Empirically, I wonder if I could create a table which maps the assorted frequencies to different MIDI notes ?

    I think this strategy would only work with the square and triangle waves. Noise and digital channels ? I’m not prepared to tackle that challenge.

    Prior Work ?
    I have to wonder if there is any existing work in this area. I’m certain that people have wanted to do this before ; I wonder if anyone has succeeded ?

    Just like reverse engineering a binary program entails trying to obtain a higher level abstraction of a program from a very low level representation, this challenge feels like reverse engineering a piece of music as it is being performed and automatically expressing it in a higher level form.

  • PHP calculate process of Handbrake CLI [closed]

    22 mars 2021, par Olive

    there. Here's a piece of code that converts video files to mp4 type, using ffmpeg or handbrake according to the config constant variable value.

    


    <?php
include( dirname( __FILE__ ) . '/../config/config.php' );
if(isset($_POST['file']))
{
 // Video Converter Using FFMPEG Service
    if(VIDEO_CONVERTER_TYPE == "ffmpeg"){
        $rotate = " -metadata:s:v:0 rotate=0 ";

        // get rotation of the video
        ob_start();
        passthru("mediainfo " . $_POST['file'] . " | grep Rotation 2>&1");
        $duration_output = ob_get_contents();
        ob_end_clean();

        // rotate?
        if (preg_match('/Rotation *: (.*?)\n/', $duration_output, $matches))
        {
            $rotation = $matches[1];
            if (strpos($rotation, "90") !== false)
                $rotate .= '-vf "transpose=1" ';
            else if (strpos($rotation, "180") !== false)
                $rotate .= '-vf "transpose=1,transpose=1" ';
            else if (strpos($rotation, "270") !== false)
                $rotate .= '-vf "transpose=2" ';
        }

        require_once('getid3/getid3.php');
        $getID3 = new getID3;
        $file = $getID3->analyze($_POST['file']);

        $dimension = "";
        $convFlag = false;
        if($file != null && !empty($file['video'])){
            if($file['video']['resolution_x'] > 1280){
                $new_width = 1280;
                $new_height = intval($file['video']['resolution_y'] * (1280 / $file['video']['resolution_x']));
                if($new_height % 2 != 0)
                    $new_height ++;
                $convFlag = true;
            } else if($file['video']['resolution_y'] > 800){
                $new_height = 800;
                $new_width = intval($file['video']['resolution_x'] * (800 / $file['video']['resolution_y']));
                if($new_width % 2 != 0)
                    $new_width ++;
                $convFlag = true;
            }
            if($convFlag)
                $dimension = $new_width . "x" . $new_height;
        }

        $info = pathinfo($_POST['file']);
        if(strtolower($info['extension']) == 'mp4' && $_POST['type'] == 'mp4'){
            $src = $info['dirname'].'/'.$info['filename'].'_original.'.$info['extension'];
            rename($_POST['file'], $src);
        } else
            $src = $_POST['file'];

        $dst = '"'.$info['dirname'].'/'.$info['filename'].'.'.$_POST['type'].'"';

        $command = 'ffmpeg -y -i "'.$src.'"' . $rotate . '-vcodec libx264 -acodec copy -ar 44100 ' . ($dimension != "" ? "-s ".$dimension : "") . ' ' . ($_POST['type'] == 'flv' ? '-crf 28 ' : '') . $dst.' 1> '.dirname(__FILE__) .'/block.txt'.' 2>&1';
        exec($command);
        unlink($src);
        echo json_encode($command);
    } else {
        $rotate = "";

        // get rotation of the video
        ob_start();
        passthru("mediainfo " . $_POST['file'] . " | grep Rotation 2>&1");
        $duration_output = ob_get_contents();
        ob_end_clean();

        // rotate?
        if (preg_match('/Rotation *: (.*?)\n/', $duration_output, $matches))
        {
            $rotation = $matches[1];
            if (strpos($rotation, "90") !== false)
                $rotate .= ' --rotate=4';
            else if (strpos($rotation, "180") !== false)
                $rotate .= ' --rotate=3';
            else if (strpos($rotation, "270") !== false)
                $rotate .= ' --rotate=7';
        }

        require_once('getid3/getid3.php');
        $getID3 = new getID3;
        $file = $getID3->analyze($_POST['file']);

        // $dimension = false;
        $convFlag = false;
        if($file != null && !empty($file['video'])){
            if($file['video']['resolution_x'] > 1280){
                $new_width = 1280;
                $new_height = intval($file['video']['resolution_y'] * (1280 / $file['video']['resolution_x']));
                if($new_height % 2 != 0)
                    $new_height ++;
                $convFlag = true;
            } else if($file['video']['resolution_y'] > 800){
                $new_height = 800;
                $new_width = intval($file['video']['resolution_x'] * (800 / $file['video']['resolution_y']));
                if($new_width % 2 != 0)
                    $new_width ++;
                $convFlag = true;
            }
        }

        $info = pathinfo($_POST['file']);
        if(strtolower($info['extension']) == 'mp4' && $_POST['type'] == 'mp4'){
            $src = $info['dirname'].'/'.$info['filename'].'_original.'.$info['extension'];
            rename($_POST['file'], $src);
        } else
            $src = $_POST['file'];

        $dst = '"'.$info['dirname'].'/'.$info['filename'].'.'.$_POST['type'].'"';

        $command = 'HandBrakeCLI -i "'.$src.'" -e x264 -R44.1 ' . ($convFlag ? "-w ".$new_width . " -h " . $new_height : "") . ' -o ' . $dst.$rotate.' 1> '.dirname(__FILE__) .'/block.txt'.' 2>&1';
        exec($command);
        unlink($src);
        echo json_encode($command);
}
}
else if(isset($_POST['progress'])) // Progress API for Video Converter
{
$content = @file_get_contents('block.txt');

if($content){
    if(VIDEO_CONVERTER_TYPE == "ffmpeg"){
        //get duration of source
        preg_match("/Duration: (.*?), start:/", $content, $matches);
        if(count($matches) <= 1)
        {
            $result['result'] = 'failed';
            $result['progress'] = 0;
            echo json_encode($result);
        }
        else
        {
            $rawDuration = $matches[1];

            //rawDuration is in 00:00:00.00 format. This converts it to seconds.
            $ar = array_reverse(explode(":", $rawDuration));
            $duration = floatval($ar[0]);
            if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
            if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;

            //get the time in the file that is already encoded
            preg_match_all("/time=(.*?) bitrate/", $content, $matches);
            if(count($matches) <= 1)
            {
                $result['result'] = 'failed';
                $result['progress'] = 0;
                echo json_encode($result);
            }
            else
            {
                $rawTime = array_pop($matches);

                //this is needed if there is more than one match
                if (is_array($rawTime)){$rawTime = array_pop($rawTime);}

                //rawTime is in 00:00:00.00 format. This converts it to seconds.
                $ar = array_reverse(explode(":", $rawTime));
                $time = floatval($ar[0]);
                if (!empty($ar[1])) $time += intval($ar[1]) * 60;
                if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;

                //calculate the progress
                $progress = round(($time/$duration) * 100);

                $result = array();
                $result['result'] = 'success';
                $result['progress'] = $progress;

                echo json_encode($result);
            }
        }       
    } else {
        //get duration of source
        preg_match_all("/task 1 of 1, (.*?) %/", $content, $matches);
        if(count($matches) <= 1)
        {
            $result['result'] = 'failed';
            $result['progress'] = 0;
            echo json_encode($result);
        }
        else
        {
            $progress = array_pop($matches);
            $result = array();
            $result['result'] = 'success';
            $result['progress'] = floatval($progress);

            echo json_encode($result);
        }
    }
}
else
{
    $result['result'] = 'fail';
    $result['progress'] = 0;
    echo json_encode($result);
}
}
else
{
    $result['result'] = 'fail';
    $result['progress'] = 0;
    echo json_encode($result);
}
?>


    


    As you can see, the above half part is for making the cli command, and executing it, and another half is for calculating the progress. On the cli part, you can see that it's writing process output contents to the block.txt file. For the ffmpeg process, it works fine. The problem is HandbrakeCLI. It doesn't return process while converting, only it does when the convert process is completely finished.
I know this is because of the locking / unlocking problem of the file. Do you have any thoughts or experience about this problem ? If so, please help me ! Thank you, Yutaka.

    


  • Understanding the VP8 Token Tree

    7 juin 2010, par Multimedia Mike — VP8

    I got tripped up on another part of the VP8 decoding process today. So I drew a picture to help myself understand it. Then I went back and read David Conrad’s comment on my last post regarding my difficulty understanding the VP8 spec and saw that he ran into the same problem. Since we both experienced the same hindrance in trying to sort out this matter, I thought I may as well publish the picture I drew.

    VP8 defines various trees for decoding different syntax elements. There is one tree for decoding the tokens and it is expressed in the VP8 spec as such :

    C :
    1. const tree_index coef_tree [2 * (num_dct_tokens - 1)] =
    2. {
    3.  -dct_eob, 2,        /* eob = "0"  */
    4.   -DCT_0, 4,        /* 0  = "10" */
    5.   -DCT_1, 6,        /* 1  = "110" */
    6.    8, 12,
    7.    -DCT_2, 10,      /* 2  = "11100" */
    8.     -DCT_3, -DCT_4,    /* 3  = "111010", 4 = "111011" */
    9.    14, 16,
    10.     -dct_cat1, -dct_cat2, /* cat1 = "111100", cat2 = "111101" */
    11.    18, 20,
    12.     -dct_cat3, -dct_cat4, /* cat3 = "1111100", cat4 = "1111101" */
    13.     -dct_cat5, -dct_cat6 /* cat4 = "1111110", cat4 = "1111111" */
    14. } ;

    Here is what the table looks like when you make a tree out of it (click for full size image) :



    The catch is that it makes no sense for an end-of-block (EOB) token to follow a 0 token since EOB already indicates that the remainder of the coefficients should be 0 anyway. Thus, the spec states that, "decoding of certain DCT coefficients may skip the first branch, whose preceding coefficient is a DCT_0." I confess, I didn’t understand what "skip the first branch" meant until I drew the tree.



    For those wondering why it might be sub-optimal (clarity-wise) for a spec to simply regurgitate vast chunks of C code, this makes a decent case. As you can see, the spec makes certain assumptions about how a binary tree should be organized in a static array (node n points to elements n*2 and n*2+1 as its branches ; leaves are either negative or 0). This is the second method I have seen ; another piece of code (not the VP8 spec) had the nodes in the first half of the array and pointed to leaves in the second half. There must be other arrangements.