Recherche avancée

Médias (0)

Mot : - Tags -/médias

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

Autres articles (75)

  • Script d’installation automatique de MediaSPIP

    25 avril 2011, par

    Afin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
    Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
    La documentation de l’utilisation du script d’installation (...)

  • Automated installation script of MediaSPIP

    25 avril 2011, par

    To overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
    You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
    The documentation of the use of this installation script is available here.
    The code of this (...)

  • Organiser par catégorie

    17 mai 2013, par

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

Sur d’autres sites (4135)

  • How to decode mp4 file and encode it to mp4 container using h264 codec in cpp ?

    17 juillet 2017, par Herdesh Verma

    I am developing a cpp program which will take mp4 video file as input, decode it and encode it again using H264 codec.
    Below is the program i have developed so far.

    extern "C"
    {
    #include <libavutil></libavutil>imgutils.h>
    #include <libavutil></libavutil>opt.h>
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>samplefmt.h>
    #include <libavutil></libavutil>timestamp.h>
    #include <libavformat></libavformat>avformat.h>
    #include <libavfilter></libavfilter>avfiltergraph.h>
    #include <libswscale></libswscale>swscale.h>
    }
    #include
    static AVFormatContext *fmt_ctx = NULL;

    static int frame_index = 0;

    static AVDictionary *pMetaData = NULL;

    static int j = 0, nbytes=0;
    uint8_t *video_outbuf = NULL;
    static AVPacket *pAVPacket=NULL;
    static int value=0;
    static AVFrame *pAVFrame=NULL;
    static AVFrame *outFrame=NULL;
    static AVStream *video_st=NULL;
    static AVFormatContext *outAVFormatContext=NULL;
    static AVCodec *outAVCodec=NULL;
    static AVOutputFormat *output_format=NULL;
    static AVCodecContext *video_dec_ctx = NULL, *audio_dec_ctx;
    static AVCodecContext *outAVCodecContext=NULL;
    static int width, height;
    static enum AVPixelFormat pix_fmt;
    static AVStream *video_stream = NULL, *audio_stream = NULL;
    static const char *src_filename = NULL;
    static const char *video_dst_filename = NULL;
    static const char *audio_dst_filename = NULL;
    static FILE *video_dst_file = NULL;
    static FILE *audio_dst_file = NULL;
    static uint8_t *video_dst_data[4] = {NULL};
    static int      video_dst_linesize[4];
    static int video_dst_bufsize;
    static int video_stream_idx = -1, audio_stream_idx = -1;
    static AVPacket *pkt=NULL;
    static AVPacket *pkt1=NULL;
    static AVFrame *frame = NULL;
    //static AVPacket pkt;
    static int video_frame_count = 0;
    static int audio_frame_count = 0;
    static int refcount = 0;
    AVCodec *codec;
    static struct SwsContext *sws_ctx;
    AVCodecContext *c= NULL;
    int i, out_size, size, x, y, outbuf_size;
    AVFrame *picture;
    uint8_t *outbuf, *picture_buf;
    int video_outbuf_size;
    int w, h;
    AVPixelFormat pixFmt;
    uint8_t *data[4];
    int linesize[4];

    static int open_codec_context(int *stream_idx,
                             AVCodecContext **dec_ctx, AVFormatContext
    *fmt_ctx, enum AVMediaType type)
    {
    int ret, stream_index;
    AVStream *st;
    AVCodec *dec = NULL;
    AVDictionary *opts = NULL;
    ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
    if (ret &lt; 0) {
       printf("Could not find %s stream in input file '%s'\n",
               av_get_media_type_string(type), src_filename);
       return ret;
    } else {
       stream_index = ret;
       st = fmt_ctx->streams[stream_index];
       /* find decoder for the stream */
       dec = avcodec_find_decoder(st->codecpar->codec_id);
       if (!dec) {
           printf("Failed to find %s codec\n",
                   av_get_media_type_string(type));
           return AVERROR(EINVAL);
       }
       /* Allocate a codec context for the decoder */
       *dec_ctx = avcodec_alloc_context3(dec);
       if (!*dec_ctx) {
           printf("Failed to allocate the %s codec context\n",
                   av_get_media_type_string(type));
           return AVERROR(ENOMEM);
       }
       /* Copy codec parameters from input stream to output codec context */
       if ((ret = avcodec_parameters_to_context(*dec_ctx, st->codecpar)) &lt; 0) {
           printf("Failed to copy %s codec parameters to decoder context\n",
                   av_get_media_type_string(type));
           return ret;
       }
       /* Init the decoders, with or without reference counting */
       av_dict_set(&amp;opts, "refcounted_frames", refcount ? "1" : "0", 0);
       if ((ret = avcodec_open2(*dec_ctx, dec, &amp;opts)) &lt; 0) {
           printf("Failed to open %s codec\n",
                   av_get_media_type_string(type));
           return ret;
       }
       *stream_idx = stream_index;
    }
    return 0;
    }



    int main (int argc, char **argv)
    {
    int ret = 0, got_frame;
    src_filename = argv[1];
    video_dst_filename = argv[2];
    audio_dst_filename = argv[3];
    av_register_all();
    avcodec_register_all();
    printf("Registered all\n");

    /* open input file, and allocate format context */
    if (avformat_open_input(&amp;fmt_ctx, src_filename, NULL, NULL) &lt; 0) {
       printf("Could not open source file %s\n", src_filename);
       exit(1);
    }

    /* retrieve stream information */
    if (avformat_find_stream_info(fmt_ctx, NULL) &lt; 0) {
       printf("Could not find stream information\n");
       exit(1);
    }

    if (open_codec_context(&amp;video_stream_idx, &amp;video_dec_ctx, fmt_ctx,
    AVMEDIA_TYPE_VIDEO) >= 0) {
       video_stream = fmt_ctx->streams[video_stream_idx];
       avformat_alloc_output_context2(&amp;outAVFormatContext, NULL, NULL,
    video_dst_filename);
       if (!outAVFormatContext)
       {
               printf("\n\nError : avformat_alloc_output_context2()");
               return -1;
       }
    }

    if (open_codec_context(&amp;audio_stream_idx, &amp;audio_dec_ctx, fmt_ctx,
    AVMEDIA_TYPE_AUDIO) >= 0) {
       audio_stream = fmt_ctx->streams[audio_stream_idx];
       audio_dst_file = fopen(audio_dst_filename, "wb");
       if (!audio_dst_file) {
           printf("Could not open destination file %s\n", audio_dst_filename);
           ret = 1;
           goto end;
       }
    }
    /* dump input information to stderr */
       printf("Source file dump starts-----------------------\n");
    av_dump_format(fmt_ctx, 0, src_filename, 0);
       printf("Source file dump ends-----------------------\n");

    if (!audio_stream &amp;&amp; !video_stream) {
       printf("Could not find audio or video stream in the input, aborting\n");
       ret = 1;
       goto end;
    }

       output_format = av_guess_format(NULL, video_dst_filename, NULL);
       if( !output_format )
       {
        printf("\n\nError : av_guess_format()");
        return -1;
       }

       video_st = avformat_new_stream(outAVFormatContext ,NULL);
       if( !video_st )
       {
               printf("\n\nError : avformat_new_stream()");
         return -1;
       }



       outAVCodec = avcodec_find_encoder(AV_CODEC_ID_H264);
       if( !outAVCodec )
       {
        printf("\n\nError : avcodec_find_encoder()");
        return -1;
       }
       outAVCodecContext = avcodec_alloc_context3(outAVCodec);
       if( !outAVCodecContext )
       {
         printf("\n\nError : avcodec_alloc_context3()");
         return -1;
       }

       printf("Width=%d Height=%d\n",video_dec_ctx->width, video_dec_ctx-
    >height);

       outAVCodecContext = video_st->codec;
       outAVCodecContext->codec_id = AV_CODEC_ID_H264;// AV_CODEC_ID_MPEG4; //
    AV_CODEC_ID_H264 // AV_CODEC_ID_MPEG1VIDEO
       outAVCodecContext->codec_type = AVMEDIA_TYPE_VIDEO;
       outAVCodecContext->pix_fmt  = AV_PIX_FMT_YUV420P;
       outAVCodecContext->bit_rate = 350000; // 2500000
       outAVCodecContext->width = video_dec_ctx->width;
       outAVCodecContext->height = video_dec_ctx->height;
       //outAVCodecContext->width = 720;
       //outAVCodecContext->height = 480;
       outAVCodecContext->gop_size = 100;
       outAVCodecContext->max_b_frames = 0;
       outAVCodecContext->time_base.num = 1;
       outAVCodecContext->time_base.den = 25; // 15fps

       if (outAVCodecContext->codec_id == AV_CODEC_ID_H264)
       {
               printf("HERE");
       //outAVCodecContext->me_range = 16;
       //outAVCodecContext->max_qdiff = 4;
       outAVCodecContext->qmin = 10;
       outAVCodecContext->qmax = 51;
       outAVCodecContext->qcompress = 0.1;
        av_opt_set(outAVCodecContext->priv_data, "preset", "slow", 0);
       av_opt_set(outAVCodecContext->priv_data, "profile", "baseline",
    AV_OPT_SEARCH_CHILDREN);
       }
       if ( outAVFormatContext->oformat->flags &amp; AVFMT_GLOBALHEADER)
       {
               outAVCodecContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
       }

       value = avcodec_open2(outAVCodecContext, outAVCodec, NULL);
       if( value &lt; 0)
       {
               printf("\n\nError : avcodec_open2()=%d", value);
               return -1;
       }

       outAVFormatContext->metadata = fmt_ctx->metadata;
       //outAVFormatContext->streams[video_stream_idx]->metadata=fmt_ctx-
    >streams[video_stream_idx]->metadata;
       av_dict_set(&amp;(outAVFormatContext->streams[video_stream_idx]->metadata),
    "rotate", "90", 0);
    /* create empty video file */
       if ( !(outAVFormatContext->flags &amp; AVFMT_NOFILE) )
       {
        if( avio_open2(&amp;outAVFormatContext->pb , video_dst_filename,
    AVIO_FLAG_WRITE ,NULL, NULL) &lt; 0 )
        {
         printf("\n\nError : avio_open2()");
        }
       }

       if(!outAVFormatContext->nb_streams)
       {
               printf("\n\nError : Output file dose not contain any stream");
         return -1;
       }

       value = avformat_write_header(outAVFormatContext , NULL);
       if(value &lt; 0)
       {
               printf("\n\nError : avformat_write_header()");
               return -1;
       }

       printf("\n\nOutput file information :\n\n");
       av_dump_format(outAVFormatContext , 0 ,video_dst_filename ,1);


       int flag;
       int frameFinished;
       value = 0;

       pAVPacket = (AVPacket *)av_malloc(sizeof(AVPacket));
       av_init_packet(pAVPacket);

       pAVFrame = av_frame_alloc();
       if( !pAVFrame )
       {
        printf("\n\nError : av_frame_alloc()");
        return -1;
       }


       outFrame = av_frame_alloc();//Allocate an AVFrame and set its fields to
    default values.
       if( !outFrame )
       {
        printf("\n\nError : av_frame_alloc()");
        return -1;
       }
       outFrame->format = outAVCodecContext->pix_fmt;
       outFrame->width  = outAVCodecContext->width;
       outFrame->height = outAVCodecContext->height;

       nbytes = av_image_get_buffer_size(outAVCodecContext-
    >pix_fmt,outAVCodecContext->width,outAVCodecContext->height,32);
       video_outbuf = (uint8_t*)av_malloc(nbytes);
       if( video_outbuf == NULL )
       {
       printf("\n\nError : av_malloc()");
       }

       // Setup the data pointers and linesizes based on the specified image
    parameters and the provided array.
       value = av_image_fill_arrays( outFrame->data, outFrame->linesize,
    video_outbuf , AV_PIX_FMT_YUV420P, outAVCodecContext-
    >width,outAVCodecContext->height,1 ); // returns : the size in bytes
    required for src
       if(value &lt; 0)
       {
       printf("\n\nError : av_image_fill_arrays()");
       }

       SwsContext* swsCtx_ ;

       // Allocate and return swsContext.
       // a pointer to an allocated context, or NULL in case of error
       // Deprecated : Use sws_getCachedContext() instead.
       swsCtx_ = sws_getContext(video_dec_ctx->width,
                               video_dec_ctx->height,
                               video_dec_ctx->pix_fmt,
                               video_dec_ctx->width,
                               video_dec_ctx->height,
                               video_dec_ctx->pix_fmt,
                               SWS_BICUBIC, NULL, NULL, NULL);


       AVPacket outPacket;

       int got_picture;

       while( av_read_frame( fmt_ctx , pAVPacket ) >= 0 )
       {
               printf("Starting of while\n");
               if(pAVPacket->stream_index == video_stream_idx)
               {
                       value = avcodec_decode_video2(video_dec_ctx , pAVFrame ,
    &amp;frameFinished , pAVPacket );
                       if( value &lt; 0)
                       {
                               printf("Error : avcodec_decode_video2()");
                       }

                       if(frameFinished)// Frame successfully decoded :)
                       {
                               sws_scale(swsCtx_, pAVFrame->data, pAVFrame-
    >linesize,0, video_dec_ctx->height, outFrame->data,outFrame->linesize);
    //                              sws_scale(swsCtx_, pAVFrame->data, pAVFrame-
    >linesize,0, video_dec_ctx->height, outFrame->data,outFrame->linesize);
                               av_init_packet(&amp;outPacket);
                               outPacket.data = NULL;    // packet data will be
    allocated by the encoder
                               outPacket.size = 0;

                               avcodec_encode_video2(outAVCodecContext ,
    &amp;outPacket ,outFrame , &amp;got_picture);

                               if(got_picture)
                               {
                                       if(outPacket.pts != AV_NOPTS_VALUE)
                                               outPacket.pts =
    av_rescale_q(outPacket.pts, video_st->codec->time_base, video_st-
    >time_base);
                                       if(outPacket.dts != AV_NOPTS_VALUE)
                                               outPacket.dts =
    av_rescale_q(outPacket.dts, video_st->codec->time_base, video_st-
    >time_base);

                                       printf("Write frame %3d (size= %2d)\n",
    j++, outPacket.size/1000);
                                       if(av_write_frame(outAVFormatContext ,
    &amp;outPacket) != 0)
                                       {
                                               printf("\n\nError :
    av_write_frame()");
                                       }

                               av_packet_unref(&amp;outPacket);
                               } // got_picture

                       av_packet_unref(&amp;outPacket);
                       } // got_picture
               }
               printf("Ending of while\n");
       }// End of while-loop
       /* get the delayed frames */
    for (got_picture = 1; got_picture; i++) {
       //fflush(stdout);
       ret = avcodec_encode_video2(outAVCodecContext, &amp;outPacket, NULL,
    &amp;got_picture);
       if (ret &lt; 0) {
           printf("Error encoding frame\n");
           exit(1);
       }
       if (got_picture) {
           printf("Write frame %3d (size=%5d)\n", i, outPacket.size);
           av_write_frame(outAVFormatContext , &amp;outPacket);
           av_free_packet(&amp;outPacket);
       }
    }

       value = av_write_trailer(outAVFormatContext);
       if( value &lt; 0)
       {
               printf("\n\nError : av_write_trailer()");
       }

       //THIS WAS ADDED LATER
       av_free(video_outbuf);

    end:
       avcodec_free_context(&amp;video_dec_ctx);
       avcodec_free_context(&amp;audio_dec_ctx);
       avformat_close_input(&amp;fmt_ctx);
       if (video_dst_file)
           fclose(video_dst_file);
       if (audio_dst_file)
           fclose(audio_dst_file);
    //  av_frame_free(&amp;frame);
       av_free(video_dst_data[0]);
       return ret &lt; 0;
    }

    Above code is generating a mp4 file but it is not playing.
    Can someone please tell me what i am doing wrong ?

  • How to give real timestamp information to encoded frames inside mpeg1 container

    24 août 2021, par jackey balwani

    I referred following link for my implementation. https://ffmpeg.org/doxygen/trunk/muxing_8c_source.html&#xA;I am converting raw data rgb to yuv420 format through scaling and conversion apis available in FFMPEG and then passing the frames to MPEG1 encoder.&#xA;I observe that the encoded video plays too fast. Below is the code of encoding the frame and then writing it to output file.

    &#xA;

      static int write_frame(AVFormatContext *fmt_ctx, AVCodecContext *c,&#xA;                    AVStream *st, AVFrame *frame)&#xA;  {&#xA;    int ret;&#xA;&#xA;    // send the frame to the encoder&#xA;    ret = avcodec_send_frame(c, frame);&#xA;    if (ret &lt; 0) {&#xA;     fprintf(stderr, "Error sending a frame to the encoder: %s\n",&#xA;             av_err2str(ret));&#xA;     exit(1);&#xA;   }&#xA;&#xA;   while (ret >= 0) {&#xA;     AVPacket pkt = { 0 };&#xA;&#xA;     ret = avcodec_receive_packet(c, &amp;pkt);&#xA;     if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;         break;&#xA;     else if (ret &lt; 0) {&#xA;         fprintf(stderr, "Error encoding a frame: %s\n", av_err2str(ret));&#xA;         exit(1);&#xA;     }&#xA;&#xA;     /* rescale output packet timestamp values from codec to stream timebase */&#xA;     av_packet_rescale_ts(&amp;pkt, c->time_base, st->time_base);&#xA;     pkt.stream_index = st->index;&#xA;&#xA;     /* Write the compressed frame to the media file. */&#xA;     log_packet(fmt_ctx, &amp;pkt);&#xA;     ret = av_interleaved_write_frame(fmt_ctx, &amp;pkt);&#xA;     av_packet_unref(&amp;pkt);&#xA;     if (ret &lt; 0) {&#xA;         fprintf(stderr, "Error while writing output packet: %s\n", av_err2str(ret));&#xA;         exit(1);&#xA;     }&#xA; }&#xA;&#xA; return ret == AVERROR_EOF ? 1 : 0;&#xA;}&#xA;

    &#xA;

    resulting mpeg video's playback time is very quick, hence video gets played so fast.

    &#xA;

    so to match output video duration with input video coming from source, I am trying to pass following realtime information to Avframe structure before calling avcodec_send_frame() -

    &#xA;

      &#xA;
    1. realtime PTS value (current time + duration got through av_gettime() in microseconds) to AvFrame structure before calling avcodec_send_frame().

      &#xA;

    2. &#xA;

    3. populating pkt_duration with time difference between frames (current_PTS - previous_PTS)

      &#xA;

    4. &#xA;

    5. Removed this call av_packet_rescale_ts(&pkt, c->time_base, st->time_base) ; which is used after avcodec_receive_packet.

      &#xA;

    6. &#xA;

    &#xA;

    below highlighted code are the changes done for real time info-

    &#xA;

    **static int64_t m_currVideopts = 0;&#xA;static int64_t m_prevVideopts = 0;**&#xA;&#xA;static int write_frame(AVFormatContext *fmt_ctx, AVCodecContext *c, AVStream *st, AVFrame *frame)&#xA;{&#xA;  **int64_t pts = av_gettime();  // returns current time in micro seconds&#xA;  int64_t duration = 90000/STREAM_FRAME_RATE;    /*duration for first frame taken default as &#xA;   3600 as we dont have reference frame to compare diff */&#xA;  pts = av_rescale_q(pts, (AVRational){1, 1000000}, st->time_base);    //pAvStream->time_base - stream time base (1:90000)&#xA;  if((m_prevVideopts > 0LL) &amp;&amp; (pts > m_prevVideopts))&#xA;  {&#xA;    duration = pts - m_prevVideopts;&#xA;  }&#xA;  else if (pts &lt; m_prevVideopts)&#xA;  {&#xA;    pts = m_prevVideopts &#x2B; duration;&#xA;  }&#xA;  m_prevVideopts = pts;&#xA;  /* Going with the approach of pts value is equal to pts value for every  packet */&#xA;  frame->pts = m_currVideopts;    /*AV_NOPTS_VALUE; */&#xA;  m_currVideopts &#x2B;= duration;&#xA;  //pFfmpegVidCtx->next_pts = m_currVideopts;&#xA;  frame->pkt_duration = duration;**&#xA;&#xA; // send the frame to the encoder&#xA; ret = avcodec_send_frame(c, frame);&#xA; if (ret &lt; 0) {&#xA;     fprintf(stderr, "Error sending a frame to the encoder: %s\n",&#xA;             av_err2str(ret));&#xA;     exit(1);&#xA; }&#xA; ....&#xA; // receive the packet avcodec_receive_packet()&#xA; ...&#xA; &#xA; // removed or commented av_packet_rescale_ts&#xA; **/* av_packet_rescale_ts(&amp;pkt, c->time_base, st->time_base) */**&#xA; ret = av_interleaved_write_frame(fmt_ctx, &amp;pkt);&#xA;

    &#xA;

    }

    &#xA;

    with the above changes, video is not playing proper.&#xA;There are couple of issues with respect to total duration (some time it is not proper on player) and also some frames are getting dropped or lost while playing in vlc or media player.

    &#xA;

    enter image description here

    &#xA;

    I am unable to find the cause of these frames loss while playing. Is it the correct way of passing real time pts information to the encoder or any mistake in above code.&#xA;Any suggestion would help me proceed further,&#xA;thanks.

    &#xA;

  • ffmpeg hangs when running -i in alpine docker container cron job

    14 mai 2021, par Richard Westby-Nunn

    I'm see strange behaviour in ffmpeg not running the -i option ONLY when running as a cron job. I can run the command fine directly via the shell. The the cronjob command runs, and it even "starts" the ffmpeg "executable", but it then hangs when it gets to the -i option and arguments.

    &#xA;

    I have included a copy of a working output when run from the shell prompt to demonstrate what the output should show.

    &#xA;

    alpine : 3.13.5

    &#xA;

    docker image : alpine:latest (date : 2021-05-14)

    &#xA;

    docker run :

    &#xA;

    docker run -v s:\_docker\_alpine-test:/media/pi --name alpine -it alpine crond -f -l8

    &#xA;

    crontab script :

    &#xA;

    /media/pi/_site/pics-alpine.sh 2>&amp;1 | tee /media/pi/_site/alpine.log

    &#xA;

    /media/pi/_site/pics-alpine.sh script :

    &#xA;

    #!/bin/ash&#xA;&#xA;set -xv&#xA;&#xA;echo "START"&#xA;&#xA;#encode jpgs to mp4&#xA;/usr/bin/ffmpeg -i /media/pi/to-video-back/%04d.jpg  /media/pi/_site/back/back-latest.mp4&#xA;&#xA;echo "END"&#xA;

    &#xA;

    The output of the log file is :

    &#xA;

    echo "START"&#xA;&#x2B; echo START&#xA;START&#xA;&#xA;### encode jpgs to mp4&#xA;/usr/bin/ffmpeg -i /media/pi/to-video-back/%04d.jpg  /media/pi/_site/back/back-latest.mp4&#xA;&#x2B; /usr/bin/ffmpeg -i &#x27;/media/pi/to-video-back/%04d.jpg&#x27; /media/pi/_site/back/back-latest.mp4&#xA;ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with gcc 10.2.1 (Alpine 10.2.1_git20210328) 20210328&#xA;  configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --enable-vulkan --enable-libsoxr --enable-libwebp --enable-libaom --disable-debug&#xA;

    &#xA;

    Script output when run directly from the shell prompt :

    &#xA;

    /media/pi/_site # ./pics-alpine.sh&#xA;&#xA;echo "START"&#xA;&#x2B; echo START&#xA;START&#xA;&#xA;### encode jpgs to mp4&#xA;/usr/bin/ffmpeg -i /media/pi/to-video-back/%04d.jpg  /media/pi/_site/back/back-latest.mp4&#xA;&#x2B; /usr/bin/ffmpeg -i &#x27;/media/pi/to-video-back/%04d.jpg&#x27; /media/pi/_site/back/back-latest.mp4&#xA;ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with gcc 10.2.1 (Alpine 10.2.1_git20210328) 20210328&#xA;  configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-libdav1d --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --enable-libsrt --enable-libssh --enable-libvidstab --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --enable-vulkan --enable-libsoxr --enable-libwebp --enable-libaom --disable-debug&#xA;  libavutil      56. 70.100 / 56. 70.100&#xA;  libavcodec     58.134.100 / 58.134.100&#xA;  libavformat    58. 76.100 / 58. 76.100&#xA;  libavdevice    58. 13.100 / 58. 13.100&#xA;  libavfilter     7.110.100 /  7.110.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  9.100 /  5.  9.100&#xA;  libswresample   3.  9.100 /  3.  9.100&#xA;  libpostproc    55.  9.100 / 55.  9.100&#xA;Input #0, image2, from &#x27;/media/pi/to-video-back/%04d.jpg&#x27;:&#xA;  Duration: 00:00:00.96, start: 0.000000, bitrate: N/A&#xA;  Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x960, 25 fps, 25 tbr, 25 tbn, 25 tbc&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))&#xA;Press [q] to stop, [?] for help&#xA;[libx264 @ 0x7fd9cf099b00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2&#xA;[libx264 @ 0x7fd9cf099b00] profile High, level 3.2, 4:2:0, 8-bit&#xA;[libx264 @ 0x7fd9cf099b00] 264 - core 161 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00&#xA;Output #0, mp4, to &#x27;/media/pi/_site/back/back-latest.mp4&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf58.76.100&#xA;  Stream #0:0: Video: h264 (avc1 / 0x31637661), yuvj420p(pc, bt470bg/unknown/unknown, progressive), 1280x960, q=2-31, 25 fps, 12800 tbn&#xA;    Metadata:&#xA;      encoder         : Lavc58.134.100 libx264&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;frame=   24 fps=0.0 q=-1.0 Lsize=      25kB time=00:00:00.84 bitrate= 242.1kbits/s speed=1.56x&#xA;video:24kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.565835%&#xA;[libx264 @ 0x7fd9cf099b00] frame I:2     Avg QP:17.30  size:  3693&#xA;[libx264 @ 0x7fd9cf099b00] frame P:11    Avg QP:20.46  size:   854&#xA;[libx264 @ 0x7fd9cf099b00] frame B:11    Avg QP:22.05  size:   623&#xA;[libx264 @ 0x7fd9cf099b00] consecutive B-frames: 29.2% 25.0% 12.5% 33.3%&#xA;[libx264 @ 0x7fd9cf099b00] mb I  I16..4: 14.6% 83.5%  2.0%&#xA;[libx264 @ 0x7fd9cf099b00] mb P  I16..4:  3.0%  2.2%  0.0%  P16..4:  5.2%  0.1%  0.1%  0.0%  0.0%    skip:89.3%&#xA;[libx264 @ 0x7fd9cf099b00] mb B  I16..4:  0.4%  0.1%  0.0%  B16..8:  6.5%  0.0%  0.0%  direct: 0.1%  skip:92.9%  L0:35.0% L1:64.8% BI: 0.2%&#xA;[libx264 @ 0x7fd9cf099b00] 8x8 transform intra:73.3% inter:94.3%&#xA;[libx264 @ 0x7fd9cf099b00] coded y,uvDC,uvAC intra: 8.5% 12.1% 0.5% inter: 0.7% 3.3% 0.0%&#xA;[libx264 @ 0x7fd9cf099b00] i16 v,h,dc,p: 77% 15%  6%  2%&#xA;[libx264 @ 0x7fd9cf099b00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 71%  6% 20%  1%  1%  0%  1%  0%  0%&#xA;[libx264 @ 0x7fd9cf099b00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 55% 13% 24%  1%  3%  1%  1%  1%  1%&#xA;[libx264 @ 0x7fd9cf099b00] i8c dc,h,v,p: 92%  4%  4%  0%&#xA;[libx264 @ 0x7fd9cf099b00] Weighted P-Frames: Y:0.0% UV:0.0%&#xA;[libx264 @ 0x7fd9cf099b00] ref P L0: 57.6%  2.5% 30.8%  9.1%&#xA;[libx264 @ 0x7fd9cf099b00] ref B L0: 70.2% 27.6%  2.2%&#xA;[libx264 @ 0x7fd9cf099b00] ref B L1: 98.5%  1.5%&#xA;[libx264 @ 0x7fd9cf099b00] kb/s:196.96&#xA;&#xA;echo "END"&#xA;&#x2B; echo END&#xA;END&#xA;

    &#xA;

    As you can see from the above, when run from the shell prompt it starts ffmpeg and then processes the arguments. But when running as cron, it opens ffmpeg, but ignores, or hangs on the processing of the arguments.

    &#xA;

    Lastly, I have the following show up in ps ax when I do a check to see what is running :

    &#xA;

       58 root      0:00 /bin/ash -c /media/pi/_site/pics-alpine.sh 2>&amp;1 | tee /media/pi/_site/alpine.log&#xA;   59 root      0:00 {pics-alpine.sh} /bin/ash /media/pi/_site/pics-alpine.sh&#xA;   60 root      0:00 tee /media/pi/_site/alpine.log&#xA;   61 root      0:00 /usr/bin/ffmpeg -i /media/pi/to-video-back/%04d.jpg /media/pi/_site/back/back-latest.mp4&#xA;

    &#xA;

    Those are just sitting there as though they are waiting on input, so I suspect the ffmpeg has a bug, or my cron is not passing the arguments correctly.

    &#xA;

    Any thoughts on how to fix this ?

    &#xA;