Recherche avancée

Médias (0)

Mot : - Tags -/page unique

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (79)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (15256)

  • libavcodec : how to encode raw video (YUV420P) frame to the valid bitmap for saving to the ".bmp" file ?

    26 octobre 2020, par Joe Dudinski

    I'm trying to save random video frames into the '.bmp' files by encoding raw video (YUV420P) into AV_CODEC_ID_BMP format using libavcodec, but result is broken image, contains 3 RGB channels :

    


    Resulting bmp
image

    


    Blue channel :
image

    


    Green channel :
image

    


    Red channel :
image

    


    Original YUV image :
image

    


    My code to get current yuv frame and encode it is into BMP :

    


    int __create_bmp(AVPacket *pkt, AVCodecContext *video_dec_ctx, int video_stream_idx) {
    int err = 0;
    int got_frame = 0;
    static int vfnum = 0; //current v.frame num

    if (pkt->stream_index == video_stream_idx) {

        fprintf(stderr, "AVCodecContext codec: (name: %s), ID %d\n",
                video_dec_ctx->codec->name, video_dec_ctx->codec_id);

        /* decode video frame */
        AVFrame *frame = av_frame_alloc();

        // !!! 'avcodec_decode_video2' IS DEPRECATED !!!
        err = avcodec_decode_video2(video_dec_ctx, frame, got_frame, pkt);
        if (err < 0) {
            fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(err));
            return err;
        }
        if(got_frame == 0) return 1;

        // !!! this dbg func save mjpeg YUV420P into '.jpg' file FINE !!!
        __encode_image_frame(frame);

        AVCodec *bmpc = avcodec_find_encoder(AV_CODEC_ID_BMP);
        if(bmpc == NULL){
            fprintf(stderr, "'AV_CODEC_ID_BMP' encoder NOT FOUND!.\n");
            exit(-1);
        }
        AVCodecContext *__bmpcc = avcodec_alloc_context3(bmpc);
        __bmpcc->width = frame->width;
        __bmpcc->height = frame->height;
        __bmpcc->pix_fmt = AV_PIX_FMT_BGR24;
        __bmpcc->time_base = (AVRational){1,1};

        err = avcodec_open2(__bmpcc, bmpc, NULL);
        if(err == 0){
            fprintf(stderr, "avcodec_open2 success.\n");
        }else{
            fprintf(stderr, "avcodec_open2 ERROR!\n");
        }

        err = avcodec_send_frame(__bmpcc, frame);
        if(err == 0){
            fprintf(stderr, "avcodec_send_frame success.\n");
        }
        else{
            fprintf(stderr, "avcodec_send_frame ERROR! (code: %d)\n",err);
        }

        AVPacket *bmp_pkt = av_packet_alloc();
        err = avcodec_receive_packet(__bmpcc, bmp_pkt);
        if(err == 0){
            fprintf(stderr, "avcodec_receive_packet success.\n");
        }
        else{
            fprintf(stderr, "avcodec_receive_packet ERROR! (code: %d)\n",err);
        }
        av_frame_unref(frame);

        /* write to bitmap file */
        char outimg[2048] = {0};
        snprintf(outimg, 2048,"out-%06d.bmp", vfnum);
        FILE *outf = fopen(outimg, "wb");
        vfnum++;
        if (!outf) {
            fprintf(stderr, "Could not open destination file %s\n", outimg);
        }else{
            fwrite(bmp_pkt->data, 1, bmp_pkt->size , outf);
            fclose(outf);
        }
        av_packet_unref(bmp_pkt);
        return 0;
    }
    return 1;
}


    


    Does anyone know how to do this correctly ?

    


  • In my django app, celery task converts uploaded video w/ ffmpeg, but converted video won't save to s3 ?

    29 janvier 2013, par GetItDone

    I use Heroku to host my website, and Amazon s3 to store my static and media files. I have a celery task that converts the video file to flv, but the flv doesn't store anywhere. There isn't any error, just there is no file uploaded to my s3 bucket. How can I force the file to save to my s3 bucket after the conversion ? I'm still pretty new web development in general, and I have been stuck trying to get my video conversion working properly for weeks. To be honest, I'm not even sure that I'm doing the right thing with my task. Here is the code in my celery task :

    @task(name='celeryfiles.tasks.convert_flv')
    def convert_flv(video_id):
       video = VideoUpload.objects.get(pk=video_id)
       filename = video.video_upload
       sourcefile = "%s%s" % (settings.MEDIA_URL, filename)
       vidfilename = "%s.flv" % video.id
       targetfile = "%svideos/flv/%s" % (settings.MEDIA_URL, vidfilename)
       ffmpeg = "ffmpeg -i %s -ar 22050 -f flv -s 320x240 %s" % (sourcefile, targetfile)
       #The next lines are code that I couldn't get to work in place of the line above, and are left commented out.
       #I am open to suggestions or alternatives for this also.
       #ffmpeg = "ffmpeg -i %s -acodec libmp3lame -ar 22050 -f flv -s 320x240 %s" % (sourcefile, targetfile)
       #ffmpeg = "ffmpeg -i %s -acodec mp3 -ar 22050 -f flv -s 320x240 %s" % (sourcefile, targetfile)
       try:
           ffmpegresult = commands.getoutput(ffmpeg)
           print "---------------FFMPEG---------------"
           print "FFMPEGRESULT: %s" % ffmpegresult
       except Exception as e:
           ffmpegresult = None
           print("Failed to convert video file %s to %s" % (sourcefile, targetfile))
           print(traceback.format_exc())
       video.flvfilename = vidfilename
       video.save()

    My view :

    def upload_video(request):
       if request.method == 'POST':
           form = VideoUploadForm(request.POST, request.FILES)
           if form.is_valid():
               video_upload=form.save()
               video_id=video_upload.id
               video_conversion = convert_flv.delay(video_id)
               return HttpResponseRedirect('/current_classes/')
       else:
       ...

    Any advice, insight, or ideas in general would be greatly appreciated. Obviously I am missing something, but I can't figure out what. I have been stuck with different aspects of getting my video conversion to work with ffmpeg using a celery task for weeks. Thanks in advance.

  • pyav - cannot save stream as mono

    3 août 2022, par Zvika

    I'm trying to use pyav to convert arbitrary audio file to a low quality, mono, wave file.

    


    I almost managed to do it, but it's stereo, and I couldn't find how to make it mono. Furthermore, I think I made some mistake here, as I had to repeat the rate in the output_container.add_stream and in the AudioResampler - it seems redundant, and I can't understand what would happen if those numbers won't match.

    


    My code is :

    


        import av
    
    input_file = 'some.mp3'
    output_file = 'new.wav'
    
    rate = 22000
    
    output_container = av.open(output_file, 'w')

    # can I tell `output_stream` to just use `resampler`'s info?
    # or, if not, how can I tell it to have only 1 channel?
    output_stream = output_container.add_stream('pcm_u8', rate)  
    
    resampler = av.audio.resampler.AudioResampler('u8p', 'mono', rate)
    
    input_container = av.open(input_file)
    for frame in input_container.decode(audio=0):
        out_frames = resampler.resample(frame)
        for out_frame in out_frames:
            for packet in output_stream.encode(out_frame):
                output_container.mux(packet)
    output_container.close()


    


    And not related to my main question, but any comments regarding my code, or pointing out mistakes, are welcomed. I hardly could find usage examples to use a reference, and PyAV API documentation isn't very detailed...