Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFMPEG facing issue while compiling common.mak file

    9 juin 2016, par sumit singh

    I am compiling the ffmpeg library i am facing some issues while compiling this.

    I follow the steps of compilation form here.But i am failed to compile. The issues are as below.

    WARNING: /home/sumit/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.
    libavcodec/bsf_list.c is unchanged
    libavformat/protocol_list.c is unchanged
    common.mak:26: *** unterminated call to function `foreach': missing `)'.  Stop.
    common.mak:26: *** unterminated call to function `foreach': missing `)'.  Stop.
    common.mak:26: *** unterminated call to function `foreach': missing `)'.  Stop.
    sumit@sumit-H81M-S:~/android-ndk-r10e/sources/ffmpeg$ 
    

    here is my build_android.sh file-

    #!/bin/bash
    
    NDK=$HOME/android-ndk-r10e
    
    SYSROOT=$NDK/platforms/android-19/arch-arm/
    
    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86
    
    function build_one
    
    {
    ./configure --prefix=$PREFIX --enable-shared --disable-static --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-avdevice --disable-doc --disable-symver --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --target-os=linux --arch=arm --enable-cross-compile --sysroot=$SYSROOT --extra-cflags="-Os -fpic $ADDI_CFLAGS" --extra-ldflags="$ADDI_LDFLAGS" 
    $ADDITIONAL_CONFIGURE_FLAG
    make clean
    make
    make install
    }
    
    CPU=arm
    
    PREFIX=$(pwd)/android/$CPU 
    
    ADDI_CFLAGS="-marm"
    
    build_one
    

    common.mak-

    #
    # common bits used by all libraries
    #
    
    # first so "all" becomes default target
    all: all-yes
    
    DEFAULT_YASMD=.dbg
    
    ifeq ($(DBG),1)
    YASMD=$(DEFAULT_YASMD)
    else
    YASMD=
    endif
    
    ifndef SUBDIR
    
    ifndef V
    Q      = @
    ECHO   = printf "$(1)\t%s\n" $(2)
    BRIEF  = CC CXX OBJCC HOSTCC HOSTLD AS YASM AR LD STRIP CP WINDRES
    SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM
    
    MSG    = $@
    M      = @$(call ECHO,$(TAG),$@);
    $(foreach VAR,$(BRIEF), \
        $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
    $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
    $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
    endif
    
    ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil postproc swscale swresample
    
    # NASM requires -I path terminated with /
    IFLAGS     := -I. -I$(SRC_LINK)/
    CPPFLAGS   := $(IFLAGS) $(CPPFLAGS)
    CFLAGS     += $(ECFLAGS)
    CCFLAGS     = $(CPPFLAGS) $(CFLAGS)
    OBJCFLAGS  += $(EOBJCFLAGS)
    OBJCCFLAGS  = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
    ASFLAGS    := $(CPPFLAGS) $(ASFLAGS)
    CXXFLAGS   += $(CPPFLAGS) $(CFLAGS)
    YASMFLAGS  += $(IFLAGS:%=%/) -Pconfig.asm
    
    HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
    LDFLAGS    := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
    
    define COMPILE
           $(call $(1)DEP,$(1))
           $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
    endef
    
    COMPILE_C = $(call COMPILE,CC)
    COMPILE_CXX = $(call COMPILE,CXX)
    COMPILE_S = $(call COMPILE,AS)
    COMPILE_M = $(call COMPILE,OBJCC)
    COMPILE_HOSTC = $(call COMPILE,HOSTCC)
    
    %.o: %.c
        $(COMPILE_C)
    
    %.o: %.cpp
        $(COMPILE_CXX)
    
    %.o: %.m
        $(COMPILE_M)
    
    %.s: %.c
        $(CC) $(CCFLAGS) -S -o $@ $<
    
    %.o: %.S
        $(COMPILE_S)
    
    %_host.o: %.c
        $(COMPILE_HOSTC)
    
    %.o: %.rc
        $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
    
    %.i: %.c
        $(CC) $(CCFLAGS) $(CC_E) $<
    
    %.h.c:
        $(Q)echo '#include "$*.h"' >$@
    
    %.ver: %.v
        $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ | sed -e 's/:/:\
    /' -e 's/; /;\
    /g' > $@
    
    %.c %.h: TAG = GEN
    
    # Dummy rule to stop make trying to rebuild removed or renamed headers
    %.h:
        @:
    
    # Disable suffix rules.  Most of the builtin rules are suffix rules,
    # so this saves some time on slow systems.
    .SUFFIXES:
    
    # Do not delete intermediate files from chains of implicit rules
    $(OBJS):
    endif
    
    include $(SRC_PATH)/arch.mak
    
    OBJS      += $(OBJS-yes)
    SLIBOBJS  += $(SLIBOBJS-yes)
    FFLIBS    := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
    TESTPROGS += $(TESTPROGS-yes)
    
    LDLIBS       = $(FFLIBS:%=%$(BUILDSUF))
    FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
    
    OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
    SLIBOBJS  := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
    TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
    TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
    HOSTOBJS  := $(HOSTPROGS:%=$(SUBDIR)%.o)
    HOSTPROGS := $(HOSTPROGS:%=$(SUBDIR)%$(HOSTEXESUF))
    TOOLS     += $(TOOLS-yes)
    TOOLOBJS  := $(TOOLS:%=tools/%.o)
    TOOLS     := $(TOOLS:%=tools/%$(EXESUF))
    HEADERS   += $(HEADERS-yes)
    
    PATH_LIBNAME = $(foreach NAME,$(1),lib$(NAME)/$($(2)LIBNAME))
    DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib),$(CONFIG_SHARED:yes=S)))
    STATIC_DEP_LIBS := $(foreach lib,$(FFLIBS),$(call PATH_LIBNAME,$(lib)))
    
    SRC_DIR    := $(SRC_PATH)/lib$(NAME)
    ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
    SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
    SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
    HOBJS        = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
    checkheaders: $(HOBJS)
    .SECONDARY:   $(HOBJS:.o=.c)
    
    alltools: $(TOOLS)
    
    $(HOSTOBJS): %.o: %.c
        $(COMPILE_HOSTC)
    
    $(HOSTPROGS): %$(HOSTEXESUF): %.o
        $(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTLIBS)
    
    $(OBJS):     | $(sort $(dir $(OBJS)))
    $(HOBJS):    | $(sort $(dir $(HOBJS)))
    $(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
    $(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
    $(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
    $(TOOLOBJS): | tools
    
    OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
    
    CLEANSUFFIXES     = *.d *.o *~ *.h.c *.map *.ver *.ver-sol2 *.ho *.gcno *.gcda *$(DEFAULT_YASMD).asm
    DISTCLEANSUFFIXES = *.pc
    LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
    
    define RULES
    clean::
        $(RM) $(HOSTPROGS)
        $(RM) $(TOOLS)
    endef
    
    $(eval $(RULES))
    
    -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_YASMD).d)
    
  • Convert ffmpeg frame into array of YUV pixels in C

    9 juin 2016, par loneraver

    I'm using the ffmpeg C libraries and trying to convert an AVFrame into a 2d array of pixels with YUV* components for analysis. I figured out how to convert the Y component for each pixel.:

    uint8_t y_val = pFrame->data[0][pFrame->linesize[0] * y + x]; 
    

    Since all frames have a Y component this is easy. However most digital video do not have a 4:4:4 chroma subsampling, so getting the UV components is stumping me.

    I'm using straight C for this project. No C++. An ideas?

    *Note: Yes, I know it's technically YCbCr and not YUV.

    Edit:

    I'm rather new to C so it might not be the prettiest code out there.

    When I try:

    VisYUVFrame *VisCreateYUVFrame(const AVFrame *pFrame){
        VisYUVFrame *tmp = (VisYUVFrame*)malloc(sizeof(VisYUVFrame));
        if(tmp == NULL){ return NULL;}
        tmp->height = pFrame->height;
        tmp->width = pFrame->width;
    
        tmp->data = (PixelYUV***)malloc(sizeof(PixelYUV**) * pFrame->height);
        if(tmp->data == NULL) { return NULL;};
    
        for(int y = 0; y < pFrame->height; y++){
            tmp->data[y] = (PixelYUV**)malloc(sizeof(PixelYUV*) * pFrame->width);
            if(tmp->data[y] == NULL) { return NULL;}
    
            for(int x = 0; x < pFrame->width; x++){
                tmp->data[y][x] = (PixelYUV*)malloc(sizeof(PixelYUV*));
                if(tmp->data[y][x] == NULL){ return NULL;};
                tmp->data[y][x]->Y = pFrame->data[0][pFrame->linesize[0] * y + x];
                tmp->data[y][x]->U = pFrame->data[1][pFrame->linesize[1] * y + x];
                tmp->data[y][x]->V = pFrame->data[2][pFrame->linesize[2] * y + x];
    
            }
        }
    
        return tmp;
    

    Luma works but when I run Valgrind, I get

    0x26 1 InvalidRead Invalid read of size 1 0x100003699 /Users/hborcher/Library/Caches/CLion2016.2/cmake/generated/borcherscope-8e83e7dd/8e83e7dd/Debug/VisCreator2 VisCreateYUVFrame /Users/hborcher/ClionProjects/borcherscope/lib visualization.c 145 0x100006B5B /Users/hborcher/Library/Caches/CLion2016.2/cmake/generated/borcherscope-8e83e7dd/8e83e7dd/Debug/VisCreator2 render /Users/hborcher/ClionProjects/borcherscope/lib/decoder simpleDecoder2.c 253 0x100002D24 /Users/hborcher/Library/Caches/CLion2016.2/cmake/generated/borcherscope-8e83e7dd/8e83e7dd/Debug/VisCreator2 main /Users/hborcher/ClionProjects/borcherscope/src createvisual2.c 93 Address 0x10e9f91ef is 0 bytes after a block of size 92,207 alloc'd 0x100013EEA /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so malloc_zone_memalign 0x1084B5416 /usr/lib/system/libsystem_malloc.dylib posix_memalign 0x10135D317 /usr/local/Cellar/ffmpeg/3.0.2/lib/libavutil.55.17.103.dylib av_malloc

    0x27 1 InvalidRead Invalid read of size 1 0x1000036BA /Users/hborcher/Library/Caches/CLion2016.2/cmake/generated/borcherscope-8e83e7dd/8e83e7dd/Debug/VisCreator2 VisCreateYUVFrame /Users/hborcher/ClionProjects/borcherscope/lib visualization.c 147 0x100006B5B /Users/hborcher/Library/Caches/CLion2016.2/cmake/generated/borcherscope-8e83e7dd/8e83e7dd/Debug/VisCreator2 render /Users/hborcher/ClionProjects/borcherscope/lib/decoder simpleDecoder2.c 253 0x100002D24 /Users/hborcher/Library/Caches/CLion2016.2/cmake/generated/borcherscope-8e83e7dd/8e83e7dd/Debug/VisCreator2 main /Users/hborcher/ClionProjects/borcherscope/src createvisual2.c 93 Address 0x10e9f91ef is 0 bytes after a block of size 92,207 alloc'd 0x100013EEA /usr/local/Cellar/valgrind/3.11.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so malloc_zone_memalign 0x1084B5416 /usr/lib/system/libsystem_malloc.dylib posix_memalign 0x10135D317 /usr/local/Cellar/ffmpeg/3.0.2/lib/libavutil.55.17.103.dylib av_malloc

  • How to use ffmpeg to make P frames reference to only the beginning I frame in a GOP ?

    9 juin 2016, par Bob

    Normally, a P frame references to the I frame and the preceding P frames. However, I want to get IPPPPPP... and all the P frames reference to only the I frame within a GOP. Is it possible to achieve it using ffmpeg? Thanks.

  • Calculate edits in QuickTime Movie File with Edit List Atom

    8 juin 2016, par kodonnell

    In a Linux environment, is there a way to calculate any edits in a QuickTime Movie File track? Specifically, I need duration and start time of edits in relation to the movie.

    I have been parsing the raw mov file to look at the Edit List Atom ( i.e. 'elst' ) to get the track duration and media time but, even after the adjustments for time scale units the start time always seems off.

    For example, I have a single track video which has been edited to have first and last 6 seconds of the video removed. However, when I look at the 'elst' atom of that file the track duration is the length of the new file but, the media time does not match what I would have expected (i.e. something equivalent to 6 seconds).

    I have tried looking into tools like FFmpeg but have had little success.

  • FFMPEG combining videos - returning video with black background ?

    8 juin 2016, par Julia

    I'm trying to combine two .mp4 files so they play next to each other in one window. They are the same length (9 seconds), have the same number of frames, and the sources are both independently playable. Here's what i've tried so far:

    ffmpeg -i highres_BH_140.mp4 -i BH_140.mp4 -filter_complex "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w" -b 16M combined.mp4
    

    and

    ffmpeg -i BH_140.mp4 -i highres_BH_140.mp4 -filter_complex vstack stacked.mp4
    

    This just creates a video with a black background, although it does play for 9 seconds. One video is a higher resolution, could this be a problem? Or is it the fact that they're .mp4 files and not .mpg?

    I'm still trying to understand ffmpeg's syntax, so it's possible I'm making a silly mistake somewhere.

    Thanks!