Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • Odd X server error with ffmpeg

    4 novembre 2013, par jhc


    I am building a weather data acquisition system. One of the things I would like to do would be to animate the satellite data that is arriving every 15 minutes. In fact, I have already devised a script (called animate) that successfully joins eight hours worth of PNG images into an AVI video file. This runs fine when run manually from the terminal.

    Unfortunately, the same cannot be said when run from my (as in my user, not root) crontab.

    Below is the cron job that I mentioned:

    1,16,31,46 * * * * /home/daniella/bin/anim_all > /home/daniella/logs/anim_all.log 2>&1
    

    anim_all simply calls animate for each distinct data product:

    #!/bin/bash
    set -x
    cd /home/daniella/data/imager
    
    rm -rf HRIT_MSG3_*.avi
    
    animate HRIT_MSG3_CTT
    animate HRIT_MSG3_IR108
    animate HRIT_MSG3_VIS006
    animate HRIT_MSG3_WV062
    

    And animate itself calls ffmpeg.

    #!/bin/bash
    
    set -x
    cd /home/daniella/data/imager
    product=$1
    hl="$product.8hl"
    
    declare -i i=0
    for file in $(cat $hl); do
        link=$(printf "images%02d.png" $i)
        ln -sf $file $link
        i=$((i+1))
        echo $i
    done
    
    ffmpeg -sameq -r 15 -i images%02d.png $product.avi
    rm -rf images*.png
    

    Just to be clear, the .8hl file is simply a list of PNG file paths that refer to that last 8 hours of data. Since there is new data every 15 minutes, that is a text file with 32 lines. Finally, this is the error that is returned when examining anim_all.log (referred in the crontab) file.

    + animate HRIT_MSG3_CTT
    animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
    + animate HRIT_MSG3_IR108
    animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
    + animate HRIT_MSG3_VIS006
    animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
    + animate HRIT_MSG3_WV062
    animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
    

    Please note that anim_all works fine, when called manually from the terminal. This error exists only when called by cron. I would imagine that this has to do with environment variables, but I have sourced my .bashrc inside the script to no prevail.

    EDIT - Investigating the animate.c file itself (see the full code here), at lines 365-368, there is this:

    if (display == (Display *) NULL)
        ThrowAnimateException(XServerError,"UnableToOpenXServer",
        XDisplayName(server_name));
    (void) XSetErrorHandler(XError);
    

    In response, I have attempted to export the $DISPLAY variable to 127.0.0.0:0 in the animate script, but this has not worked.

  • Getting “field has incomplete type” and "conflicting types"

    4 novembre 2013, par Viet

    I'm trying build pjsip from source with video support by gcc on ubuntu. After i success full run ./configure and make dep, i run make and i have error below:

    ../src/pjmedia/ffmpeg_util.c:46:18: error: field ‘codec_id’ has incomplete type
    ../src/pjmedia/ffmpeg_util.c:148:13: error: conflicting types for ‘pjmedia_format_id_to_CodecID’
    ../src/pjmedia/ffmpeg_util.h:23:13: note: previous declaration of ‘pjmedia_format_id_to_CodecID’ was here
    ../src/pjmedia/ffmpeg_util.c: In function ‘pjmedia_format_id_to_CodecID’:
    ../src/pjmedia/ffmpeg_util.c:154:35: warning: comparison between pointer and integer [enabled by default]
    ../src/pjmedia/ffmpeg_util.c:155:6: error: dereferencing pointer to incomplete type
    ../src/pjmedia/ffmpeg_util.c:155:6: warning: statement with no effect [-Wunused-value]
    ../src/pjmedia/ffmpeg_util.c:160:5: error: dereferencing pointer to incomplete type
    ../src/pjmedia/ffmpeg_util.c:160:5: warning: statement with no effect [-Wunused-value]
    ../src/pjmedia/ffmpeg_util.c: At top level:
    ../src/pjmedia/ffmpeg_util.c:164:55: error: parameter 1 (‘codec_id’) has incomplete type
    

    Here is the code in ffmpeg_util.h and ffmpeg_util.c

    ffmpeg_util.h

    #ifndef __PJMEDIA_FFMPEG_UTIL_H__
    #define __PJMEDIA_FFMPEG_UTIL_H__
    
    #include format.h>
    
    #ifdef _MSC_VER
    #   ifndef __cplusplus
    #   define inline _inline
    #   endif
    #   pragma warning(disable:4244) /* possible loss of data */
    #endif
    
    #include avutil.h>
    #include avcodec.h>
    
    void pjmedia_ffmpeg_add_ref();
    void pjmedia_ffmpeg_dec_ref();
    
    pj_status_t pjmedia_format_id_to_PixelFormat(pjmedia_format_id fmt_id,
                             enum PixelFormat *pixel_format);
    
    pj_status_t PixelFormat_to_pjmedia_format_id(enum PixelFormat pf,
                             pjmedia_format_id *fmt_id);
    
    pj_status_t pjmedia_format_id_to_CodecID(pjmedia_format_id fmt_id,
                         enum CodecID *codec_id);
    
    pj_status_t CodecID_to_pjmedia_format_id(enum CodecID codec_id,
                         pjmedia_format_id *fmt_id);
    
    #endif /* __PJMEDIA_FFMPEG_UTIL_H__ */
    

    ffmpeg_util.c

    #include types.h>
    #include errno.h>
    #include log.h>
    #include string.h>
    
    #if PJMEDIA_HAS_LIBAVFORMAT && PJMEDIA_HAS_LIBAVUTIL
    
    #include "ffmpeg_util.h"
    #include avformat.h>
    
    #define MAKE_VER(mj,mn,mi)  ((mj << 16) | (mn << 8) | (mi << 0))
    #define VER_AT_LEAST(mj,mn,mi)  (MAKE_VER(LIBAVUTIL_VERSION_MAJOR, \
                                              LIBAVUTIL_VERSION_MINOR, \
                                              LIBAVUTIL_VERSION_MICRO) >= \
                                     MAKE_VER(mj,mn,mi))
    
    
    
    /* Conversion table between pjmedia_format_id and PixelFormat */
    static const struct ffmpeg_fmt_table_t
    {
        pjmedia_format_id   id;
        enum PixelFormat    pf;
    } ffmpeg_fmt_table[] =
    {
        { PJMEDIA_FORMAT_RGBA, PIX_FMT_RGBA},
        { PJMEDIA_FORMAT_RGB24,PIX_FMT_BGR24},
        { PJMEDIA_FORMAT_BGRA, PIX_FMT_BGRA},
    #if VER_AT_LEAST(51,20,1)
        { PJMEDIA_FORMAT_GBRP, PIX_FMT_GBR24P},
    #endif
    
        { PJMEDIA_FORMAT_AYUV, PIX_FMT_NONE},
        { PJMEDIA_FORMAT_YUY2, PIX_FMT_YUYV422},
        { PJMEDIA_FORMAT_UYVY, PIX_FMT_UYVY422},
        { PJMEDIA_FORMAT_I420, PIX_FMT_YUV420P},
        //{ PJMEDIA_FORMAT_YV12, PIX_FMT_YUV420P},
        { PJMEDIA_FORMAT_I422, PIX_FMT_YUV422P},
        { PJMEDIA_FORMAT_I420JPEG, PIX_FMT_YUVJ420P},
        { PJMEDIA_FORMAT_I422JPEG, PIX_FMT_YUVJ422P},
    };
    
    /* Conversion table between pjmedia_format_id and CodecID */
    static const struct ffmpeg_codec_table_t
    {
        pjmedia_format_id   id;
        enum CodecID    codec_id;
    } ffmpeg_codec_table[] =
    {
        {PJMEDIA_FORMAT_H261,   CODEC_ID_H261},
        {PJMEDIA_FORMAT_H263,   CODEC_ID_H263},
        {PJMEDIA_FORMAT_H263P,  CODEC_ID_H263P},
        {PJMEDIA_FORMAT_H264,   CODEC_ID_H264},
        {PJMEDIA_FORMAT_MPEG1VIDEO, CODEC_ID_MPEG1VIDEO},
        {PJMEDIA_FORMAT_MPEG2VIDEO, CODEC_ID_MPEG2VIDEO},
        {PJMEDIA_FORMAT_MPEG4,  CODEC_ID_MPEG4},
        {PJMEDIA_FORMAT_MJPEG,  CODEC_ID_MJPEG}
    };
    
    static int pjmedia_ffmpeg_ref_cnt;
    
    static void ffmpeg_log_cb(void* ptr, int level, const char* fmt, va_list vl);
    
    void pjmedia_ffmpeg_add_ref()
    {
        if (pjmedia_ffmpeg_ref_cnt++ == 0) {
        av_log_set_level(AV_LOG_ERROR);
        av_log_set_callback(&ffmpeg_log_cb);
        av_register_all();
        }
    }
    
    void pjmedia_ffmpeg_dec_ref()
    {
        if (pjmedia_ffmpeg_ref_cnt-- == 1) {
        /* How to shutdown ffmpeg? */
        }
    
        if (pjmedia_ffmpeg_ref_cnt < 0) pjmedia_ffmpeg_ref_cnt = 0;
    }
    
    
    static void ffmpeg_log_cb(void* ptr, int level, const char* fmt, va_list vl)
    {
        const char *LOG_SENDER = "ffmpeg";
        enum { LOG_LEVEL = 5 };
        char buf[100];
        int bufsize = sizeof(buf), len;
        pj_str_t fmt_st;
    
        /* Custom callback needs to filter log level by itself */
        if (level > av_log_get_level())
        return;
    
        /* Add original ffmpeg sender to log format */
        if (ptr) {
        AVClass* avc = *(AVClass**)ptr;
        len = pj_ansi_snprintf(buf, bufsize, "%s: ", avc->item_name(ptr));
        bufsize -= len;
        }
    
        /* Copy original log format */
        len = pj_ansi_strlen(fmt);
        if (len > bufsize-1)
        len = bufsize-1;
        pj_memcpy(buf+sizeof(buf)-bufsize, fmt, len);
        bufsize -= len;
    
        /* Trim log format */
        pj_strset(&fmt_st, buf, sizeof(buf)-bufsize);
        pj_strrtrim(&fmt_st);
        buf[fmt_st.slen] = '\0';
    
        pj_log(LOG_SENDER, LOG_LEVEL, buf, vl);
    }
    
    
    pj_status_t pjmedia_format_id_to_PixelFormat(pjmedia_format_id fmt_id,
                             enum PixelFormat *pixel_format)
    {
        unsigned i;
        for (i=0; iid==fmt_id && t->pf != PIX_FMT_NONE) {
            *pixel_format = t->pf;
            return PJ_SUCCESS;
        }
        }
    
        *pixel_format = PIX_FMT_NONE;
        return PJ_ENOTFOUND;
    }
    
    pj_status_t PixelFormat_to_pjmedia_format_id(enum PixelFormat pf,
                             pjmedia_format_id *fmt_id)
    {
        unsigned i;
        for (i=0; ipf == pf) {
            if (fmt_id) *fmt_id = t->id;
            return PJ_SUCCESS;
        }
        }
    
        return PJ_ENOTFOUND;
    }
    
    pj_status_t pjmedia_format_id_to_CodecID(pjmedia_format_id fmt_id,
                         enum CodecID *codec_id)
    {
        unsigned i;
        for (i=0; iid==fmt_id && t->codec_id != PIX_FMT_NONE) {
            *codec_id = t->codec_id;
            return PJ_SUCCESS;
        }
        }
    
        *codec_id = PIX_FMT_NONE;
        return PJ_ENOTFOUND;
    }
    
    pj_status_t CodecID_to_pjmedia_format_id(enum CodecID codec_id,
                         pjmedia_format_id *fmt_id)
    {
        unsigned i;
        for (i=0; icodec_id == codec_id) {
            if (fmt_id) *fmt_id = t->id;
            return PJ_SUCCESS;
        }
        }
    
        return PJ_ENOTFOUND;
    }
    
    
    #ifdef _MSC_VER
    #   pragma comment( lib, "avformat.lib")
    #   pragma comment( lib, "avutil.lib")
    #endif
    
    #endif  /* #if PJMEDIA_HAS_LIBAVFORMAT && PJMEDIA_HAS_LIBAVUTIL */
    

    Help me fix this error!

  • Aforge FFMpeg DLL Location Issue

    4 novembre 2013, par Sam35

    I'm using AForge FFMPEG libraries for video compression in .Net.Currently I've put the ffmpeg & Aforge libraries in the location which the application(.exe) exists.

    I need to put these libraries in a common place.i've tried to put these libraries inside system32 folder. It is not working.

    Is there any ways to put the Aforge & FFMpeg Libraries in a common place other than application(.exe) directory?

  • ffmpeg not using all cores

    4 novembre 2013, par kkgzjjmj

    I just got my new server with two intel e5-2695 but I was shocked to see that ffmpeg or ubuntu doesn't utilize all cores.

    top while ffmpeg was running

    top - 23:35:25 up  2:41,  2 users,  load average: 5.35, 4.37, 3.12
    Tasks: 333 total,   2 running, 331 sleeping,   0 stopped,   0 zombie
    %Cpu0  :  0.0 us,  1.0 sy, 35.6 ni, 63.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu1  :  0.0 us,  0.7 sy, 35.5 ni, 63.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu2  :  0.0 us,  0.7 sy, 33.4 ni, 65.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu3  :  0.0 us,  0.0 sy, 32.7 ni, 67.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu4  :  0.0 us,  0.3 sy, 32.3 ni, 67.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu5  :  0.0 us,  0.3 sy, 33.0 ni, 66.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu6  :  0.0 us,  0.0 sy, 32.6 ni, 67.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu7  :  0.0 us,  0.3 sy, 32.7 ni, 67.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu8  :  0.0 us,  0.7 sy, 32.6 ni, 66.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu9  :  0.0 us,  0.3 sy, 33.9 ni, 65.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu10 :  0.0 us,  0.0 sy, 35.0 ni, 65.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu11 :  0.0 us,  0.7 sy, 30.0 ni, 69.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu12 : 21.1 us,  0.0 sy,  0.0 ni, 78.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu13 :  0.7 us,  0.0 sy,  4.3 ni, 95.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu14 :  0.3 us,  0.0 sy,  5.0 ni, 94.6 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu15 : 24.9 us,  0.0 sy,  0.0 ni, 75.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu16 :  0.3 us,  0.0 sy,  3.7 ni, 96.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu17 :  0.7 us,  0.3 sy,  4.9 ni, 94.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu18 :  1.0 us,  0.0 sy,  4.6 ni, 94.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu19 :  0.7 us,  0.0 sy,  4.7 ni, 94.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu20 : 11.1 us,  0.0 sy,  0.0 ni, 88.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu21 :  1.3 us,  0.0 sy,  4.6 ni, 94.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu22 :  2.0 us,  0.3 sy,  4.3 ni, 93.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu23 : 96.7 us,  1.0 sy,  0.0 ni,  2.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu24 :  0.0 us,  0.0 sy,  0.7 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu25 :  0.0 us,  0.0 sy,  3.0 ni, 97.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu26 :  0.0 us,  0.0 sy,  1.3 ni, 98.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu27 :  0.0 us,  0.0 sy,  4.0 ni, 96.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu28 :  0.0 us,  0.0 sy,  1.7 ni, 98.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu29 :  0.0 us,  0.0 sy,  1.7 ni, 98.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu30 :  0.0 us,  0.0 sy,  1.7 ni, 98.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu31 :  0.0 us,  0.0 sy,  1.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu32 :  0.0 us,  0.0 sy,  0.7 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu33 :  0.0 us,  0.0 sy,  1.7 ni, 98.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu34 :  0.0 us,  0.0 sy,  2.0 ni, 98.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu35 :  0.0 us,  0.0 sy,  1.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    %Cpu36 :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    

    ffmpeg was sent with -threads 0

    *I also tried sending ffmoeg with -threads 500- no difference

    OS: Ubuntu Server 12.04.3 LTS

  • Alternative to ffmpeg for dynamically creating video thumbnails

    3 novembre 2013, par user763852

    The server hosting my website doesn't have ffmpeg and I am not allowed to install any additional extensions. Is there any other way I can make video thumbnails dynamically? Perhaps some kind of web service, where I pass the video file and as a result I get a picture file. I'm using php, by the way.