Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
ffmpeg : Combine/merge multiple mp4 videos - not working
9 juin 2016, par dtbakerHere is the command I am using to combine multiple videos:
ffmpeg -i 75_540_38HQ2.mp4 -i 76_70_20.mp4 -i 76_173_80.mp4 -i 81_186_35.mp4 -vcodec copy -acodec copy Mux1.mp4
The resulting
Mux1.mp4
does not contain all videos. Only the first video (75_540_38HQ2.mp4
). The file size of the source and resulting video is below (as you can see, resulting video is slightly larger than first vid):$ ls -lh -rw-r--r-- 1 dbaker dbaker 42M 2011-03-24 11:59 75_540_38HQ2.mp4 -rw-r--r-- 1 dbaker dbaker 236M 2011-03-24 12:09 76_173_80.mp4 -rw-r--r-- 1 dbaker dbaker 26M 2011-03-24 12:05 76_70_20.mp4 -rw-r--r-- 1 dbaker dbaker 54M 2011-03-24 12:15 81_186_35.mp4 -rw-r--r-- 1 dbaker dbaker 44M 2011-03-24 14:48 Mux1.mp4
Here is the output of the
ffmpeg
command. To me it looks ok, showing the multiple source inputs and the single output.FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers built on Mar 21 2011 18:05:32 with gcc 4.4.5 configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab libavutil 50.36. 0 / 50.36. 0 libavcore 0.16. 1 / 0.16. 1 libavcodec 52.108. 0 / 52.108. 0 libavformat 52.93. 0 / 52.93. 0 libavdevice 52. 2. 3 / 52. 2. 3 libavfilter 1.74. 0 / 1.74. 0 libswscale 0.12. 0 / 0.12. 0 libpostproc 51. 2. 0 / 51. 2. 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '75_540_38HQ2.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:00:29.99, start: 0.000000, bitrate: 11517 kb/s Stream #0.0(eng): Video: h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 11575 kb/s, 29.94 fps, 29.97 tbr, 30k tbn, 59.94 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 127 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '76_70_20.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:00:19.98, start: 0.000000, bitrate: 10901 kb/s Stream #1.0(eng): Video: h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 10804 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #1.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '76_173_80.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:03:09.99, start: 0.000000, bitrate: 10393 kb/s Stream #2.0(eng): Video: h264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], 10321 kb/s, 29.96 fps, 29.97 tbr, 30k tbn, 59.94 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #2.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Seems stream 0 codec frame rate differs from container frame rate: 119.88 (120000/1001) -> 30000.00 (30000/1) Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '81_186_35.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Duration: 00:00:35.00, start: 0.000000, bitrate: 12700 kb/s Stream #3.0(eng): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 12620 kb/s, 59.91 fps, 30k tbr, 60k tbn, 119.88 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #3.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Output #0, mp4, to 'Mux1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.93.0 Stream #0.0(eng): Video: libx264, yuv420p, 1280x960 [PAR 1:1 DAR 4:3], q=2-31, 11575 kb/s, 30k tbn, 29.97 tbc Metadata: creation_time : 1970-01-01 00:00:00 Stream #0.1(eng): Audio: libfaac, 48000 Hz, stereo, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 Stream mapping: Stream #0.0 -> #0.0 Stream #2.1 -> #0.1 Press [q] to stop encoding frame= 883 fps=632 q=-1.0 Lsize= 44730kB time=29.40 bitrate=12465.1kbits/s video:41678kB audio:2969kB global headers:0kB muxing overhead 0.184548%
Am I doing something blindingly stupid here?
The source videos came from a video camera, and are small snippets taken with
ffmpeg -i bigfile.mp4 -ss 20 -t 10 -vcodec copy etc..
Thanks heaps!! Dave
Edit: couldn't solve it so I just use avidemux GUI tool. It seemed to append the MP4's just fine.
Must be a problem with MP4's or just the ones that come off a gopro camera.
-
Conversion of .iva to .mp4 using ffmpeg
9 juin 2016, par Rupesh ParabThe video which I am trying to convert is uploaded at http://www.filedropper.com/video_17
I am using the following command to convert the file:
ffmpeg -i archive.iva -c copy -map 0 output.mp4 -vsync 2 -y;
The file should be around 1 min in length but after conversion is of only 7 secs
What am I doing wrong?
Edit
Console Output:
rupesh@rupesh-Lenovo-IdeaPad-Y510P:~/video$ ffmpeg -i archive.iva -c copy -map 0 output.mp4 -vsync 2 -y; ffmpeg version N-80026-g936751b Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3) configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 42.100 / 57. 42.100 libavformat 57. 36.100 / 57. 36.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 45.100 / 6. 45.100 libavresample 3. 0. 0 / 3. 0. 0 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 [mjpeg @ 0x3a2eda0] Format mjpeg detected only with low score of 25, misdetection possible! Input #0, mjpeg, from 'archive.iva': Duration: N/A, bitrate: N/A Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 25 fps, 25 tbr, 1200k tbn [mp4 @ 0x3a309c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. Output #0, mp4, to 'output.mp4': Metadata: encoder : Lavf57.36.100 Stream #0:0: Video: mjpeg (l[0][0][0] / 0x006C), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, q=2-31, 25 fps, 25 tbr, 1200k tbn Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help frame= 190 fps=0.0 q=-1.0 Lsize= 5909kB time=00:00:07.56 bitrate=6403.2kbits/s speed= 127x video:5908kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.026134%
-
FFMPEG facing issue while compiling common.mak file
9 juin 2016, par sumit singhI 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 loneraverI'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 BobNormally, 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.