Recherche avancée

Médias (91)

Autres articles (75)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, 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 (...)

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

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

Sur d’autres sites (11897)

  • ffmpeg nvenc encode too slow

    13 août 2016, par sweetsource

    i use ffmpeg 3.1 compile with nvenc,when i run the ffmpeg encode example like this:

    #include

    #include <libavutil></libavutil>opt.h>
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>common.h>
    #include <libavutil></libavutil>imgutils.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>samplefmt.h>
    #include <ace></ace>ace_os.h>

    #define INBUF_SIZE 4096
    #define AUDIO_INBUF_SIZE 20480
    #define AUDIO_REFILL_THRESH 4096



    /*
    * Video encoding example
    */
    static void video_encode_example(const char *filename, const char* codec_name)
    {
       AVCodec *codec;
       AVCodecContext *c= NULL;
       int i, ret, x, y, got_output;
       ACE_INT64 nstart,nend;
       FILE *f;
       AVFrame *frame;
       AVPacket pkt;
       uint8_t endcode[] = { 0, 0, 1, 0xb7 };

       printf("Encode video file %s\n", filename);

       /* find the video encoder */
       codec = avcodec_find_encoder_by_name(codec_name);
       if (!codec) {
           fprintf(stderr, "Codec not found\n");
           exit(1);
       }

       c = avcodec_alloc_context3(codec);
       if (!c) {
           fprintf(stderr, "Could not allocate video codec context\n");
           exit(1);
       }

       /* put sample parameters */
       c->bit_rate = 400000;
       /* resolution must be a multiple of two */
       c->width = 352;
       c->height = 288;
       /* frames per second */
       c->time_base = (AVRational){1,25};
       /* emit one intra frame every ten frames
        * check frame pict_type before passing frame
        * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
        * then gop_size is ignored and the output of encoder
        * will always be I frame irrespective to gop_size
        */
       c->gop_size = 25;
       c->max_b_frames = 0;
       c->thread_count = 1;
       c->refs = 4;
       c->pix_fmt = AV_PIX_FMT_YUV420P;

       if(!strcmp(codec_name,"libx264")
       {
           av_opt_set(c->priv_data, "preset", "superfast", 0);
           av_opt_set(c->priv_data, "tune", "zerolatency", 0);
       }

       if(!strcmp(codec_name,"h264_nvenc")
       {
           av_opt_set(m_pEncodeCtx->priv_data, "gpu","any",0);
           av_opt_set(m_pEncodeCtx->priv_data, "preset", "llhp", 0);
           av_opt_set(m_pEncodeCtx->priv_data,"profile","main",0);
           m_pEncodeCtx->refs = 0;
           m_pEncodeCtx->flags = 0;
           m_pEncodeCtx->qmax = 31;
           m_pEncodeCtx->qmin = 2;
       }

       /* open it */
       if (avcodec_open2(c, codec, NULL) &lt; 0) {
           fprintf(stderr, "Could not open codec\n");
           exit(1);
       }

       f = fopen(filename, "wb");
       if (!f) {
           fprintf(stderr, "Could not open %s\n", filename);
           exit(1);
       }

       frame = av_frame_alloc();
       if (!frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(1);
       }
       frame->format = c->pix_fmt;
       frame->width  = c->width;
       frame->height = c->height;

       /* the image can be allocated by any means and av_image_alloc() is
        * just the most convenient way if av_malloc() is to be used */
       ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,
                            c->pix_fmt, 32);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate raw picture buffer\n");
           exit(1);
       }

       /* encode 1 second of video */
       for (i = 0; i &lt; 25; i++) {
           av_init_packet(&amp;pkt);
           pkt.data = NULL;    // packet data will be allocated by the encoder
           pkt.size = 0;

           fflush(stdout);
           /* prepare a dummy image */
           /* Y */
           for (y = 0; y &lt; c->height; y++) {
               for (x = 0; x &lt; c->width; x++) {
                   frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
               }
           }

           /* Cb and Cr */
           for (y = 0; y &lt; c->height/2; y++) {
               for (x = 0; x &lt; c->width/2; x++) {
                   frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
                   frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
               }
           }

           frame->pts = i;

           /* encode the image */
           nstart = ACE_OS::gettimeofday().get_msec();
           ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_output);
           if (ret &lt; 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("%s take time:%d\n",codec_name,ACE_OS::gettimeofday().get_msec()-nstart);
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_packet_unref(&amp;pkt);
           }
       }

       /* get the delayed frames */
       for (got_output = 1; got_output; i++) {
           fflush(stdout);

           ret = avcodec_encode_video2(c, &amp;pkt, NULL, &amp;got_output);
           if (ret &lt; 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
           }

           if (got_output) {
               printf("Write frame %3d (size=%5d)\n", i, pkt.size);
               fwrite(pkt.data, 1, pkt.size, f);
               av_packet_unref(&amp;pkt);
           }
       }

       /* add sequence end code to have a real MPEG file */
       fwrite(endcode, 1, sizeof(endcode), f);
       fclose(f);

       avcodec_close(c);
       av_free(c);
       av_freep(&amp;frame->data[0]);
       av_frame_free(&amp;frame);
       printf("\n");
    }



    int main(int argc, char **argv)
    {
       const char *output_type;

       /* register all the codecs */
       avcodec_register_all();
       video_encode_example("test.h264", "h264_nvenc");


       return 0;
    }

    it encode one frame to a packet about 1800ms,this is too slow. I use Nvidia Grid K1.Is there some parameter error ? Thanke you very much

  • MMMS stream is playing slow with FFMEG Codec

    21 juillet 2016, par Matrix Revolved

    I had use AudioQueue and FFMpeg codec for playing MMS stream.
    But it is not playing proper, it’s slow some bit of time.
    I am using open source repository
    https://github.com/shouian/MMSRadioWithFFmpeg

    - (BOOL)initFFmpegAudioStream:(NSString *)filePath withTransferWay:(kNetworkWay)network
    {
       NSString *pAudioInPath;
       AVCodec  *pAudioCodec;
       // Parse header
       uint8_t pInput[] = {0x0ff,0x0f9,0x058,0x80,0,0x1f,0xfc};
       tAACADTSHeaderInfo vxADTSHeader={0};
       [AudioUtilities parseAACADTSHeader:pInput toHeader:(tAACADTSHeaderInfo *) &amp;vxADTSHeader];
       // Compare the file path
       if (strncmp([filePath UTF8String], "rtsp", 4) == 0) {
           pAudioInPath = filePath;
           isLocalFile = NO;
       } else if (strncmp([filePath UTF8String], "mms:", 4) == 0) {
           pAudioInPath = filePath;
           pAudioInPath = [pAudioInPath stringByReplacingOccurrencesOfString:@"mms:" withString:@"mmst:"];
           NSLog(@"Audio path %@", pAudioInPath);
           isLocalFile = NO;
       } else if (strncmp([filePath UTF8String], "mmsh:", 4) == 0) {
           pAudioInPath = filePath;
           isLocalFile = NO;
       }else if (strncmp([filePath UTF8String], "mmst:", 4) == 0) {
           pAudioInPath = filePath;
           isLocalFile = NO;
       }else if (strncmp([filePath UTF8String], "http:", 4) == 0) {
           pAudioInPath = filePath;
           isLocalFile = NO;
       } else {
           pAudioInPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:filePath];
           isLocalFile = YES;
       }
       // Register FFmpeg
       avcodec_register_all();
       av_register_all();
       if (isLocalFile == NO) {
           avformat_network_init();
       }
       @synchronized(self) {
           pFormatCtx = avformat_alloc_context();
       }
       // Set network path
       switch (network) {
           case kTCP:
           {
               AVDictionary *option = 0;
               av_dict_set(&amp;option, "rtsp_transport", "tcp", 0);
               // Open video file
               if (avformat_open_input(&amp;pFormatCtx, [pAudioInPath cStringUsingEncoding:NSASCIIStringEncoding], NULL, &amp;option) != 0) {
                   NSLog(@"Could not open connection");
                   return NO;
               }
               av_dict_free(&amp;option);
           }
               break;
           case kUDP:
           {
               if (avformat_open_input(&amp;pFormatCtx, [pAudioInPath cStringUsingEncoding:NSASCIIStringEncoding], NULL, NULL) != 0) {
                   NSLog(@"Could not open connection");
                   return NO;
               }
           }
               break;
       }

       pAudioInPath = nil;

       // Retrieve stream information
       if (avformat_find_stream_info(pFormatCtx, NULL) &lt; 0) {
           NSLog(@"Could not find streaming information");
           return NO;
       }

       // Dump Streaming information
       av_dump_format(pFormatCtx, 0, [pAudioInPath UTF8String], 0);

       // Find the first audio stream
       if ((audioStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, &amp;pAudioCodec, 0)) &lt; 0) {
           NSLog(@"Could not find a audio streaming information");
           return NO;
       } else {
           // Succeed to get streaming information
           NSLog(@"== Audio pCodec Information");
           NSLog(@"name = %s",pAudioCodec->name);
           NSLog(@"sample_fmts = %d",*(pAudioCodec->sample_fmts));

           if (pAudioCodec->profiles) {
               NSLog(@"Profile names = %@", pAudioCodec->profiles);
           } else {
               NSLog(@"Profile is Null");
           }

           // Get a pointer to the codec context for the video stream
           pAudioCodeCtx = pFormatCtx->streams[audioStream]->codec;

           // Find out the decoder
           pAudioCodec = avcodec_find_decoder(pAudioCodeCtx->codec_id);

           // Open codec
           if (avcodec_open2(pAudioCodeCtx, pAudioCodec, NULL) &lt; 0) {
               return NO;
           }
       }

       isStop = NO;

       return YES;
    }

    Above code for initiate audio queue and parsing stream header.
    Suggest any change so can make it smooth playing MMS stream.
    How to update audio buffer size while buffering data in Audio queue.

  • FFmpeg adding image watermark to video process is very slow

    22 juin 2024, par Tushar Lathiya

    I am adding image watermark to video with help of FFmpeg but FFmpeg takes an inordinate amount of time with the below command-

    &#xA;&#xA;

    String[] cmd = {"-i",videoPath, "-i", waterMark.toString(),"-filter_complex","overlay=5:5","-codec:a", "copy", outputPath};&#xA;

    &#xA;&#xA;

    so i tried another command which was little bit faster but increase output file size(which i do not want)

    &#xA;&#xA;

    String[] cmd = {"-y","-i", videoPath, "-i", waterMark.toString(), "-filter_complex", "overlay=5:5", "-c:v","libx264","-preset", "ultrafast", outputPath};&#xA;

    &#xA;&#xA;

    Some one please explain to me how to increase the speed of FFmpeg watermarking speed without increasing the size of output.&#xA; Thanks.

    &#xA;