Recherche avancée

Médias (91)

Autres articles (65)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

Sur d’autres sites (11618)

  • FFMPEG conversion (h.264) taking long time for short videos

    15 février 2023, par Sara

    I am trying to record the video and upload into the aws s3 server. Vuejs as front end and php Laravel as backend, I was not using any conversion before saving it to s3. Due to this if any recording recorded from android cannot be played in apple device due to some codecs..
To over come this, I am using ffmpeg to encode in X264() format to make it play in apple and android device regardless on which device the recording is done.

    


    1 min video taking 6-7 minutes using ffmpeg. I thought may be aws s3 taking time to save, i commented "saving to s3 bucket code" still very slow to save temp public folder in php.

    


    please check the code if i am missing anything to make conversion quick. if any solution update answer with reference link or code snippet with reference to my code below.

    


    public function video_upload(Request $request)
    {
                // Response Declaration   
                $response=array();
                $response_code = 200;
                $response['status'] = false;
                $response['data'] = [];
                // Validation
                // TODO: Specify mimes:mp4,webm,ogg etc 
                $validator = Validator::make(
                $request->all(), [
                'file' => 'required'
                ]
                );
                if ($validator->fails()) {
                $response['data']['validator'] = $validator->errors();
                return response()->json($response);
                }
                try{
                    $file = $request->file('file');
                    //convert
                    $ffmpeg = FFMpeg\FFMpeg::create();
                    $video = $ffmpeg->open($file);
                    $format = new X264(); 
                    //end convert
                    $file_name =  str_replace (' ', '-', Hash::make(time()));
                    $file_name = preg_replace('/[^A-Za-z0-9\-]/', '',$file_name).'.mp4';
                    
                    $video->save($format, $file_name);
                    $file_folder = 'uploads/video/';
                    // Store the file to S3
                    
                    // $store = Storage::disk('s3')->put($file_folder.$file_name, file_get_contents($file));
                    $store = Storage::disk('s3')->put($file_folder.$file_name, file_get_contents($file_name));
                    if($store){
                        // Replace old file if exist
                        //delete the file from public folder
                        $file = public_path($file_name);
                        if (file_exists($file)) {
                            unlink($file);
                        }

                        if(isset($request->old_file)){
 
                            if(Storage::disk('s3')->exists($file_folder.basename($request->old_file))) {
                                 Storage::disk('s3')->delete($file_folder.basename($request->old_file));
                            }
                        }
                    }
                    $response['status'] = true;
                    $response['data']= '/s3/'.$file_folder. $file_name;

                }catch (\Exception $e) {
                    $response['data']['message']=$e->getMessage()."line".$e->getLine();
                    $response_code = 400;
                }
                return response()->json($response, $response_code);
    }


    


    Its blocking point for me. I cannot let user to wait 5-6 mins to upload 1 min video.

    


  • C++ ffmpeg encoded audio is distorted

    14 janvier 2023, par Turgut

    I've made a demuxer/muxer program that takes a video as an input, takes audio and video, then just encodes that red information. So far the video is working fine but the audio is faulty. I can hear the original audio of the input in the background but there is a distorted static sound on the front. I'm setting the AVFrame I got from the demuxer and some information about AVCodecContext in the encoder. The rest is some what similar to ffmpegs muxing example

    


    Here is what I've done so far :

    


    int video_encoder::write_audio_frame(AVFormatContext *oc, OutputStream *ost)
{
    AVCodecContext *c;
    AVFrame *frame;
    int ret;
    int dst_nb_samples;

    c = ost->enc;

#if __AUDIO_ENABLED
    c->bit_rate = input_sample_fmt.bit_rate;
    c->sample_rate = input_sample_fmt.sample_rate;
    c->time_base = input_sample_fmt.time_base;
    c->sample_fmt =  input_sample_fmt.sample_fmt;
    c->channel_layout =  input_sample_fmt.channel_layout;
    //c-> =  input_sample_fmt.channel_layout
#endif

    frame = get_audio_frame(ost);

    if (frame) {
        /* convert samples from native format to destination codec format, using the resampler */
        /* compute destination number of samples */
        dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
                                        c->sample_rate, c->sample_rate, AV_ROUND_UP);
        //av_assert0(dst_nb_samples == frame->nb_samples);

        /* when we pass a frame to the encoder, it may keep a reference to it
         * internally;
         * make sure we do not overwrite it here
         */
        ret = av_frame_make_writable(ost->frame);
        if (ret < 0)
            exit(1);

        /* convert to destination format */
        ret = swr_convert(ost->swr_ctx,
                          ost->frame->data, dst_nb_samples,
                          (const uint8_t **)frame->data, frame->nb_samples);
        if (ret < 0) {
            fprintf(stderr, "Error while converting\n");
            exit(1);
        }
        frame = ost->frame;

        frame->pts = av_rescale_q(ost->samples_count, (AVRational){1, c->sample_rate}, c->time_base);
        ost->samples_count += dst_nb_samples;
    }


    return write_frame(oc, c, ost->st, frame, ost->tmp_pkt);
}


void video_encoder::set_audio_frame(AVFrame* audio, AVCodecContext* c_ctx)
{
    audio_data = *audio;
    input_sample_fmt = *c_ctx;
    //std::cout << audio-> << std::endl;
}

AVFrame* video_encoder::get_audio_frame(OutputStream *ost)
{
    AVFrame *frame = &audio_data;
    int j, i, v;
    int16_t *q = (int16_t*)frame->data[0];


    //(int16_t)*audio_frame->data[0];
    /* check if we want to generate more frames */
    if (av_compare_ts(ost->next_pts, ost->enc->time_base,
                      STREAM_DURATION, (AVRational){ 1, 1 }) > 0)
        return NULL;

    for (j = 0; j nb_samples; j++) {
        #if !__AUDIO_ENABLED
            v = (int)(sin(ost->t) * 10000);
        #endif
        for (i = 0; i < ost->enc->channels; i++)
        #if !__AUDIO_ENABLED
            *q++ = v;
        #endif
        ost->t     += ost->tincr;
        ost->tincr += ost->tincr2;
    }

    frame->pts = ost->next_pts;
    ost->next_pts  += frame->nb_samples;

#if __AUDIO_ENABLED        
    return frame;
#else
    return frame;
#endif
}



    


  • is there a way to change dynamic the water mark text color when using ffmpeg depending on the background color when recording a vieo file ?

    11 juillet 2023, par Shelly Ron

    This command in the command prompt window is working fine and recording the entire screen :

    


    ffmpeg -f gdigrab -framerate 24 -i desktop -preset ultrafast -pix_fmt yuv420p out.mp4


    


    this command prompt add a water mark text in the middle of the screen in white color :

    


    ffmpeg -f gdigrab -framerate 24 -i desktop -vf "drawtext=fontfile=path/to/arial.ttf:text='All rights reserved to ...':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2" -preset ultrafast -pix_fmt yuv420p out.mp4


    


    the problem is that the water mark text is in white and i can see it only when the background window color is black for example when i bring to the front the ffmpeg console window :

    


    water mark

    


    but when it's recording some window with white background, because the text is white it can't be seen.

    


    I want to update the command prompt of the ffmpeg to make somehow dynamic so if the background window is black show the water mark text in white and then if I'm bringing up a window with background white change the water mark text automatic to black.

    


    this is the command i tried for the dynamic effect but it didn't work i got errors and then i tried so many versions of the command line, but nothing helped or worked.

    


    ffmpeg -f gdigrab -framerate 24 -i desktop -filter_complex "[0:v]drawtext=text='Watermark Text':x=(w-text_w)/2:y=(h-text_h)/2:fontfile=arial.ttf:fontsize=24,format=rgba [txt];[txt]split=2 [bw][wc];[bw]lut=r=val*2 [b];[wc]lut=r=val*0.5+0.5:g=val*0.5+0.5:b=val*0.5+0.5 [wc];[wc][b]alphamerge [wm];[wm][0:v]overlay=10:10[outv]" -c:v libx264 -preset ultrafast -map "[outv]" out.mp4


    


    and also tried this

    


    ffmpeg -f gdigrab -framerate 24 -i desktop -filter_complex "[0:v]drawtext=text='Watermark Text':x=(w-text_w)/2:y=(h-text_h)/2:fontfile=Arial.ttf:fontsize=24,format=rgba [txt];[txt]split=2 [bw][wm];[bw][1:v]split=3 [b][g][r];[b]geq=r=0:g=0.5:b=0 [b];[g]geq=r=0:g=0:b=0.5 [g];[r]geq=r=0.5:g=0:b=0 [r];[wm][b][g][r]merge=3,format=rgba [watermark];[0:v][watermark]overlay=x=(W-w)/2:y=(H-h)/2" -map "[watermark]" -map 0:a? -c:v libx264 -c:a copy -preset ultrafast out.mp4