Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP

Autres articles (97)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • 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" (...)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

Sur d’autres sites (5336)

  • 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
}



    


  • 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.

    


  • How to automatically rotate video based on camera orientation while recording ?

    7 avril, par jestrabikr

    I am developing Mediasoup SFU and client web app, on the server I am recording client's stream by sending it to FFmpeg as plain RTP. FFmpeg creates HLS recording (.m3u8 and .ts files), because I need to be able to switch between WebRTC live stream and HLS recording before live stream ends.

    


    My problem is that, when I am testing the app and I rotate my phone 90 degrees, the recording's aspect ratio stays the same but the image is rotated (as shown on images 1.1, 1.2 and 1.3 below). I need for it to change aspect ratio dynamically according to camera orientation. How can I do that using FFmpeg ?

    


    On the live stream it works perfectly fine (as shown on the images - 2.1 and 2.2 below), when the phone is rotated, the aspect ration is changed and video is shown correctly. I think it works on live stream because maybe WebRTC is signaling orientation changes somehow (but it does not project to the recording).

    


    These are my ffmpeg command arguments for recording (version 6.1.1-3ubuntu5) :

    


    let commandArgs = [
      "-loglevel", "info",
      "-protocol_whitelist", "pipe,udp,rtp",
      "-fflags", "+genpts+discardcorrupt",
      "-reinit_filter", "1",
      "-strict", "-2",
      "-f", "sdp",
      "-i", "pipe:0",
      "-map", "0:v:0",
      "-c:v", "libx264",
      "-b:v", "1500k",
      "-profile:v", "high",
      "-level:v", "4.1",
      "-pix_fmt", "yuv420p",
      "-g", "30",
      "-map", "0:a:0",
      "-c:a", "aac",
      "-b:a", "128k",
      "-movflags", "+frag_keyframe+empty_moov",
      "-f", "hls",
      "-hls_time", "4",
      "-hls_list_size", "0",
      "-hls_flags", "split_by_time",
      `${filePath}.m3u8`
    ];


    


      

    • Image 1.1 - Portrait mode in recording :

      


      Image 1.1 - Portrait mode in recording

      


    • 


    • Image 1.2 - Landscape mode in recording (rotated 90deg to my left side - front camera is on my left side) :

      


      Image 1.2 - Landscape mode in recording - left

      


    • 


    • Image 1.3 - Landscape mode in recording (rotated 90deg to my right side) :

      


      Image 1.3 - Landscape mode in recording - right

      


    • 


    • Image 2.1 - Portrait mode in live stream (correct behavior) :

      


      Portrait mode in live stream

      


    • 


    • Image 2.2 - Landscape mode in live stream (correct behavior) :

      


      Landscape mode in live stream

      


    •