Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How can I install and configure ffmpeg on linux server ?

    3 avril 2015, par Sanket Shah

    I need to generate thumbnail from an uploaded video in codeigniter. After some R&D I came to know that i need to install ffmpeg on my server so can anybody guide me for that? My server is linux server.

  • Can FFMPEG binaries be embedded into a commercial closed source application ?

    2 avril 2015, par James

    I am building a closed source, commercial audio processing tool that relies in part on making command line calls to ffmpeg.exe (on Windows).

    Can I legally package an unmodified ffmpeg.exe in my installer and program directory without making my app open source/are there any crucial rules e.g. distributing the ffmpeg source?

  • FFMPEG Create internal pipeline for adding raw frames to AVI file (no input file)

    2 avril 2015, par Katie

    I have an application that reads in a raw video file, does some image processing to each frame, then feeds the resulting BGRA-format byte[] frames to the FFMPEG container to eventually create an AVI file. Since this process works slightly differently than any other FFMPEG example I've seen in that it does not have an existing input file, I'm wondering if anyone knows how to do this.

    I initialize the FFMPEG container:

    ProcessBuilder pBuilder = new ProcessBuilder(raid.getLocation()
                    + "\\ffmpeg\\bin\\ffmpeg.exe", "-r", "30", "-vcodec",
                    "rawvideo", "-f", "rawvideo", "-pix_fmt", "bgra", "-s",
                    size, "-i", "pipe:0", "-r", "30", "-y", "-c:v", "libx264",
                    "C:\export\2015-02-03\1500\EXPORT6.avi");
    
     try
     {
         process = pBuilder.start();
     }
     catch (IOException e)
     {
         e.printStackTrace();
     }
    
      ffmpegInput = process.getOutputStream();
    

    For each incoming byte[] array frame, I add the frame to the container ("src" is a BufferedImage that I'm converting to a byte array):

    try
    {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ImageIO.write(src, ".png", baos);
         ffmpegInput.write(baos.toByteArray());
    }
    catch (IOException e)
    {
         e.printStackTrace();
    }
    

    And once the video is finished loading frames, I close the container:

    try
    {
         ffmpegInput.flush();
         ffmpegInput.close();
    }
    catch (IOException e)
    {
         e.printStackTrace();
    }
    

    The AVI file is created but it displays an error when opening. The FFMPEG logger displays this as the error:

    ffmpeg version N-71102-g1f5d1ee Copyright (c) 2000-2015 the FFmpeg developers built with gcc 4.9.2 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
      libavutil      54. 20.101 / 54. 20.101
      libavcodec     56. 30.100 / 56. 30.100
      libavformat    56. 26.101 / 56. 26.101
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 13.101 /  5. 13.101
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, rawvideo, from 'pipe:0':
      Duration: N/A, bitrate: 294912 kb/s
        Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 640x480, 294912 kb/s, 30 tbr, 30 tbn, 30 tbc
    No pixel format specified, yuv444p for H.264 encoding chosen.
    Use -pix_fmt yuv420p for compatibility with outdated media players.
    [libx264 @ 00000000003bcbe0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    [libx264 @ 00000000003bcbe0] profile High 4:4:4 Predictive, level 3.0, 4:4:4 8-bit
    Output #0, avi, to 'C:\export\2015-02-03\1500\EXPORT6.avi':
      Metadata:
        ISFT            : Lavf56.26.101
        Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 640x480, q=-1--1, 30 fps, 30 tbn, 30 tbc
        Metadata:
          encoder         : Lavc56.30.100 libx264
    Stream mapping:
      Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
    frame=    0 fps=0.0 q=0.0 Lsize=       6kB time=00:00:00.00 bitrate=N/A    
    video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
    Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
    

    Any insight or ideas would be greatly appreciated!

  • How to convert avi files to mp4 using mmpeg ?

    2 avril 2015, par Idon'tGetIt

    I installed mmpeg on my windows 8 computer to convert AVI files to mp4, but I don't have an idea how this program works. I looked for a tutorial for mmpeg but didn't find any. so, does anyone can explain me how i can convert my avi files to mp4 using mmpeg?

    Thanks in advance.

  • ffmpeg library performance for decoding h.264 for embedded device

    2 avril 2015, par pasifus

    I have some confuse when tried to compile and run decode h.264 on ARM and MIPS architecture.

    I have two embedded devices. I tired to run simple code that read h264 format from file and decode it to h264 in loop in maximum speed (without sleep between frames)

    I found that it too slow in there devices. I tested HD video (720p/25fps)

    1. MIPS32® 1004K (700MHz) it was ~4 fps average.
    2. Raspberry Pi Model B (700MHz) it also was ~4 fps average. (i know that raspberry have GPU to decoding/encoding)

    A also check it on my virtual machine on ubuntu i686 (1300MHz) and it was ~200 fps average.

    The question: why it so different preference? Somebody know how to increase decoding preference on MIPS32® 1004K architecture?

    #include 
    #include 
    #include 
    #include 
    
    #include time.h>
    #include 
    
    #include "libavcodec/avcodec.h"
    #include "libavutil/mathematics.h"
    
    #define INBUF_SIZE 80000
    
    
    static long get_time_diff(struct timeval time_now) {
       struct timeval time_now2;
       gettimeofday(&time_now2,0);
       return time_now2.tv_sec*1.e6 - time_now.tv_sec*1.e6 + time_now2.tv_usec - time_now.tv_usec;
    }
    
    int main(int argc, char **argv)
    {
        AVCodec *codec;
        AVCodecContext *c= NULL;
        AVCodecParserContext *parser = NULL;
        int frame, got_picture, len2, len;
        const char *filename;
        FILE *f;
        AVFrame *picture;
        char *arghwtf = malloc(INBUF_SIZE);
        uint64_t in_len;
        int pts, dts;
        struct timeval t,t2;
        float inv_fps = 1e6/23.98;
        AVPacket avpkt;
    
        // register all the codecs
        avcodec_register_all();
    
        // log level
        av_log_set_level(AV_LOG_PANIC|AV_LOG_FATAL|AV_LOG_ERROR|AV_LOG_WARNING);
    
        filename = argv[1];
    
        av_init_packet(&avpkt);
    
        printf("Decoding file %s...\n", filename);
    
        // find the H.264 video decoder
        codec = avcodec_find_decoder(CODEC_ID_H264);
        if (!codec)
        {
            fprintf(stderr, "codec not found\n");
            exit(1);
        }
    
        c = avcodec_alloc_context3(codec);
        picture = avcodec_alloc_frame();
    
        // skiploopfilter=all
        c->skip_loop_filter = 48;
    
        AVDictionary* dictionary = NULL;
        if (avcodec_open2(c, codec, &dictionary) < 0)
        {
            fprintf(stderr, "could not open codec\n");
            exit(1);
        }
    
        // the codec gives us the frame size, in samples
        parser = av_parser_init(c->codec_id);
        parser->flags |= PARSER_FLAG_ONCE;
    
        f = fopen(filename, "rb");
        if (!f)
        {
            fprintf(stderr, "could not open %s\n", filename);
            exit(1);
        }
    
        frame = 0;
        gettimeofday(&t, 0);
        if(fread(arghwtf, 1, INBUF_SIZE, f) == 0)
        {
            exit(1);
        }
    
        in_len = 80000;
        gettimeofday(&t2, 0);
        while (in_len > 0 && !feof(f))
        {
            len = av_parser_parse2(parser, c, &avpkt.data, &avpkt.size, arghwtf, in_len, pts, dts, AV_NOPTS_VALUE);
    
            len2 = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
            if (len2 < 0) {
                fprintf(stderr, "Error while decoding frame %d\n", frame);
                exit(1);
            }
    
            if (got_picture)
            {
                fprintf(stderr, "\rDisplaying %c %dx%d :frame %3d (%02d:%03d)...", av_get_picture_type_char(picture->pict_type), c->width, c->height, frame, (int)(get_time_diff(t)/1000000), (int)((get_time_diff(t)/1000)%1000));
                fflush(stderr);
    
                frame++;
            }
    
            memcpy(arghwtf, arghwtf + len, 80000-len);
            fread(arghwtf + 80000 - len, 1, len, f);
        }
    
        fclose(f);
        avcodec_close(c);
        av_free(c);
        av_free(picture);
        printf("\n");
        printf("Avarage fps: %d\n", (int)(((double)frame)/(double)(get_time_diff(t)/1000)*1000));
    
        return 0;
    }