Recherche avancée

Médias (91)

Autres articles (112)

  • Script d’installation automatique de MediaSPIP

    25 avril 2011, par

    Afin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
    Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
    La documentation de l’utilisation du script d’installation (...)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • 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 (12562)

  • Show progress bar of a ffmpeg video convertion

    13 juin 2022, par stackexchange.com-upvm25mz

    I'm trying to print a progress bar while executing ffmpeg but I'm having trouble getting the total number of frames and the current frame being processed. The error I get is AttributeError: 'NoneType' object has no attribute 'groups'. I've copied the function from this program and for some reason it works there but not here, even though I haven't changed that part.

    


    main.py

    


    pattern_duration = re.compile(
    'duration[ \t\r]?:[ \t\r]?(.+?),[ \t\r]?start', re.IGNORECASE)
pattern_progress = re.compile('time=(.+?)[ \t\r]?bitrate', re.IGNORECASE)

def execute_ffmpeg(self, manager, cmd):
    proc = expect.spawn(cmd, encoding='utf-8')
    self.update_progress_bar(proc, manager)
    self.raise_ffmpeg_error(proc)

def update_progress_bar(self, proc, manager):
    total = self.get_total_frames(proc)
    cont = 0
    pbar = self.initialize_progress_bar(manager)
    try:
        proc.expect(pattern_duration)
        while True:
            progress = self.get_current_frame(proc)
            percent = progress / total * 100
            pbar.update(percent - cont)
            cont = percent
    except expect.EOF:
        pass
    finally:
        if pbar is not None:
            pbar.close()

def raise_ffmpeg_error(self, proc):
    proc.expect(expect.EOF)
    res = proc.before
    res += proc.read()
    exitstatus = proc.wait()
    if exitstatus:
        raise ffmpeg.Error('ffmpeg', '', res)

def initialize_progress_bar(self, manager):
    pbar = None
    pbar = manager.counter(
        total=100,
        desc=self.path.rsplit(os.path.sep, 1)[-1],
        unit='%',
        bar_format=BAR_FMT,
        counter_format=COUNTER_FMT,
        leave=False
    )
    return pbar

def get_total_frames(self, proc):
    return sum(map(lambda x: float(
        x[1])*60**x[0], enumerate(reversed(proc.match.groups()[0].strip().split(':')))))

def get_current_frame(self, proc):
    proc.expect(pattern_progress)
    return sum(map(lambda x: float(
                x[1])*60**x[0], enumerate(reversed(proc.match.groups()[0].strip().split(':')))))


    


  • How can I change slice_type which is show in Elecard stream analyzer using ffmpeg ?

    10 octobre 2018, par Tooraj Jam

    I’m not ffmpeg and encodding expert and am trying to encode a MP4 file to MPEG-4 h264 .ts file.

    When Elecard stream analyzer is analyzing my result .ts file, it shows slice_type = 7 for all of i-frames as you can see in the attached screenshot.

    How can I change all these to slice_type = 2 ?

    My ffmpeg command :

    -i Source.mp4 \
    -filter:v 'setpts=0+PTQ-STARTPTS' -metadata:s:v:0 start_time=0 \
    -f adts -c:a libfdk_aac  -profile:a aac_he  -strict -2 -ar 48000 -b:a 48k \
    -f mpegts -c:v libx264  -vbsf h264_mp4toannexb -strict experimental -    profile:v main -level:v 3.0 -preset:v slow -movflags faststart -pat_period 100 \
    -x264opts nal-hrd=cbr:force-cfr=1 -crf 25 -vf scale=w=640:h=360 -aspect 16:9 \
    -bf 1  -sc_threshold 0 -keyint_min 2*25 -g 2*25 \
    -force_key_frames "expr:gte(t,n_forced*50)" -max_muxing_queue_size 1500k \
    -coder 1  -refs 2 \
    -b:v 750k -minrate 750k -maxrate 750k -bufsize 1500k \
    -vsync 1 -framerate 25000/1001 \
    -x264opts "bitrate=750:vbv-maxrate=750:vbv-bufsize=1500"\
    -pix_fmt yuv420p  -r 25 -x264opts force-cfr \
    -mbs_per_slice 1 -y dest.ts

    enter image description here

  • using X264 and librtmp to send live camera frame, but the flash can't show

    9 mai 2016, par brian_wang

    I am using X264 and librtmp to send my live camera frame, all the things seems right. but my web test flash can’t show the correct video. Sometimes it seems correct, but when I re-click play button, it doesn’t show any picture on the flash.

    Here is my X264 config code

    x264_param_default_preset(&x264param, "ultrafast", "zerolatency");
    x264param.i_threads = 2;
    x264param.i_width = width;
    x264param.i_height = height;
    x264param.i_log_level = X264_LOG_DEBUG;
    x264param.i_fps_num = x264param.i_timebase_num= fps;
    x264param.i_fps_den = x264param.i_timebase_den=1;
    x264param.i_frame_total = 0;

    x264param.i_frame_reference =1;
    //x264param.i_frame_reference = 2;
    x264param.i_keyint_min = 25;
    x264param.i_keyint_max = fps*3;
    x264param.i_scenecut_threshold = 40;

    x264param.b_deblocking_filter = 1;
    x264param.b_cabac = 0;
    x264param.analyse.i_trellis = 0;
    x264param.analyse.b_chroma_me = 1;

    x264param.vui.i_sar_width = 0;
    x264param.vui.i_sar_height = 0;
    x264param.i_bframe_bias = 0;
    x264param.b_interlaced= 0;
    x264param.analyse.i_subpel_refine = 6; /* 0..5 -> 1..6 */
    x264param.analyse.i_me_method = X264_ME_DIA;//X264_ME_HEX?X264_ME_DIA
    x264param.analyse.i_me_range = 16;
    x264param.analyse.i_direct_mv_pred = X264_DIRECT_PRED_AUTO;
    x264param.i_deblocking_filter_alphac0 = 0;
    x264param.i_deblocking_filter_beta = 0;
    //x264param.analyse.intra = X264_ANALYSE_I4x4;
    x264param.analyse.intra = X264_ANALYSE_I4x4;//  | X264_ANALYSE_PSUB16x16 | X264_ANALYSE_BSUB16x16;
    x264param.analyse.inter = X264_ANALYSE_I4x4 | X264_ANALYSE_PSUB16x16 | X264_ANALYSE_BSUB16x16;
    //edit 2014-7-28
    x264param.analyse.b_transform_8x8 = 1;
    //x264param.analyse.b_transform_8x8 = 0;
    x264param.analyse.b_fast_pskip = 1;
    x264param.i_bframe = 0;
    //x264param.b_intra_refresh
    x264param.analyse.b_weighted_bipred = 0;

    //// Intra refres:
    x264param.i_keyint_max = 250;
    x264param.b_intra_refresh = 0;
    ////Rate control:
    //x264param.rc.i_rc_method = X264_RC_CRF;

    //Rate Control
    x264param.rc.f_ip_factor = 1.4f;
    x264param.rc.f_pb_factor = 1.3f;
    x264param.rc.f_qcompress = 1.0;
    x264param.rc.i_qp_min = 20;//20;
    x264param.rc.i_qp_max = 32;
    x264param.rc.i_qp_step = 1;

    switch (0)
    {
    case 0: /* 1 PASS ABR */
       x264param.rc.i_rc_method = X264_RC_ABR;
       x264param.rc.i_bitrate = 300; // max = 5000
       x264param.rc.b_mb_tree = 0;
       break;
    case 1: /* 1 PASS CQ */
       x264param.rc.i_rc_method = X264_RC_CQP;
       x264param.rc.i_qp_constant = 26;//10 - 51
       break;
    }

    //For streaming:
    x264param.b_repeat_headers = 1;
    x264param.b_annexb = 1;
    x264_param_apply_profile(&x264param, "baseline");
    encoder = x264_encoder_open(&x264param);
    x264_picture_init( &pic_in );
    x264_picture_alloc(&pic_in, X264_CSP_I420, width, height);

    pic_in.img.i_csp = X264_CSP_I420|X264_CSP_VFLIP;
    pic_in.img.i_plane = 3;
    pic_in.i_type = X264_TYPE_AUTO;

    Sending To RTMP :

    sws_scale(convertCtx,&a,&scribe,0,height, pic_in.img.plane, pic_in.img.i_stride);
    int i_nal;
    int i_frame_size = x264_encoder_encode( encoder, &nal, &i_nal, &pic_in, &pic_out );
    if(i_frame_size <= 0){
       printf("\t!!!FAILED encode frame \n");
    }else{
       for (int i = 0,last=0; i < i_nal;i++)  
       {
           fwrite(nal[i].p_payload, 1, i_frame_size-last, fpw1);
           if (nal[i].i_type == NAL_SPS) {
               sps_len = nal[i].i_payload-4;
               sps  = new unsigned char[sps_len];
               memcpy(sps,nal[i].p_payload+4,sps_len);
           } else if (nal[i].i_type == NAL_PPS) {
               pps_len = nal[i].i_payload-4;
               pps  = new unsigned char[sps_len];
               memcpy(pps,nal[i].p_payload+4,pps_len);
               send_video_sps_pps();
               free(sps);
               free(pps);
           } else {
               send_rtmp_video(nal[i].p_payload,i_frame_size-last);
               break;
           }
           last += nal[i].i_payload;
       }
    }

    Send PPS and SPS

    void send_video_sps_pps(){
    if(rtmp!= NULL){
       RTMPPacket * packet;
       unsigned char * body;
       int i;

       packet = (RTMPPacket *)malloc(RTMP_HEAD_SIZE+1024);
       memset(packet,0,RTMP_HEAD_SIZE);

       packet->m_body = (char *)packet + RTMP_HEAD_SIZE;
       body = (unsigned char *)packet->m_body;
       i = 0;
       body[i++] = 0x17;
       body[i++] = 0x00;

       body[i++] = 0x00;
       body[i++] = 0x00;
       body[i++] = 0x00;

       /*AVCDecoderConfigurationRecord*/
       body[i++] = 0x01;
       body[i++] = sps[1];
       body[i++] = sps[2];
       body[i++] = sps[3];
       body[i++] = 0xff;

       /*sps*/
       body[i++]   = 0xe1;
       body[i++] = (sps_len >> 8) & 0xff;
       body[i++] = sps_len & 0xff;
       memcpy(&body[i],sps,sps_len);
       i +=  sps_len;

       /*pps*/
       body[i++]   = 0x01;
       body[i++] = (pps_len >> 8) & 0xff;
       body[i++] = (pps_len) & 0xff;
       memcpy(&body[i],pps,pps_len);
       i +=  pps_len;

       packet->m_packetType = RTMP_PACKET_TYPE_VIDEO;
       packet->m_nBodySize = i;
       packet->m_nChannel = 0x04;
       packet->m_nTimeStamp = 0;
       packet->m_hasAbsTimestamp = 0;
       packet->m_headerType = RTMP_PACKET_SIZE_MEDIUM;
       packet->m_nInfoField2 = rtmp->m_stream_id;

       RTMP_SendPacket(rtmp,packet,TRUE);
       free(packet);  
       rtmp_start_time = GetTickCount();
    }else{
       std::cout<<"RTMP is not ready"<code>

    Send video Frame

    void send_rtmp_video(unsigned char * buf,int len){
    RTMPPacket * packet;
    long timeoffset = GetTickCount() - rtmp_start_time;

    int type = buf[0]&0x1f;

    packet = (RTMPPacket *)malloc(RTMP_HEAD_SIZE+len+9);
    memset(packet,0,RTMP_HEAD_SIZE);

    packet->m_body = (char *)packet + RTMP_HEAD_SIZE;
    packet->m_nBodySize = len + 9;

    /*send video packet*/
    unsigned char *body = (unsigned char *)packet->m_body;
    memset(body,0,len+9);

    /*key frame*/
    body[0] = 0x27;
    if (type == NAL_SLICE_IDR) {
       body[0] = 0x17;
    }

    body[1] = 0x01;   /*nal unit*/
    body[2] = 0x00;
    body[3] = 0x00;
    body[4] = 0x00;

    body[5] = (len >> 24) & 0xff;
    body[6] = (len >> 16) & 0xff;
    body[7] = (len >>  8) & 0xff;
    body[8] = (len ) & 0xff;

    /*copy data*/
    memcpy(&body[9],buf,len);

    packet->m_hasAbsTimestamp = 0;
    packet->m_packetType = RTMP_PACKET_TYPE_VIDEO;
    if(rtmp != NULL){
       packet->m_nInfoField2 = rtmp->m_stream_id;
    }
    packet->m_nChannel = 0x04;
    packet->m_headerType = RTMP_PACKET_SIZE_LARGE;
    packet->m_nTimeStamp = timeoffset;

    if(rtmp != NULL){
       RTMP_SendPacket(rtmp,packet,TRUE);
    }
    free(packet);

    }