Recherche avancée

Médias (91)

Autres articles (78)

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

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

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

  • FFMPEG RTSP Server using muxing doc example

    11 novembre 2018, par Harshil Makwana

    I am trying to develop RTSP server using FFMPEG. For that I slightly modified muxing file located at doc/example/ folder inside FFMPEG repository.

    Giving my source code of RTSP server example :

    #include
    #include
    #include
    #include

    #include <libavutil></libavutil>avassert.h>
    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>opt.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>timestamp.h>
    #include <libavformat></libavformat>avformat.h>
    #include <libswscale></libswscale>swscale.h>
    #include <libswresample></libswresample>swresample.h>

    #define STREAM_DURATION   10.0
    #define STREAM_FRAME_RATE 25 /* 25 images/s */
    #define STREAM_PIX_FMT    AV_PIX_FMT_YUV420P /* default pix_fmt */

    #define SCALE_FLAGS SWS_BICUBIC

    // a wrapper around a single output AVStream
    typedef struct OutputStream {
       AVStream *st;
       AVCodecContext *enc;

       /* pts of the next frame that will be generated */
       int64_t next_pts;
       int samples_count;

       AVFrame *frame;
       AVFrame *tmp_frame;

       float t, tincr, tincr2;

       struct SwsContext *sws_ctx;
       struct SwrContext *swr_ctx;
    } OutputStream;

    static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
    {
       AVRational *time_base = &amp;fmt_ctx->streams[pkt->stream_index]->time_base;

       printf("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
              av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
              av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
              av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
              pkt->stream_index);
    }

    static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
    {
       /* rescale output packet timestamp values from codec to stream timebase */
       av_packet_rescale_ts(pkt, *time_base, st->time_base);
       pkt->stream_index = st->index;

       /* Write the compressed frame to the media file. */
       log_packet(fmt_ctx, pkt);
       return av_interleaved_write_frame(fmt_ctx, pkt);
    }

    /* Add an output stream. */
    static void add_stream(OutputStream *ost, AVFormatContext *oc,
                          AVCodec **codec,
                          enum AVCodecID codec_id)
    {
       AVCodecContext *c;
       int i;

       /* find the encoder */
       *codec = avcodec_find_encoder(codec_id);
       if (!(*codec)) {
           fprintf(stderr, "Could not find encoder for '%s'\n",
                   avcodec_get_name(codec_id));
           exit(1);
       }

       ost->st = avformat_new_stream(oc, NULL);
       if (!ost->st) {
           fprintf(stderr, "Could not allocate stream\n");
           exit(1);
       }
       ost->st->id = oc->nb_streams-1;
       c = avcodec_alloc_context3(*codec);
       if (!c) {
           fprintf(stderr, "Could not alloc an encoding context\n");
           exit(1);
       }
       ost->enc = c;

       switch ((*codec)->type) {
       case AVMEDIA_TYPE_AUDIO:
           c->sample_fmt  = (*codec)->sample_fmts ?
               (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
           c->bit_rate    = 64000;
           c->sample_rate = 44100;
           if ((*codec)->supported_samplerates) {
               c->sample_rate = (*codec)->supported_samplerates[0];
               for (i = 0; (*codec)->supported_samplerates[i]; i++) {
                   if ((*codec)->supported_samplerates[i] == 44100)
                       c->sample_rate = 44100;
               }
           }
           c->channels        = av_get_channel_layout_nb_channels(c->channel_layout);
           c->channel_layout = AV_CH_LAYOUT_STEREO;
           if ((*codec)->channel_layouts) {
               c->channel_layout = (*codec)->channel_layouts[0];
               for (i = 0; (*codec)->channel_layouts[i]; i++) {
                   if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO)
                       c->channel_layout = AV_CH_LAYOUT_STEREO;
               }
           }
           c->channels        = av_get_channel_layout_nb_channels(c->channel_layout);
           ost->st->time_base = (AVRational){ 1, c->sample_rate };
           break;

       case AVMEDIA_TYPE_VIDEO:
           c->codec_id = codec_id;

           c->bit_rate = 400000;
           /* Resolution must be a multiple of two. */
           c->width    = 352;
           c->height   = 288;
           /* timebase: This is the fundamental unit of time (in seconds) in terms
            * of which frame timestamps are represented. For fixed-fps content,
            * timebase should be 1/framerate and timestamp increments should be
            * identical to 1. */
           ost->st->time_base = (AVRational){ 1, STREAM_FRAME_RATE };
           c->time_base       = ost->st->time_base;

           c->gop_size      = 12; /* emit one intra frame every twelve frames at most */
           c->pix_fmt       = STREAM_PIX_FMT;
           if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
               /* just for testing, we also add B-frames */
               c->max_b_frames = 2;
           }
           if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
               /* Needed to avoid using macroblocks in which some coeffs overflow.
                * This does not happen with normal video, it just happens here as
                * the motion of the chroma plane does not match the luma plane. */
               c->mb_decision = 2;
           }
      break;

       default:
           break;
       }

       /* Some formats want stream headers to be separate. */
       if (oc->oformat->flags &amp; AVFMT_GLOBALHEADER)
           c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
    }

    /**************************************************************/
    /* audio output */

    static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
                                     uint64_t channel_layout,
                                     int sample_rate, int nb_samples)
    {
       AVFrame *frame = av_frame_alloc();
       int ret;

       if (!frame) {
           fprintf(stderr, "Error allocating an audio frame\n");
           exit(1);
       }

       frame->format = sample_fmt;
       frame->channel_layout = channel_layout;
       frame->sample_rate = sample_rate;
       frame->nb_samples = nb_samples;

       if (nb_samples) {
           ret = av_frame_get_buffer(frame, 0);
           if (ret &lt; 0) {
               fprintf(stderr, "Error allocating an audio buffer\n");
               exit(1);
           }
       }

       return frame;
    }

    static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
    {
       AVCodecContext *c;
       int nb_samples;
       int ret;
      AVDictionary *opt = NULL;

       c = ost->enc;

       /* open it */
       av_dict_copy(&amp;opt, opt_arg, 0);
       ret = avcodec_open2(c, codec, &amp;opt);
       av_dict_free(&amp;opt);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
           exit(1);
       }

       /* init signal generator */
       ost->t     = 0;
       ost->tincr = 2 * M_PI * 110.0 / c->sample_rate;
       /* increment frequency by 110 Hz per second */
       ost->tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;

       if (c->codec->capabilities &amp; AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
           nb_samples = 10000;
       else
           nb_samples = c->frame_size;

       ost->frame     = alloc_audio_frame(c->sample_fmt, c->channel_layout,
                                          c->sample_rate, nb_samples);
       ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
                                          c->sample_rate, nb_samples);

       /* copy the stream parameters to the muxer */
       ret = avcodec_parameters_from_context(ost->st->codecpar, c);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not copy the stream parameters\n");
           exit(1);
       }

       /* create resampler context */
           ost->swr_ctx = swr_alloc();
           if (!ost->swr_ctx) {
               fprintf(stderr, "Could not allocate resampler context\n");
               exit(1);
           }

           /* set options */
           av_opt_set_int       (ost->swr_ctx, "in_channel_count",   c->channels,       0);
           av_opt_set_int       (ost->swr_ctx, "in_sample_rate",     c->sample_rate,    0);
           av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt",      AV_SAMPLE_FMT_S16, 0);
           av_opt_set_int       (ost->swr_ctx, "out_channel_count",  c->channels,       0);
           av_opt_set_int       (ost->swr_ctx, "out_sample_rate",    c->sample_rate,    0);
           av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt",     c->sample_fmt,     0);

           /* initialize the resampling context */
           if ((ret = swr_init(ost->swr_ctx)) &lt; 0) {
               fprintf(stderr, "Failed to initialize the resampling context\n");
               exit(1);
           }
    }

    /* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
    * 'nb_channels' channels. */
    static AVFrame *get_audio_frame(OutputStream *ost)
    {
       AVFrame *frame = ost->tmp_frame;
       int j, i, v;
       int16_t *q = (int16_t*)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++) {
           v = (int)(sin(ost->t) * 10000);
           for (i = 0; i &lt; ost->enc->channels; i++)
               *q++ = v;
           ost->t     += ost->tincr;
           ost->tincr += ost->tincr2;
       }

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

       return frame;
    }

    /*
    * encode one audio frame and send it to the muxer
    * return 1 when encoding is finished, 0 otherwise
    */
    static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
    {
       AVCodecContext *c;
       AVPacket pkt = { 0 }; // data and size must be 0;
       AVFrame *frame;
       int ret;
       int got_packet;
       int dst_nb_samples;

       av_init_packet(&amp;pkt);
       c = ost->enc;

       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 &lt; 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 &lt; 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;
       }

       ret = avcodec_encode_audio2(c, &amp;pkt, frame, &amp;got_packet);
       if (ret &lt; 0) {
           fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
           exit(1);
       }

       if (got_packet) {
           ret = write_frame(oc, &amp;c->time_base, ost->st, &amp;pkt);
           if (ret &lt; 0) {
               fprintf(stderr, "Error while writing audio frame: %s\n",
                       av_err2str(ret));
               exit(1);
           }
       }

       return (frame || got_packet) ? 0 : 1;
    }

    /**************************************************************/
    /* video output */

    static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
    {
       AVFrame *picture;
       int ret;

       picture = av_frame_alloc();
       if (!picture)
           return NULL;

       picture->format = pix_fmt;
       picture->width  = width;
       picture->height = height;

       /* allocate the buffers for the frame data */
       ret = av_frame_get_buffer(picture, 32);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate frame data.\n");
           exit(1);
       }

       return picture;
    }

    static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
    {
       int ret;
       AVCodecContext *c = ost->enc;
       AVDictionary *opt = NULL;

       av_dict_copy(&amp;opt, opt_arg, 0);

       /* open the codec */
       ret = avcodec_open2(c, codec, &amp;opt);
       av_dict_free(&amp;opt);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
           exit(1);
       }

       /* allocate and init a re-usable frame */
       ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);
       if (!ost->frame) {
           fprintf(stderr, "Could not allocate video frame\n");
           exit(1);
       }

       /* If the output format is not YUV420P, then a temporary YUV420P
        * picture is needed too. It is then converted to the required
        * output format. */
       ost->tmp_frame = NULL;
       if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
           ost->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, c->width, c->height);
           if (!ost->tmp_frame) {
               fprintf(stderr, "Could not allocate temporary picture\n");
               exit(1);
           }
       }

       /* copy the stream parameters to the muxer */
       ret = avcodec_parameters_from_context(ost->st->codecpar, c);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not copy the stream parameters\n");
           exit(1);
       }
    }

    /* Prepare a dummy image. */
    static void fill_yuv_image(AVFrame *pict, int frame_index,
                              int width, int height)
    {
       int x, y, i;

       i = frame_index;

       /* Y */
       for (y = 0; y &lt; height; y++)
           for (x = 0; x &lt; width; x++)
               pict->data[0][y * pict->linesize[0] + x] = x + y + i * 3;

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

    static AVFrame *get_video_frame(OutputStream *ost)
    {
       AVCodecContext *c = ost->enc;

       /* check if we want to generate more frames */
       if (av_compare_ts(ost->next_pts, c->time_base,
                         STREAM_DURATION, (AVRational){ 1, 1 }) >= 0)
           return NULL;

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

       if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
           /* as we only generate a YUV420P picture, we must convert it
            * to the codec pixel format if needed */
           if (!ost->sws_ctx) {
               ost->sws_ctx = sws_getContext(c->width, c->height,
                                             AV_PIX_FMT_YUV420P,
                                             c->width, c->height,
                                             c->pix_fmt,
                                             SCALE_FLAGS, NULL, NULL, NULL);
               if (!ost->sws_ctx) {
                   fprintf(stderr,
                           "Could not initialize the conversion context\n");
                   exit(1);
               }
           }
           fill_yuv_image(ost->tmp_frame, ost->next_pts, c->width, c->height);
           sws_scale(ost->sws_ctx,
                     (const uint8_t * const *)ost->tmp_frame->data, ost->tmp_frame->linesize,
                     0, c->height, ost->frame->data, ost->frame->linesize);
       } else {
           fill_yuv_image(ost->frame, ost->next_pts, c->width, c->height);
       }

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

       return ost->frame;
    }

    /*
    * encode one video frame and send it to the muxer
    * return 1 when encoding is finished, 0 otherwise
    */
    static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
    {
       int ret;
       AVCodecContext *c;
       AVFrame *frame;
       int got_packet = 0;
       AVPacket pkt = { 0 };

       c = ost->enc;

       frame = get_video_frame(ost);

       av_init_packet(&amp;pkt);

       /* encode the image */
       ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_packet);
       if (ret &lt; 0) {
         fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
           exit(1);
       }

       if (got_packet) {
           ret = write_frame(oc, &amp;c->time_base, ost->st, &amp;pkt);
       } else {
           ret = 0;
       }

       if (ret &lt; 0) {
           fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
           exit(1);
       }

       return (frame || got_packet) ? 0 : 1;
    }

    static void close_stream(AVFormatContext *oc, OutputStream *ost)
    {
       avcodec_free_context(&amp;ost->enc);
       av_frame_free(&amp;ost->frame);
       av_frame_free(&amp;ost->tmp_frame);
       sws_freeContext(ost->sws_ctx);
       swr_free(&amp;ost->swr_ctx);
    }

    /**************************************************************/
    /* media file output */

    int main(int argc, char **argv)
    {
       OutputStream video_st = { 0 }, audio_st = { 0 };
       const char *filename;
       AVOutputFormat *fmt;
       AVFormatContext *oc;
       AVCodec *audio_codec, *video_codec;
       int ret;
       int have_video = 0, have_audio = 0;
       int encode_video = 0, encode_audio = 0;
       AVDictionary *opt = NULL;
       int i;

       /* Initialize libavcodec, and register all codecs and formats. */
       av_register_all();
       avformat_network_init();
       if (argc &lt; 2) {
           printf("usage: %s output_file\n"
                  "API example program to output a media file with libavformat.\n"
                  "This program generates a synthetic audio and video stream, encodes and\n"
                  "muxes them into a file named output_file.\n"
                  "The output format is automatically guessed according to the file extension.\n"
                  "Raw images can also be output by using '%%d' in the filename.\n"
                  "\n", argv[0]);
           return 1;
       }

       filename = argv[1];
       for (i = 2; i+1 &lt; argc; i+=2) {
           if (!strcmp(argv[i], "-flags") || !strcmp(argv[i], "-fflags"))
               av_dict_set(&amp;opt, argv[i]+1, argv[i+1], 0);
       }
      /* allocate the output media context */
       avformat_alloc_output_context2(&amp;oc, NULL, "rtsp", filename);
       if (!oc) {
           printf("Could not deduce output format from file extension: using MPEG.\n");
           avformat_alloc_output_context2(&amp;oc, NULL, "mpeg", filename);
       }
       if (!oc)
           return 1;

       fmt = oc->oformat;

       /* Add the audio and video streams using the default format codecs
        * and initialize the codecs. */
       if (fmt->video_codec != AV_CODEC_ID_NONE) {
           add_stream(&amp;video_st, oc, &amp;video_codec, fmt->video_codec);
           have_video = 1;
           encode_video = 1;
       }
       if (fmt->audio_codec != AV_CODEC_ID_NONE) {
           add_stream(&amp;audio_st, oc, &amp;audio_codec, fmt->audio_codec);
           have_audio = 1;
           encode_audio = 1;
       }

       /* Now that all the parameters are set, we can open the audio and
        * video codecs and allocate the necessary encode buffers. */
       if (have_video)
           open_video(oc, video_codec, &amp;video_st, opt);

       if (have_audio)
           open_audio(oc, audio_codec, &amp;audio_st, opt);

       av_dump_format(oc, 0, filename, 1);

       /* open the output file, if needed */
       if (!(fmt->flags &amp; AVFMT_NOFILE)) {
           ret = avio_open(&amp;oc->pb, filename, AVIO_FLAG_WRITE);
           if (ret &lt; 0) {
               fprintf(stderr, "Could not open '%s': %s\n", filename,
                       av_err2str(ret));
               return 1;
           }
       }

       /* Write the stream header, if any. */
       ret = avformat_write_header(oc, &amp;opt);
       if (ret &lt; 0) {
           fprintf(stderr, "Error occurred when opening output file: %s\n",
                   av_err2str(ret));
           return 1;
       }

       while (encode_video || encode_audio) {
           /* select the stream to encode */
           if (encode_video &amp;&amp;
              (!encode_audio || av_compare_ts(video_st.next_pts, video_st.enc->time_base,
                                               audio_st.next_pts, audio_st.enc->time_base) &lt;= 0)) {
               encode_video = !write_video_frame(oc, &amp;video_st);
           } else {
               encode_audio = !write_audio_frame(oc, &amp;audio_st);
           }
       }

       /* Write the trailer, if any. The trailer must be written before you
        * close the CodecContexts open when you wrote the header; otherwise
        * av_write_trailer() may try to use memory that was freed on
        * av_codec_close(). */
       av_write_trailer(oc);

       /* Close each codec. */
       if (have_video)
           close_stream(oc, &amp;video_st);
       if (have_audio)
           close_stream(oc, &amp;audio_st);

       if (!(fmt->flags &amp; AVFMT_NOFILE))
           /* Close the output file. */
           avio_closep(&amp;oc->pb);

       /* free the stream */
       avformat_free_context(oc);

       return 0;
    }

    After compiling it, I am running binary :

    $ ./muxing rtsp://127.0.0.1/test
    Output #0, rtsp, to 'rtsp://127.0.0.1/test':
       Stream #0:0: Video: mpeg4, yuv420p, 352x288, q=2-31, 400 kb/s, 25 tbn
       Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 64 kb/s
    [tcp @ 0x2b9d220] Connection to tcp://127.0.0.1:554?timeout=0 failed: Connection refused
    Error occurred when opening output file: Connection refused

    But getting Connection refused error,

  • ffmpeg error "Could not allocate picture : Invalid argument Found Video Stream Found Audio Stream"

    26 octobre 2020, par Dinkan

    I am trying to write a C program to stream AV by copying both AV codecs with rtp_mpegts using RTP over network

    &#xA;

    ffmpeg -re -i Sample_AV_15min.ts -acodec copy -vcodec copy -f rtp_mpegts rtp://192.168.1.1:5004&#xA;

    &#xA;

    using muxing.c as example which used ffmpeg libraries.&#xA;ffmpeg application works fine.

    &#xA;

    Stream details

    &#xA;

    Input #0, mpegts, from &#x27;Weather_Nation_10min.ts&#x27;:&#xA;  Duration: 00:10:00.38, start: 41313.400811, bitrate: 2840 kb/s&#xA;  Program 1&#xA;    Stream #0:0[0x11]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc&#xA;    Stream #0:1[0x14]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 448 kb/s&#xA;Output #0, rtp_mpegts, to &#x27;rtp://192.168.1.1:5004&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf54.63.104&#xA;    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 1440x1080 [SAR 4:3 DAR 16:9], q=2-31, 29.97 fps, 90k tbn, 29.97 tbc&#xA;    Stream #0:1: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, 448 kb/s&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (copy)&#xA;  Stream #0:1 -> #0:1 (copy)&#xA;

    &#xA;

    However, my application fails with

    &#xA;

    ./my_test_app Sample_AV_15min.ts rtp://192.168.1.1:5004  &#xA;[h264 @ 0x800b30] non-existing PPS referenced                                  &#xA;[h264 @ 0x800b30] non-existing PPS 0 referenced                        &#xA;[h264 @ 0x800b30] decode_slice_header error                            &#xA;[h264 @ 0x800b30] no frame! &#xA;&#xA;[....snipped...]&#xA;[h264 @ 0x800b30] non-existing PPS 0 referenced        &#xA;[h264 @ 0x800b30] non-existing PPS referenced  &#xA;[h264 @ 0x800b30] non-existing PPS 0 referenced  &#xA;[h264 @ 0x800b30] decode_slice_header error  &#xA;[h264 @ 0x800b30] no frame!  &#xA;[h264 @ 0x800b30] mmco: unref short failure  &#xA;[h264 @ 0x800b30] mmco: unref short failure&#xA;&#xA;[mpegts @ 0x800020] max_analyze_duration 5000000 reached at 5024000 microseconds  &#xA;[mpegts @ 0x800020] PES packet size mismatch could not find codec tag for codec id &#xA;17075200, default to 0.  could not find codec tag for codec id 86019, default to 0.  &#xA;Could not allocate picture: Invalid argument  &#xA;Found Video Stream Found Audio Stream&#xA;

    &#xA;

    How do I fix this ? My complete source code based on muxing.c

    &#xA;

    /**&#xA; * @file&#xA; * libavformat API example.&#xA; *&#xA; * Output a media file in any supported libavformat format.&#xA; * The default codecs are used.&#xA; * @example doc/examples/muxing.c&#xA; */&#xA;&#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;&#xA;#include <libavutil></libavutil>mathematics.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;&#xA;/* 5 seconds stream duration */&#xA;#define STREAM_DURATION   200.0&#xA;#define STREAM_FRAME_RATE 25 /* 25 images/s */&#xA;#define STREAM_NB_FRAMES  ((int)(STREAM_DURATION * STREAM_FRAME_RATE))&#xA;#define STREAM_PIX_FMT    AV_PIX_FMT_YUV420P /* default pix_fmt */&#xA;&#xA;static int sws_flags = SWS_BICUBIC;&#xA;&#xA;/**************************************************************/&#xA;/* audio output */&#xA;&#xA;static float t, tincr, tincr2;&#xA;static int16_t *samples;&#xA;static int audio_input_frame_size;&#xA;#if 0&#xA;/* Add an output stream. */&#xA;static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,&#xA;                            enum AVCodecID codec_id)&#xA;{&#xA;    AVCodecContext *c;&#xA;    AVStream *st;&#xA;&#xA;    /* find the encoder */&#xA;    *codec = avcodec_find_encoder(codec_id);&#xA;    if (!(*codec)) {&#xA;        fprintf(stderr, "Could not find encoder for &#x27;%s&#x27;\n",&#xA;                avcodec_get_name(codec_id));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    st = avformat_new_stream(oc, *codec);&#xA;    if (!st) {&#xA;        fprintf(stderr, "Could not allocate stream\n");&#xA;        exit(1);&#xA;    }&#xA;    st->id = oc->nb_streams-1;&#xA;    c = st->codec;&#xA;&#xA;    switch ((*codec)->type) {&#xA;    case AVMEDIA_TYPE_AUDIO:&#xA;        st->id = 1;&#xA;        c->sample_fmt  = AV_SAMPLE_FMT_S16;&#xA;        c->bit_rate    = 64000;&#xA;        c->sample_rate = 44100;&#xA;        c->channels    = 2;&#xA;        break;&#xA;&#xA;    case AVMEDIA_TYPE_VIDEO:&#xA;        c->codec_id = codec_id;&#xA;&#xA;        c->bit_rate = 400000;&#xA;        /* Resolution must be a multiple of two. */&#xA;        c->width    = 352;&#xA;        c->height   = 288;&#xA;        /* timebase: This is the fundamental unit of time (in seconds) in terms&#xA;         * of which frame timestamps are represented. For fixed-fps content,&#xA;         * timebase should be 1/framerate and timestamp increments should be&#xA;         * identical to 1. */&#xA;        c->time_base.den = STREAM_FRAME_RATE;&#xA;        c->time_base.num = 1;&#xA;        c->gop_size      = 12; /* emit one intra frame every twelve frames at most */&#xA;        c->pix_fmt       = STREAM_PIX_FMT;&#xA;        if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {&#xA;            /* just for testing, we also add B frames */&#xA;            c->max_b_frames = 2;&#xA;        }&#xA;        if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {&#xA;            /* Needed to avoid using macroblocks in which some coeffs overflow.&#xA;             * This does not happen with normal video, it just happens here as&#xA;             * the motion of the chroma plane does not match the luma plane. */&#xA;            c->mb_decision = 2;&#xA;        }&#xA;    break;&#xA;&#xA;    default:&#xA;        break;&#xA;    }&#xA;&#xA;    /* Some formats want stream headers to be separate. */&#xA;    if (oc->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;        c->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;    return st;&#xA;}&#xA;#endif &#xA;/**************************************************************/&#xA;/* audio output */&#xA;&#xA;static float t, tincr, tincr2;&#xA;static int16_t *samples;&#xA;static int audio_input_frame_size;&#xA;&#xA;static void open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st)&#xA;{&#xA;    AVCodecContext *c;&#xA;    int ret;&#xA;&#xA;    c = st->codec;&#xA;&#xA;    /* open it */&#xA;    ret = avcodec_open2(c, codec, NULL);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* init signal generator */&#xA;    t     = 0;&#xA;    tincr = 2 * M_PI * 110.0 / c->sample_rate;&#xA;    /* increment frequency by 110 Hz per second */&#xA;    tincr2 = 2 * M_PI * 110.0 / c->sample_rate / c->sample_rate;&#xA;&#xA;    if (c->codec->capabilities &amp; CODEC_CAP_VARIABLE_FRAME_SIZE)&#xA;        audio_input_frame_size = 10000;&#xA;    else&#xA;        audio_input_frame_size = c->frame_size;&#xA;    samples = av_malloc(audio_input_frame_size *&#xA;                        av_get_bytes_per_sample(c->sample_fmt) *&#xA;                        c->channels);&#xA;    if (!samples) {&#xA;        fprintf(stderr, "Could not allocate audio samples buffer\n");&#xA;        exit(1);&#xA;    }&#xA;}&#xA;&#xA;/* Prepare a 16 bit dummy audio frame of &#x27;frame_size&#x27; samples and&#xA; * &#x27;nb_channels&#x27; channels. */&#xA;static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels)&#xA;{&#xA;    int j, i, v;&#xA;    int16_t *q;&#xA;&#xA;    q = samples;&#xA;    for (j = 0; j &lt; frame_size; j&#x2B;&#x2B;) {&#xA;        v = (int)(sin(t) * 10000);&#xA;        for (i = 0; i &lt; nb_channels; i&#x2B;&#x2B;)&#xA;            *q&#x2B;&#x2B; = v;&#xA;        t     &#x2B;= tincr;&#xA;        tincr &#x2B;= tincr2;&#xA;    }&#xA;}&#xA;&#xA;static void write_audio_frame(AVFormatContext *oc, AVStream *st)&#xA;{&#xA;    AVCodecContext *c;&#xA;    AVPacket pkt = { 0 }; // data and size must be 0;&#xA;    AVFrame *frame = avcodec_alloc_frame();&#xA;    int got_packet, ret;&#xA;&#xA;    av_init_packet(&amp;pkt);&#xA;    c = st->codec;&#xA;&#xA;    get_audio_frame(samples, audio_input_frame_size, c->channels);&#xA;    frame->nb_samples = audio_input_frame_size;&#xA;    avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,&#xA;                             (uint8_t *)samples,&#xA;                             audio_input_frame_size *&#xA;                             av_get_bytes_per_sample(c->sample_fmt) *&#xA;                             c->channels, 1);&#xA;&#xA;    ret = avcodec_encode_audio2(c, &amp;pkt, frame, &amp;got_packet);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if (!got_packet)&#xA;        return;&#xA;&#xA;    pkt.stream_index = st->index;&#xA;&#xA;    /* Write the compressed frame to the media file. */&#xA;    ret = av_interleaved_write_frame(oc, &amp;pkt);&#xA;    if (ret != 0) {&#xA;        fprintf(stderr, "Error while writing audio frame: %s\n",&#xA;                av_err2str(ret));&#xA;        exit(1);&#xA;    }&#xA;    avcodec_free_frame(&amp;frame);&#xA;}&#xA;&#xA;static void close_audio(AVFormatContext *oc, AVStream *st)&#xA;{&#xA;    avcodec_close(st->codec);&#xA;&#xA;    av_free(samples);&#xA;}&#xA;&#xA;/**************************************************************/&#xA;/* video output */&#xA;&#xA;static AVFrame *frame;&#xA;static AVPicture src_picture, dst_picture;&#xA;static int frame_count;&#xA;&#xA;static void open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st)&#xA;{&#xA;    int ret;&#xA;    AVCodecContext *c = st->codec;&#xA;&#xA;    /* open the codec */&#xA;    ret = avcodec_open2(c, codec, NULL);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* allocate and init a re-usable frame */&#xA;    frame = avcodec_alloc_frame();&#xA;    if (!frame) {&#xA;        fprintf(stderr, "Could not allocate video frame\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* Allocate the encoded raw picture. */&#xA;    ret = avpicture_alloc(&amp;dst_picture, c->pix_fmt, c->width, c->height);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Could not allocate picture: %s\n", av_err2str(ret));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* If the output format is not YUV420P, then a temporary YUV420P&#xA;     * picture is needed too. It is then converted to the required&#xA;     * output format. */&#xA;    if (c->pix_fmt != AV_PIX_FMT_YUV420P) {&#xA;        ret = avpicture_alloc(&amp;src_picture, AV_PIX_FMT_YUV420P, c->width, c->height);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not allocate temporary picture: %s\n",&#xA;                    av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;&#xA;    /* copy data and linesize picture pointers to frame */&#xA;    *((AVPicture *)frame) = dst_picture;&#xA;}&#xA;&#xA;/* Prepare a dummy image. */&#xA;static void fill_yuv_image(AVPicture *pict, int frame_index,&#xA;                           int width, int height)&#xA;{&#xA;    int x, y, i;&#xA;&#xA;    i = frame_index;&#xA;&#xA;    /* Y */&#xA;    for (y = 0; y &lt; height; y&#x2B;&#x2B;)&#xA;        for (x = 0; x &lt; width; x&#x2B;&#x2B;)&#xA;            pict->data[0][y * pict->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;&#xA;    /* Cb and Cr */&#xA;    for (y = 0; y &lt; height / 2; y&#x2B;&#x2B;) {&#xA;        for (x = 0; x &lt; width / 2; x&#x2B;&#x2B;) {&#xA;            pict->data[1][y * pict->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;            pict->data[2][y * pict->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;static void write_video_frame(AVFormatContext *oc, AVStream *st)&#xA;{&#xA;    int ret;&#xA;    static struct SwsContext *sws_ctx;&#xA;    AVCodecContext *c = st->codec;&#xA;&#xA;    if (frame_count >= STREAM_NB_FRAMES) {&#xA;        /* No more frames to compress. The codec has a latency of a few&#xA;         * frames if using B-frames, so we get the last frames by&#xA;         * passing the same picture again. */&#xA;    } else {&#xA;        if (c->pix_fmt != AV_PIX_FMT_YUV420P) {&#xA;            /* as we only generate a YUV420P picture, we must convert it&#xA;             * to the codec pixel format if needed */&#xA;            if (!sws_ctx) {&#xA;                sws_ctx = sws_getContext(c->width, c->height, AV_PIX_FMT_YUV420P,&#xA;                                         c->width, c->height, c->pix_fmt,&#xA;                                         sws_flags, NULL, NULL, NULL);&#xA;                if (!sws_ctx) {&#xA;                    fprintf(stderr,&#xA;                            "Could not initialize the conversion context\n");&#xA;                    exit(1);&#xA;                }&#xA;            }&#xA;            fill_yuv_image(&amp;src_picture, frame_count, c->width, c->height);&#xA;            sws_scale(sws_ctx,&#xA;                      (const uint8_t * const *)src_picture.data, src_picture.linesize,&#xA;                      0, c->height, dst_picture.data, dst_picture.linesize);&#xA;        } else {&#xA;            fill_yuv_image(&amp;dst_picture, frame_count, c->width, c->height);&#xA;        }&#xA;    }&#xA;&#xA;    if (oc->oformat->flags &amp; AVFMT_RAWPICTURE) {&#xA;        /* Raw video case - directly store the picture in the packet */&#xA;        AVPacket pkt;&#xA;        av_init_packet(&amp;pkt);&#xA;&#xA;        pkt.flags        |= AV_PKT_FLAG_KEY;&#xA;        pkt.stream_index  = st->index;&#xA;        pkt.data          = dst_picture.data[0];&#xA;        pkt.size          = sizeof(AVPicture);&#xA;&#xA;        ret = av_interleaved_write_frame(oc, &amp;pkt);&#xA;    } else {&#xA;        /* encode the image */&#xA;        AVPacket pkt;&#xA;        int got_output;&#xA;&#xA;        av_init_packet(&amp;pkt);&#xA;        pkt.data = NULL;    // packet data will be allocated by the encoder&#xA;        pkt.size = 0;&#xA;&#xA;        ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_output);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;&#xA;        /* If size is zero, it means the image was buffered. */&#xA;        if (got_output) {&#xA;            if (c->coded_frame->key_frame)&#xA;                pkt.flags |= AV_PKT_FLAG_KEY;&#xA;&#xA;            pkt.stream_index = st->index;&#xA;&#xA;            /* Write the compressed frame to the media file. */&#xA;            ret = av_interleaved_write_frame(oc, &amp;pkt);&#xA;        } else {&#xA;            ret = 0;&#xA;        }&#xA;    }&#xA;    if (ret != 0) {&#xA;        fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));&#xA;        exit(1);&#xA;    }&#xA;    frame_count&#x2B;&#x2B;;&#xA;}&#xA;&#xA;static void close_video(AVFormatContext *oc, AVStream *st)&#xA;{&#xA;    avcodec_close(st->codec);&#xA;    av_free(src_picture.data[0]);&#xA;    av_free(dst_picture.data[0]);&#xA;    av_free(frame);&#xA;}&#xA;&#xA;/**************************************************************/&#xA;/* media file output */&#xA;&#xA;int main(int argc, char **argv)&#xA;{&#xA;    const char *filename;&#xA;    AVOutputFormat *fmt;&#xA;    AVFormatContext *oc;&#xA;    AVStream *audio_st, *video_st;&#xA;    AVCodec *audio_codec, *video_codec;&#xA;    double audio_pts, video_pts;&#xA;    int ret;&#xA;    char errbuf[50];&#xA;    int i = 0;&#xA;    /* Initialize libavcodec, and register all codecs and formats. */&#xA;    av_register_all();&#xA;&#xA;    if (argc != 3) {&#xA;        printf("usage: %s input_file out_file|stream\n"&#xA;               "API example program to output a media file with libavformat.\n"&#xA;               "This program generates a synthetic audio and video stream, encodes and\n"&#xA;               "muxes them into a file named output_file.\n"&#xA;               "The output format is automatically guessed according to the file extension.\n"&#xA;               "Raw images can also be output by using &#x27;%%d&#x27; in the filename.\n"&#xA;               "\n", argv[0]);&#xA;        return 1;&#xA;    }&#xA;&#xA;    filename = argv[2];&#xA;&#xA;    /* allocate the output media context */&#xA;    avformat_alloc_output_context2(&amp;oc, NULL, "rtp_mpegts", filename);&#xA;    if (!oc) {&#xA;        printf("Could not deduce output format from file extension: using MPEG.\n");&#xA;        avformat_alloc_output_context2(&amp;oc, NULL, "mpeg", filename);&#xA;    }&#xA;    if (!oc) {&#xA;        return 1;&#xA;    }&#xA;    fmt = oc->oformat;&#xA;    //Find input stream info.&#xA;&#xA;   video_st = NULL;&#xA;   audio_st = NULL;&#xA;&#xA;   avformat_open_input( &amp;oc, argv[1], 0, 0);&#xA;&#xA;   if ((ret = avformat_find_stream_info(oc, 0))&lt; 0)&#xA;   {&#xA;       av_strerror(ret, errbuf,sizeof(errbuf));&#xA;       printf("Not Able to find stream info::%s ", errbuf);&#xA;       ret = -1;&#xA;       return ret;&#xA;   }&#xA;   for (i = 0; i &lt; oc->nb_streams; i&#x2B;&#x2B;)&#xA;   {&#xA;       if(oc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;       {&#xA;           AVCodecContext *codec_ctx;&#xA;           unsigned int tag = 0;&#xA;&#xA;           printf("Found Video Stream ");&#xA;           video_st = oc->streams[i];&#xA;           codec_ctx = video_st->codec;&#xA;           // m_num_frames = oc->streams[i]->nb_frames;&#xA;           video_codec = avcodec_find_decoder(codec_ctx->codec_id);&#xA;           ret = avcodec_open2(codec_ctx, video_codec, NULL);&#xA;            if (ret &lt; 0) &#xA;            {&#xA;                av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);&#xA;                return ret;&#xA;            }&#xA;            if (av_codec_get_tag2(oc->oformat->codec_tag, video_codec->id, &amp;tag) == 0) &#xA;            {&#xA;                av_log(NULL, AV_LOG_ERROR, "could not find codec tag for codec id %d, default to 0.\n", audio_codec->id);&#xA;            }&#xA;            video_st->codec = avcodec_alloc_context3(video_codec);&#xA;            video_st->codec->codec_tag = tag;&#xA;       }&#xA;&#xA;       if(oc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)&#xA;       {&#xA;           AVCodecContext *codec_ctx;&#xA;           unsigned int tag = 0;&#xA;&#xA;           printf("Found Audio Stream ");&#xA;           audio_st = oc->streams[i];&#xA;          // aud_dts = audio_st->cur_dts;&#xA;          // aud_pts = audio_st->last_IP_pts;           &#xA;          codec_ctx = audio_st->codec;&#xA;          audio_codec = avcodec_find_decoder(codec_ctx->codec_id);&#xA;          ret = avcodec_open2(codec_ctx, audio_codec, NULL);&#xA;          if (ret &lt; 0) &#xA;          {&#xA;             av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i);&#xA;             return ret;&#xA;          }&#xA;          if (av_codec_get_tag2(oc->oformat->codec_tag, audio_codec->id, &amp;tag) == 0) &#xA;          {&#xA;              av_log(NULL, AV_LOG_ERROR, "could not find codec tag for codec id %d, default to 0.\n", audio_codec->id);&#xA;          }&#xA;          audio_st->codec = avcodec_alloc_context3(audio_codec);&#xA;          audio_st->codec->codec_tag = tag;&#xA;       }&#xA;   }&#xA;    /* Add the audio and video streams using the default format codecs&#xA;     * and initialize the codecs. */&#xA;    /*&#xA;    if (fmt->video_codec != AV_CODEC_ID_NONE) {&#xA;        video_st = add_stream(oc, &amp;video_codec, fmt->video_codec);&#xA;    }&#xA;    if (fmt->audio_codec != AV_CODEC_ID_NONE) {&#xA;        audio_st = add_stream(oc, &amp;audio_codec, fmt->audio_codec);&#xA;    }&#xA;    */&#xA;&#xA;    /* Now that all the parameters are set, we can open the audio and&#xA;     * video codecs and allocate the necessary encode buffers. */&#xA;    if (video_st)&#xA;        open_video(oc, video_codec, video_st);&#xA;    if (audio_st)&#xA;        open_audio(oc, audio_codec, audio_st);&#xA;&#xA;    av_dump_format(oc, 0, filename, 1);&#xA;&#xA;    /* open the output file, if needed */&#xA;    if (!(fmt->flags &amp; AVFMT_NOFILE)) {&#xA;        ret = avio_open(&amp;oc->pb, filename, AVIO_FLAG_WRITE);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open &#x27;%s&#x27;: %s\n", filename,&#xA;                    av_err2str(ret));&#xA;            return 1;&#xA;        }&#xA;    }&#xA;&#xA;    /* Write the stream header, if any. */&#xA;    ret = avformat_write_header(oc, NULL);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Error occurred when opening output file: %s\n",&#xA;                av_err2str(ret));&#xA;        return 1;&#xA;    }&#xA;&#xA;    if (frame)&#xA;        frame->pts = 0;&#xA;    for (;;) {&#xA;        /* Compute current audio and video time. */&#xA;        if (audio_st)&#xA;            audio_pts = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;&#xA;        else&#xA;            audio_pts = 0.0;&#xA;&#xA;        if (video_st)&#xA;            video_pts = (double)video_st->pts.val * video_st->time_base.num /&#xA;                        video_st->time_base.den;&#xA;        else&#xA;            video_pts = 0.0;&#xA;&#xA;        if ((!audio_st || audio_pts >= STREAM_DURATION) &amp;&amp;&#xA;            (!video_st || video_pts >= STREAM_DURATION))&#xA;            break;&#xA;&#xA;        /* write interleaved audio and video frames */&#xA;        if (!video_st || (video_st &amp;&amp; audio_st &amp;&amp; audio_pts &lt; video_pts)) {&#xA;            write_audio_frame(oc, audio_st);&#xA;        } else {&#xA;            write_video_frame(oc, video_st);&#xA;            frame->pts &#x2B;= av_rescale_q(1, video_st->codec->time_base, video_st->time_base);&#xA;        }&#xA;    }&#xA;&#xA;    /* Write the trailer, if any. The trailer must be written before you&#xA;     * close the CodecContexts open when you wrote the header; otherwise&#xA;     * av_write_trailer() may try to use memory that was freed on&#xA;     * av_codec_close(). */&#xA;    av_write_trailer(oc);&#xA;&#xA;    /* Close each codec. */&#xA;    if (video_st)&#xA;        close_video(oc, video_st);&#xA;    if (audio_st)&#xA;        close_audio(oc, audio_st);&#xA;&#xA;    if (!(fmt->flags &amp; AVFMT_NOFILE))&#xA;        /* Close the output file. */&#xA;        avio_close(oc->pb);&#xA;&#xA;    /* free the stream */&#xA;    avformat_free_context(oc);&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

  • The Ultimate List of Alternatives to Google Products

    2 août 2022, par Erin — Privacy

    For many businesses, Google products can play an integral part in the productivity, function and even success of the company. This is because Google has designed their digital ecosystem to infiltrate every aspect of your work and personal life at low-to-no cost.

    On the surface, this seems like a no-brainer. Why not have a cost-effective and seamlessly connected tech stack ? It’s the complete package. 

    From Gmail to Google Analytics, it becomes hard to untangle yourself from this intricate web Google has managed to spin. But like a web, you know there’s also a catch.

    This leads us to the big question… Why stop ?

    In this blog, we’ll cover :

    Why de-Google ?

    Google products are convenient and seemingly free. However, in recent years, Google’s name has become synonymous with privacy breaches, data leaks and illegal under the General Data Protection Regulation (GDPR).

    As their track record shows a glaring disregard for data protection, a growing list of EU member countries like Austria, France, Denmark and Italy have banned Google products, such as Google Analytics, Google Workspace and Google Chromebook.

    Google offers free products and services, but not out of altruism. There’s a trade-off. By using Google’s “free” products, your customers’ and your own online activity becomes a commodity that can be sold to advertisers.

    When the risks of using Google products are considered, it becomes clear the need to plot a pathway to de-Google your business. If you’re wondering how in the world to uncoil from this web, fortunately, there are plenty of privacy-friendly, secure alternatives to Google products that you can choose.

    Disclaimer : Below, we’ve tried our best to provide a comprehensive list of alternatives to Google products for businesses, but because you know your business best, we’d also encourage you to do your own research to ensure the tool will suit your unique needs.

    Best Google alternative tools for business

    Overall business tools

    Google Workspace alternatives

    Google Workspace isn’t GDPR compliant by default, so businesses are at risk of fines and reputational damage. More EU countries are reaching the same conclusion that Google products are violating EU law. Data Protection Authorities from Norway and Denmark have deemed Google Workspace illegal in accordance with the GDPR. 

    Nextcloud

    Nextcloud is an open-source and self-hosted productivity platform that offers a suite of services to replace the major features found in Google Workspace, such as Google Drive, Calendar, Docs, Forms and Tasks. 

    You can share files and collaborate without worrying about data being shared with unauthorised individuals or companies. As a self-hosted suite, you’re in full control of where your data is, who has access to it and can comply with the strictest of data protection legislations.

    Nextcloud dashboard
    Zoho

    Zoho is a Google Workspace alternative built on the same principles as Google’s productivity suite. It offers a suite of online office tools, including email, calendar and task management, but with an emphasis on privacy protection. Zoho doesn’t rely on advertising revenue to support their business which means your personal data will never be sold or used for targeted ads. 

    With over 75 million users globally, Zoho offers data encryption at rest and at transit, multi-factor authentication and complies with strict security standards set by HIPAA, the Cloud Security Alliance and the GDPR.

    Zoho dashboard

    Gmail alternatives

    Google only encrypts emails via STARTTLS. In other words, your data isn’t end-to-end encrypted and can be decrypted by them at any time. Gmail also has a history of allowing third-party app developers that work with Gmail to access private and personal Gmail messages for their own market research purposes.

    ProtonMail

    ProtonMail is a secure, open-source email service that provides end-to-end encryption, so only the sender and receiver can access the messages. Proton deliberately doesn’t possess the key needed to decrypt any part of the message, so you know your sensitive business information is always private. 

    To protect users from digital surveillance, they also provide enhanced tracking protections and don’t rely on ads, so your data isn’t mined for advertising purposes. Not only that, you can also sync ProtonMail with a host of other Google alternative products, such as Proton Calendar and Proton Drive.

    Proton Mail
    Mailfence

    Mailfence is a highly secure communications and planning platform that offers a complete email suite, as well as, Documents, a Calendar and Groups. It provides end-to-end encryption and comes with a built-in data loss prevention system that prevents unauthorised access to your sensitive information. 

    Mailfence is completely ad-free and promises to never commercialise its databases or share data with third parties for targeted ads.

    Mailfence
    Tutanota

    Tutanota is an open-source email service known as one of the first to offer end-to-end encryption. It boasts a user-friendly interface and offers a fast, simple and secure email service that works on web and mobile platforms. Stringent security, in addition to TOTP and U2F for two-factor authentication means you control who has access to your email and messages. 

    It requires no phone number or personal information to register for a free account. In addition, Tutanota doesn’t earn money through ads, its servers are based in Europe and it is fully GDPR compliant.

    Google Calendar alternatives

    Calendars can contain a lot of personal information (who you are meeting, location, contact info, etc.), which is well worth keeping private. 

    Proton Calendar

    With Proton Calendar all event details – participants, locations, event names, descriptions and notes are end-to-end encrypted. It has a clean and easy-to-use interface, and you get a full set of advanced features to replace Google Calendar, such as the ability to create events and reminders, add multiple calendars and set up repeating events. You can easily sync all your calendars between mobile and desktop apps.

    Mailfence Calendar

    Mailfence Calendar lets you manage, schedule and track your events and meetings. Similar to Google Calendar, you can invite people to events using their Mailfence email IDs, but it doesn’t track your location or email address.

    Tutanota Calendar

    Tutanota Calendar offers built-in encryption, so no one else can decrypt and read your information.

    You can keep track of your appointments and meetings in a secure environment that only you have access to. You get features, such as day/week/month view, all-day events, recurring events, upcoming events view and shared calendars. You can also sync it with other apps such as Outlook.

    Tutanota calendar event
    Nextcloud Calendar app

    Nextcloud also offers a Calendar app which easily syncs events from different devices with your Nextcloud account. You can integrate it with other Nextcloud apps like Contacts, Talk and Tasks.

    Nextcloud calendar

    Google Drive alternatives

    The GDPR emphasises end-to-end encryption as a safeguard against data leaks, but Google Drive isn’t end-to-end encrypted, so Google has access to the data on its servers. 

    In their privacy policy, they also state that this data can be analysed for advertising purposes, so although you’re using “free” Cloud storage, users need to be aware that they’re paying for this by giving Google access to any and all data stored in Google Drive.

    Proton Drive

    Proton Drive is a secure and private Cloud storage service that provides you with an easy-to-use, customisable and secure file management system.

    It uses end-to-end encryption to secure your data and keep it safe from prying eyes. As you have full control over your data, you can decide how long it’s stored and who has access to it. You can also choose how much of your information is shared with other users.

    Proton Drive
    Nextcloud

    Nextcloud works on your own server, so you can access and share your data wherever you are. It’s a file hosting service that lets you store files, sync them across your devices and collaborate with others on projects. 

    It also provides encryption for all the files that you store on its servers, so you can rest assured that no one can see your information without your permission.

    Nextcloud Drive
    Syncthing

    Syncthing is a free, open-source file synchronisation program that allows you to store and access your files wherever you are. It’s designed to be fast, secure and easy to use, making it a great alternative to Google Drive. 

    With Syncthing, you can sync files across multiple computers and mobile devices at once. So if you create, delete or modify files on one machine, they will automatically be replicated on other devices. Data is saved directly to a location you choose, so you can securely backup your data without needing a third-party cloud service.

    Google Docs alternatives

    Google states they can “collect information” from Google-hosted content such as Docs by means of automated scanning. 

    Not only does this stoke spying fears, it also raises concerns over who holds power over your content. If they look through your docs and decide that you’ve violated their terms of service, you can get locked out of your Google Docs – as was the case when a National Geographic crime reporter had her story “frozen” by Google.

    LibreOffice

    LibreOffice is a free, open-source office suite with all the features you need to create and edit documents, presentations and spreadsheets. It’s compatible with many different languages and all Microsoft Office file formats. 

    Unlike Google Docs, LibreOffice doesn’t store your documents on the Cloud. As it runs on your own computer, you maintain complete control and the data is kept as private and as secure as you wish. LibreOffice also has an online version that works with most web browsers and can be used on Windows, Mac and Linux operating systems. 

    The open-source nature ensures security as the code is constantly improved and scouted for vulnerabilities.

    Nextcloud Office

    Like Google Docs, Nextcloud Office lets you create new documents and spreadsheets and collaborate with teammates or colleagues. But unlike Google Docs, Nextcloud doesn’t collect any data on who is using its platform, or what they’re doing on it. You can even encrypt the files you store in Nextcloud, so no one else can see them unless you give them access to your account.

    Nextcloud Office

    Google Keep alternative

    Standard Notes

    Standard Notes is an open-source online notebook app that offers a variety of useful features, such as tasks, to-dos and spreadsheets. 

    Unlike Google Keep, which has access to your notes, Standard Notes is end-to-end encrypted, which protects all your information and keeps it securely synced across all your devices. Standard Notes supports text, images and audio notes. As open-source software, they value transparency and trust and don’t rely on tracking or intrusive ads.

    Standard notes dashboard

    Google Chrome alternatives

    Google Chrome is notorious for stalking users and collecting information for their own gains. Their browser fuels their data gathering infrastructure by being able to collect info about your search history, location, personal data and product interaction data for “personalisation” purposes – essentially to build a profile of you to sell to advertisers.

    Firefox

    Firefox is one of the most secure browsers for privacy and is trusted by 220 million users. It easily compares with Chrome in terms of ease of use and performance. 

    On top of that it offers enhanced privacy protections, so you get a browser that doesn’t stalk you and isn’t riddled with ads.

    Firefox