Recherche avancée

Médias (91)

Autres articles (89)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

Sur d’autres sites (13176)

  • First upload video and display upload progress and then convert video using ffmpeg and display progress

    21 avril 2020, par Salman

    I am working on a video sharing platform. What I want to do is that when user upload a video, it first shows an upload progress bar and after completing upload it shows another progress bar for ffmpeg execution time remaining.

    



    I am using this jQuery code for displaying upload progress bar.

    



    $("body").on("submit", "form[name='upload']", function(e) {
    e.preventDefault();
    var formData = new FormData(this);
    $.ajax({
        cache: false,
        contentType: false,
        data: formData,
        dataType: "json",
        method: "POST",
        processData: false,
        url: "upload.php",
        error: function() {
            alert("Sorry, something went wrong!");
        },
        xhr: function() {
            var xhr = new window.XMLHttpRequest();
            xhr.upload.addEventListener("progress", function(evt) {
                if (evt.lengthComputable) {
                    var percentComplete = (evt.loaded / evt.total) * 100;
                    $(".upload .progress-bar").css({
                        "width": percentComplete + "%"
                    });
                }
            }, false);

            return xhr;
        }
    });
});


    



    And I am using this php code for executing video in ffmpeg.

    



    shell_exec('ffmpeg -i uploads/video.mp4 -c:a copy -s 256x144 uploads/video_144p.mp4 > uploads/output.log 2>&1');


    



    It generates an "output.log" file.
Now in jQuery I can GET the content of this log file and display the progress after little calculations.
This is the jQuery code

    



    $.ajax({
    type: "GET",
    cache: false,
    url: "uploads/output.log",
    success: function(response) {
        var duration = 0;
        var time = 0;
        var progress = 0;

        var matches = (response) ? response.match(/Duration: (.*?), start:/) : [];
        if (matches.length > 0) {
            var rawDuration = matches[1];

            var arrayReverse = rawDuration.split(":").reverse();
            duration = parseFloat(arrayReverse[0]);
            if (arrayReverse[1]) duration += parseInt(arrayReverse[1]) * 60;
            if (arrayReverse[2]) duration += parseInt(arrayReverse[2]) * 60 * 60;

            matches = response.match(/time=(.*?) bitrate/g);
            console.log(matches);

            if (matches.length > 0) {
                var rawTime = matches.pop();

                if (Array.isArray(rawTime)) {
                    rawTime = rawTime.pop().replace("time=", "").replace(" bitrate", "");
                } else {
                    rawTime = rawTime.replace("time=", "").replace(" bitrate", "");
                }

                arrayReverse = rawTime.split(":").reverse();
                time = parseFloat(arrayReverse[0]);
                if (arrayReverse[1]) time += parseInt(arrayReverse[1]) * 60;
                if (arrayReverse[2]) time += parseInt(arrayReverse[2]) * 60 * 60;

                progress = Math.round((time / duration) * 100);
            }
        }
        $(".execution .progress-bar").css({
            "width": progress + "%"
        });
    }
});


    



    Now I want a single AJAX code which will upload my file first and display "Upload progress" and after that it will execute my video in php FFMPEG and display "Execution progress"

    


  • Is anyone willing to join a GTK+3 project started in 2009 and still active ?

    15 mars 2020, par GiuTor

    first of all if my question is not relevant to stackoverflow website please delete it, I apologize in advance.

    I started Imagination, a DVD slideshow maker developed with GTK+2 in 2009. Along the years users have contributed with few patches. The software was ported to GTK+3 last year. Imagination works by using Cairo to paint the transition on a GTK drawing area and ffmpeg run in the background to encode the video. I’m currently getting rid of ffmpeg and using libav to encode the video.

    Does anybody want to help with libav coding ? The software is available through SVN :

    svn co https://svn.code.sf.net/p/imagination/code/trunk imagination

    The web site is hosted at sourceforge : http://imagination.sourceforge.net/

    Thanks :)

  • AJAX upload file with progres + FFMPEG progress

    24 octobre 2019, par Сергей Барахтенко

    The task is to implement the following :
    1. On the page there is a form for downloading a file, the file should be loaded asynchronously, without rebooting with the help of AJAX and displaying the upload progress
    2. If the file is successfully downloaded, send a command to the server, which should check the queue, and if the queue is empty, inform the client that the processing of the file has begun, then start the processing itself
    3. If processing has begun, then show the progress of this processing

    What did you manage to implement
    File upload was successfully implemented, after a successful upload, the server issues a line with the status successfully, and the full path of the downloaded file

    Upload JS snippet

    $.ajax({
       url: 'api/upload/load',
       type: 'post',
       data: fd,
       contentType: false,
       processData: false,
       xhr: function() {
           var xhr = new window.XMLHttpRequest();
           xhr.upload.addEventListener("progress", function(evt) {
               if (evt.lengthComputable) {
                   var percent = Math.ceil((evt.loaded / evt.total) * 100);
                   console.log(percent) // Upload progress
               }
           }, false);
           return xhr;
       },
       success: function(data){
           var response = JSON.parse(data);
           if(response.status == 'success'){
               //if upload success, run command
               startConversion(response.path)
           }
       }
    });

    Reponse from api/upload/load

    {"status":"success","path":"<path>"}
    </path>

    In the AJAX script, I do a check : if the response.status == ’success’, then we call the startConversion function, which takes the full path of the newly loaded file as an argument. This function sends another AJAX request to the server, where the queue check is in progress.

    startConversion JS Snippet

    function startConversion(path){
       $.ajax({
           url: '/api/upload/conversion',
           type: 'POST',
           data: { path: path },
           success: function(data){
               var response = JSON.parse(data);
               // if response.status == 'start', run checkConversion function
           }
       })

    Code /api/upload/conversion

    $queue = $this->model->getQueue();
    if($queue &lt; 5){
       // If queue is empty, notify browser
       $output = array('progress' => 'start');
       echo json_encode($output);
       // Then start shell_ecxec
       $cmd = 'some_command';
       shell_exec('ffmpeg.exe -i ' . $path . ' ' . $cmd . ' 1>log.txt 2>&amp;1 ');
    } else {
       $output = array('progress' => 'waiting');
       echo json_encode($output);
    }

    Here, for some reason, a message is already not being displayed stating that processing has begun (echo before $cmd)

    Full link

    And here the most interesting begins. It would seem that it would be possible in the method to success call the check on the status of the processing (start, queue or an error) and if the processing began to call the third function, which, again AJAX, polls the server returns the progress of the processing

    But in reality, the following happens : as soon as the second function sends the request, nothing is returned in response, but processing is in progress, and in the console it shows the status of the request - PENDING. As soon as the server completes processing, a response is issued from the server that the queue is empty and you can start processing the progress, although the processing has already been completed

    There are suggestions that further execution of the script is blocked by the command shell_exec() until the end of her work
    Also, it is not clear to me why the response from the server is not issued when the echo is clearly registered in it, and why the browser is waiting for the complete completion of the work shel_exec() because after it, the code does not have one. What should be done, that is, as if according to the logic of things and by the code, the server should give an answer in the form of a JSON string, the browser should show that the request has completed with the status of 200, and the server, in the meantime, should start the conversion, but for some reason this does not happen...