Recherche avancée

Médias (0)

Mot : - Tags -/content

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

Autres articles (54)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (5859)

  • How to convert an IP Camera video stream into a video file ?

    14 novembre 2014, par AgentFire

    I have a URL (<ip>/ipcam/mpeg4.cgi</ip>) which points to my IP camera which is connected via Ethernet.
    Accessing the URL resuls in a infinite stream of video (possibly with audio) data.

    I would like to store this data into a video file and play it later with a video player (HTML5’s video tag is preferred as the player).

    However, a straightforward approach, which is simple saving the stream data into .mp4 file, didn’t work.

    I have looked into the file and here is what I saw (click to enlarge) :

    It turned out, there are some HTML headers, which I further on manually excluded using the binary editing tool, and yet no player could play the rest of the file.

    The HTML headers are :

    --myboundary
    Content-Type: image/mpeg4
    Content-Length: 76241
    X-Status: 0
    X-Tag: 1693923
    X-Flags: 0
    X-Alarm: 0
    X-Frametype: I
    X-Framerate: 30
    X-Resolution: 1920*1080
    X-Audio: 1
    X-Time: 2000-02-03 02:46:31
    alarm: 0000

    My question is pretty clear now, and I would like any help or suggestion. I suspect, I have to manually create some MP4 headers myself based on those values above, however, I fail to understand format descriptions such as these.

    I have the following video stream settings on my IP camera (click to enlarge) :

    I could also use the ffmpeg tool, but no matter how I try and mix the arguments to the program, it keeps telling me this error :

  • How to play a part of the MP4 video stream ?

    14 novembre 2014, par AgentFire

    I have a URL (<ip>/ipcam/mpeg4.cgi</ip>) which points to my IP camera which is connected via Ethernet.
    Accessing the URL resuls in a infinite stream of video (possibly with audio) data.

    I would like to store this data into a video file and play it later with a video player (HTML5’s video tag is preferred as the player).

    However, a straightforward approach, which is simple saving the stream data into .mp4 file, didn’t work.

    I have looked into the file and here is what I saw (click to enlarge) :

    It turned out, there are some HTML headers, which I further on manually excluded using the binary editing tool, and yet no player could play the rest of the file.

    The HTML headers are :

    --myboundary
    Content-Type: image/mpeg4
    Content-Length: 76241
    X-Status: 0
    X-Tag: 1693923
    X-Flags: 0
    X-Alarm: 0
    X-Frametype: I
    X-Framerate: 30
    X-Resolution: 1920*1080
    X-Audio: 1
    X-Time: 2000-02-03 02:46:31
    alarm: 0000

    My question is pretty clear now, and I would like any help or suggestion. I suspect, I have to manually create some MP4 headers myself based on those values above, however, I fail to understand format descriptions such as these.

    I have the following video stream settings on my IP camera (click to enlarge) :

    I could also use the ffmpeg tool, but no matter how I try and mix the arguments to the program, it keeps telling me this error :

  • FFmpeg : generating H264 video in c++

    13 octobre 2015, par EZEROFIVE EMD

    Im using ffmpeg library in windows with vs2012 to convert a series of images into Mp4 with H264 encoding. Im new to FFMPEG.

    Below is my code. Everything went fine. Video is created.But i can play the video in vlc player only if i changed the extension to ".h264", also when i check for codec information it says "H264 - MPEG-4 AVC (part 10) (h264)". but when i checked the same for other mp4 videos which are downloaded from web. it says "H264 - MPEG-4" AVC (part 10) (avc1)". I dont understand where it went wrong. Also i searched a lot, some says like add SPS and PPS.

    const uint8_t sps[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00,
    0x0a, 0xf8, 0x41, 0xa2 };
    const uint8_t pps[] = { 0x00, 0x00, 0x00, 0x01, 0x68, 0xce,
    0x38, 0x80 };

    So i added the above value to video file before i add the image stream. But no luck.
    Can anyone help on this..Thanks in advance.

    const uint8_t sps[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00,
    0x0a, 0xf8, 0x41, 0xa2 };
    const uint8_t pps[] = { 0x00, 0x00, 0x00, 0x01, 0x68, 0xce,
    0x38, 0x80 };
    const uint8_t slice_header[] = { 0x00, 0x00, 0x00, 0x01, 0x05, 0x88,
    0x84, 0x21, 0xa0 };
    const uint8_t macroblock_header[] = { 0x0d, 0x00 };

    const uint8_t spspps[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x0a, 0xf8, 0x41, 0xa2,
                              0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x38, 0x80
                            };

    int ff_load_image(uint8_t *data[4], int linesize[4],
           int *w, int *h, enum PixelFormat *pix_fmt,
           const char *filename, void *log_ctx)
       {
           AVInputFormat *iformat = NULL;
           AVFormatContext *format_ctx = NULL;
           AVCodec *codec=NULL;
           AVCodecContext *codec_ctx=NULL;
           AVFrame *frame=NULL;
           int frame_decoded, ret = 0;
           AVPacket pkt;

           av_register_all();

           iformat = av_find_input_format("image2");
           if ((ret = avformat_open_input(&amp;format_ctx, filename, iformat, NULL)) &lt; 0) {
               return ret;
           }

           codec_ctx = format_ctx->streams[0]->codec;
           codec = avcodec_find_decoder(codec_ctx->codec_id);
           if (!codec) {
               ret = AVERROR(EINVAL);
               goto end;
           }

           if ((ret = avcodec_open2(codec_ctx, codec, NULL)) &lt; 0) {
               goto end;
           }

           //if (!(frame = avcodec_alloc_frame()) ) {
           if (!(frame = av_frame_alloc()) ) {
               ret = AVERROR(ENOMEM);
               goto end;
           }

           ret = av_read_frame(format_ctx, &amp;pkt);
           if (ret &lt; 0) {
               goto end;
           }

           ret = avcodec_decode_video2(codec_ctx, frame, &amp;frame_decoded, &amp;pkt);
           if (ret &lt; 0 || !frame_decoded) {
               goto end;
           }
           ret = 0;

           *w       = frame->width;
           *h       = frame->height;
           *pix_fmt = (PixelFormat)frame->format;

           if ((ret = av_image_alloc(data, linesize, *w, *h, (AVPixelFormat)*pix_fmt, 16)) &lt; 0)
               goto end;
           ret = 0;

           av_image_copy(data, linesize, (const uint8_t **)frame->data, frame->linesize, (AVPixelFormat)*pix_fmt, *w, *h);

    end:
           if(codec_ctx) { avcodec_close(codec_ctx); }
           if(format_ctx) { avformat_close_input(&amp;format_ctx); }
           if(frame) { av_freep(&amp;frame); }
           av_free_packet(&amp;pkt);
                   return ret;
       }

       int load_image_into_frame(AVFrame *frame, const char *filename)
       {
           int retval = -1, res;
           static struct SwsContext *sws_ctx;
           uint8_t *image_data[4];
           int linesize[4];
           int source_width, source_height;
           enum PixelFormat source_fmt;

           res = ff_load_image(image_data, linesize, &amp;source_width, &amp;source_height, &amp;source_fmt, filename, NULL);

           if (source_fmt != frame->format) {
               sws_ctx = sws_getContext(source_width, source_height, (AVPixelFormat)source_fmt,
                   frame->width, frame->height, (AVPixelFormat)frame->format,
                   sws_flags, NULL, NULL, NULL);

               sws_scale(sws_ctx,
                   (const uint8_t * const *)image_data, linesize,
                   0, frame->height, frame->data, frame->linesize);
           }

           retval = 0;
    error:
           av_freep(&amp;image_data[0]);
           sws_freeContext(sws_ctx);
           return retval;
       }

       int write_frame_to_file(FILE *file, AVFrame *frame, AVCodecContext *codec_context, AVPacket *pkt) {
           int res, got_output;
           av_init_packet(pkt);
           pkt->data = NULL;
           pkt->size = 0;

           /* generate synthetic video */
           frame->pts += 30;

           res = avcodec_encode_video2(codec_context, pkt, frame, &amp;got_output);

           if (got_output) {

               fwrite(pkt->data, 1, pkt->size, file);
               av_free_packet(pkt);
           }
           return 0;
    error:
           return -1;
       }

       int write_image_to_file(FILE *file, const char *filename, int count, AVFrame *frame, AVCodecContext *codec_context, AVPacket *pkt) {
           int res, i;
           res = load_image_into_frame(frame, filename);

           for (i = 0; i &lt; count; i++) {

               res = write_frame_to_file(file, frame, codec_context, pkt);
           }

           return 0;
    error:
           return -1;
       }

       int write_delayed_frames_to_file(FILE *file, AVFrame *frame, AVCodecContext *codec_context, AVPacket *pkt) {
           int res, got_output;

           for (got_output = 1; got_output;) {
               res = avcodec_encode_video2(codec_context, pkt, NULL, &amp;got_output);

               if (got_output) {
                   fwrite(pkt->data, 1, pkt->size, file);
                   av_free_packet(pkt);
               }
           }

           return 0;
    error:
           return -1;
       }

       AVCodecContext *get_codec_context(int width, int height, int fps)
       {
           int res;
           avcodec_register_all();

           AVCodec *codec;
           AVCodecContext *codec_context = NULL;

           codec = avcodec_find_encoder(AV_CODEC_ID_H264);

           codec_context = avcodec_alloc_context3(codec);

           codec_context->bit_rate = 441000;
           codec_context->width = width;
           codec_context->height = height;
           AVRational temp_113 = {1, fps};
           AVRational temp_114 = {fps, 1};
           codec_context->time_base= temp_113;
           codec_context->gop_size = 10;
           codec_context->max_b_frames=1;
           codec_context->pix_fmt = AV_PIX_FMT_YUV420P;        

           res = avcodec_open2(codec_context, codec, NULL);

           return codec_context;
    error:
           return NULL;
       }

       AVFrame *get_av_frame(AVCodecContext *codec_context) {
           int res;
           AVFrame *frame;

           frame = av_frame_alloc();
           frame->height = codec_context->height;
           frame->width = codec_context->width;
           frame->format = codec_context->pix_fmt;
           frame->pts = 0;

           res = av_image_alloc(frame->data, frame->linesize, frame->width, frame->height, (AVPixelFormat)frame->format, 1);

           return frame;
    error:
           return NULL;
       }

       int main(int argc, char **argv)
       {
           const char *filename = "result video\\test.mp4";
           FILE *file=NULL;
           int res, retval=-1;
           AVCodecContext *codec_context= NULL;
           AVFrame *frame=NULL;
           AVPacket pkt;
           uint8_t endcode[] = { 0, 0, 1, 0xb7 };

           codec_context = get_codec_context(1920, 1080, 30);

           file = fopen(filename, "wb");
           //check(file != NULL, "could not open destination file %s", filename);

           frame = get_av_frame(codec_context);        

           //fwrite(sps, 1, sizeof(sps), file);
           //fwrite(pps, 1, sizeof(pps), file);

           /*codec_context->extradata = (uint8_t *)malloc(sizeof(uint8_t) * sizeof(spspps));

           for(unsigned int index = 0; index &lt; sizeof(spspps); index++)
           {
               codec_context->extradata[index] = spspps[index];
           }

           codec_context->extradata_size = (int)sizeof(spspps);*/

           codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;

           int i, frames= 51;
           for (i = 0; i &lt; frames; i++) {
               std::stringstream ss;
               ss&lt;&lt;"\\frames\\out"&lt;&lt;( i + 1)&lt;&lt;".jpg";
               res = write_image_to_file(file, ss.str().c_str(), 3, frame, codec_context, &amp;pkt);
           }


           res = write_delayed_frames_to_file(file, frame, codec_context, &amp;pkt);
           fwrite(endcode, 1, sizeof(endcode), file);

           retval = 0;
    error:
           if (file)
               fclose(file);
           if (codec_context) {
               avcodec_close(codec_context);
               av_free(codec_context);
           }
           if (frame) {
               av_freep(&amp;frame->data[0]);
               av_free(frame);
           }
           return retval;
       }
    }