Recherche avancée

Médias (3)

Mot : - Tags -/pdf

Autres articles (80)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

Sur d’autres sites (9912)

  • Why UA sniffing is generally bad, real-world example #1048577 : "That time a missing /s on navigator.userAgent (based on single-digit UA version assumptions) broke SM2 on iOS 8+ devices."

    1er septembre 2014, par scottschiller
    Why UA sniffing is generally bad, real-world example #1048577 : "That time a missing /s on navigator.userAgent (based on single-digit UA version assumptions) broke SM2 on iOS 8+ devices."
    

    The upside : The fix is adding \s to a UA regex check targeting legacy iOS devices with broken HTML5 Audio support, so that the "OS 10 " portion of the UA string does not match the pattern "OS 1 ".

    This is a pre-emptive fix for the pending iOS 8 release, which reportedly includes the string "iPhone OS 10_10 like Mac OS X". Due to SM2 checking for /os ([12|3_0|3_1])/i which had broken HTML5 Audio() support, and not considering the far future possibility of "iOS 10" being included in the userAgent string at the time, HTML5 audio is incorrectly disabled on iOS 8 beta 3 and is likely to apply to the final iOS 8 release.

    This is a good example and reminder of why UA checks are generally bad, and dangerous ; similar issues hit other libraries doing UA and plugin checks both client and server-side when IE hit 10, and Flash hit version 10, so this iOS pattern change may affect some other libraries targeting iOS as well.

  • Why my ffmpeg video encode codes does not work on other computer ?

    10 avril 2022, par Object Unknown

    I'm writing code to encode some cv::Mat images to a MP4 video. The program can run successfully in my computer which I developed it, but when I copied it (and all dlls it needs) to an other computer, it stopped work.

    


    The function which reporting error : (I got it from StackOverflow, and added some changes)

    


    int uns::VideoWriter::Remux()
{
    AVFormatContext* ifmt_ctx = NULL, * ofmt_ctx = NULL;
    int err = 0, ret = 0;
    int64_t ts = 0;
    AVStream* inVideoStream = NULL;
    AVStream* outVideoStream = NULL;
    if ((err = avformat_open_input(&ifmt_ctx, VIDEO_TMP_FILE.c_str(), 0, 0)) < 0)
    {
        if(callback != nullptr) 
            callback("[uns::VideoWriter/Remux] Failed to open input file for remuxing", err);
        ret = -1;
        goto end;
    }
    if ((err = avformat_find_stream_info(ifmt_ctx, 0)) < 0) 
    {
        if(callback != nullptr) 
            callback("[uns::VideoWriter/Remux] Failed to retrieve input stream information", err);
        ret = -2;
        goto end;
    }
    if ((err = avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, FINAL_FILE_NAME.c_str())))
    {
        if(callback != nullptr) 
            callback("[uns::VideoWriter/Remux] Failed to allocate output context", err);
        ret = -3;
        goto end;
    }
    inVideoStream = ifmt_ctx->streams[0];
    outVideoStream = avformat_new_stream(ofmt_ctx, NULL);
    if (!outVideoStream) 
    {
        if(callback != nullptr) 
            callback("[uns::VideoWriter/Remux] Failed to allocate output video stream", 0);
        ret = -4;
        goto end;
    }
    outVideoStream->time_base = { 1, fps };
    if ((err = avcodec_parameters_copy(outVideoStream->codecpar, inVideoStream->codecpar)) < 0)
    {
        if (callback != nullptr)
            callback("[uns::VideoWriter/Remux] Failed to copy stream information", err);
        return -4;
        goto end;
    }
    outVideoStream->codecpar->codec_tag = 0;
    if (!(ofmt_ctx->oformat->flags & AVFMT_NOFILE)) 
    {
        if ((err = avio_open(&ofmt_ctx->pb, FINAL_FILE_NAME.c_str(), AVIO_FLAG_WRITE)) < 0)
        {
            if(callback != nullptr) 
                callback("[uns::VideoWriter/Remux] Failed to open output file", err);
            ret = -5;
            goto end;
        }
    }
    ofmt_ctx->streams[0]->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
    ofmt_ctx->streams[0]->time_base.num = 1;
    ofmt_ctx->streams[0]->time_base.den = fps;
    if ((err = avformat_write_header(ofmt_ctx, 0)) < 0) 
    {
        if(callback != nullptr) 
            callback("[uns::VideoWriter/Remux] Failed to write header to output file", err);
        ret = -6;
        goto end;
    }
    AVPacket videoPkt;
    while (true) 
    {
        if ((err = av_read_frame(ifmt_ctx, &videoPkt)) < 0) 
        {
            break;
        }
        videoPkt.stream_index = outVideoStream->index;
        videoPkt.pts = ts;
        videoPkt.dts = ts;
        videoPkt.duration = av_rescale_q(videoPkt.duration, inVideoStream->time_base, outVideoStream->time_base);
        ts += videoPkt.duration;
        videoPkt.pos = -1;
        if ((err = av_interleaved_write_frame(ofmt_ctx, &videoPkt)) < 0) 
        {
            if(callback != nullptr) 
                callback("[uns::VideoWriter/Remux] Failed to mux packet", err);
            av_packet_unref(&videoPkt);
            break;
        }
        av_packet_unref(&videoPkt);
    }
    av_write_trailer(ofmt_ctx);
end:
    if (ifmt_ctx) 
    {
        avformat_close_input(&ifmt_ctx);
    }
    if (ofmt_ctx && !(ofmt_ctx->oformat->flags & AVFMT_NOFILE)) 
    {
        avio_closep(&ofmt_ctx->pb);
    }
    if (ofmt_ctx) 
    {
        avformat_free_context(ofmt_ctx);
    }
    return ret;
}


    


    Notes :

    


    


    callback is a function which prints error messsage and error code.

    
The error I recived is [uns::VideoWriter/Remux] Failed to write header to output file, error code: -22

    


    


    I want to know what is causing this and how to resolve it please.

    


    Other Informations :

    


    


    Developing Env :

    


    


    OS : Windows 11 Professional Workstation build 22593.ni_release
    
IDE : Visual Studio 2022
    
ffmpeg : 4.4.1
    
Installed ffmpeg library :
ffmpeg[avcodec],ffmpeg[avdevice],ffmpeg[avfilter],ffmpeg[avfilter],ffmpeg[avformat],ffmpeg[openh264],ffmpeg[swresample],ffmpeg[swscale]
    
Compile Settings : x64 Release

    


    


    


    


    Running Env which causing error :

    


    


    OS : Windows Server 2019 DataCenter
    
With all dlls VS2022 copied to release folder

    


    


    


  • PHP - Read and write the same file hangs

    2 février 2016, par Adracat

    I’m trying to use FFMPEG to make some works with video on the server, and something I need to do is to get the progress of the process.

    I searched a little and I found this solution which tells to write the log into a file and then reading and parsing it.

    The problem

    What is driving me crazy is that I tell FFMPEG - with exec - (process A) to write the log into a file, but when I try to read it - with file_get_contents() - (process B) it does not show the contents until process A is finished (or interrupted the PHP script).

    So, when process A finishes or it says "PHP script timeout", then I can read the file as times as I want, refreshing the page (process B) and showing the contents at the time.

    What I’ve tried

    I’ve tried to use fopen() to create the file with w, w+ and a parameters, using - and without using - fclose(). I’ve tried to use also flock() just in case it gets faster to read to process B if it knows it’s already locked and does not have to wait, but then FFMPEG is not able to write into the file.

    I’ve searched for multithreading too, but I think there must be an easier and simpler way.

    I’ve used also CURL and HTTP context, as this link suggests, but no luck.

    I’ve tried, too, to use PHP-FFMPEG but it’s not supporting the last FFMPEG version, so I cannot use it.

    When I said before "(or interrupted the PHP script)" is because I tried to wait and, when PHP got a timeout, process B worked alright and the file was still updating.

    The code

    Process A (fileA.php)

    exec('ffmpeg -y -i input_file.mp4 output_file.avi 2> C:\Full\Path\To\File\log.txt 1>&2');

    Process B (fileB.php)

    $content = file_get_contents($file);

    if($content){
       //get duration of source
       preg_match("/Duration: (.*?), start:/", $content, $matches);

       $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);

       $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);

       echo "Duration: " . $duration . "<br />";
       echo "Current Time: " . $time . "<br />";
       echo "Progress: " . $progress . "%";

    }

    The process

    I just open fileA.php on a Chrome tab and, after a few seconds, I open fileB.php on another Chrome tab (and it stays as loading).

    What I need

    I need to be able to load the file and show the information I want to show while the file is being written (by exec and FFMPEG or other PHP scripts), so I can update the progress percentage with some AJAX calls.

    Extra information

    At this point, I’m using PHP 5.4 on a IIS 7.5 with Windows 7 Professional.

    Thank you everyone for your time, help and patience !

    Best regards.