Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Retranslating video stream using ffmpeg
6 mai 2014, par zdimon77I want to redirect video stream from rtmp to hls format using nginx rtmp-module.
This my nginx config
server { exec_options on; listen 1936; chunk_size 4000; application myapp { live on; exec /usr/bin/avconv -loglevel verbose -re -i rtmp://localhost:1936/myapp/$name -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/hls/$name; } } server { listen 1935; chunk_size 4000; application hls { live on; hls on; hls_path /tmp/hls; } }
But it doesnt work. When I try to publish my stream in console (without exec command in nginx.conf)
ffmpeg -loglevel debug -re -i rtmp://localhost:1936/myapp/test -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/hls/test
I see this in console
root@dcv23:/usr/share/nginx/html# avconv -i rtmp://localhost:1935/myapp/testname -vcodec copy -an -f flv rtmp://localhost:1936/hls/testname
avconv version 0.8.10-6:0.8.10-1, Copyright (c) 2000-2013 the Libav developers
built on Feb 5 2014 17:15:30 with gcc 4.7.2
[flv @ 0x98a3800] invalid stream
[flv @ 0x98a3800] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from 'rtmp://localhost:1935/myapp/testname':
Duration: N/A, start: 448.536000, bitrate: N/A
Stream #0.0: Audio: nellymoser, 8000 Hz, mono, s16 Stream #0.1: Video: flv, yuv420p, 800x600, 1k tbr, 1k tbn
Output #0, flv, to 'rtmp://localhost:1936/hls/testname':
Metadata:
encoder : Lavf53.21.1 Stream #0.0: Video: flv, yuv420p, 800x600, q=2-31, 1k tbn, 1k tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press ctrl-c to stop encoding
^Cframe= 200 fps= 7 q=-1.0 Lsize= 1031kB time=35.44 bitrate= 238.2kbits/s
And process going but m3u8 files dont create. Can someone help me please? Thank you.
-
Command work, but have a error when used by sh [on hold]
6 mai 2014, par DrakaSANI have this script:
extract.sh:
ffmpeg –i $1 –ss $2 –t $3 –c:v copy –c:a copy $4
If I type
ffmpeg –i full.mp4 –ss 114 –t 30 –c:v copy –c:a copy out.mp4
All go well. But if I try
sh extract.sh full.mp4 114 30 out.mp4
I get :
ffmpeg version 2.1 Copyright (c) 2000-2013 the FFmpeg developers built on May 5 2014 11:41:48 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --enable-gpl libavutil 52. 48.100 / 52. 48.100 libavcodec 55. 39.100 / 55. 39.100 libavformat 55. 19.104 / 55. 19.104 libavdevice 55. 5.100 / 55. 5.100 libavfilter 3. 90.100 / 3. 90.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 [NULL @ 0x2a20b00] Unable to find a suitable output format for '–i' –i: Invalid argument
What does sh do to the argument to make it unreadable in the script?
EDIT:
user@domain:~/test$ sh extract.sh cdr.mp4 0 7 generique.mp4 ffmpeg –i cdr.mp4 –ss 0 –t 7 –c:v copy –c:a copy generique.mp4
-
How to control insert position when insert video frames to pure audio file with ffmpeg
6 mai 2014, par teddyInserting video frames into pure audio flv file(may call it audio.flv) can make it seekable.I do this with ffmpeg using the following command:
/usr/bin/ffmpeg -y -loop 1 -i /root/testimage.jpg -i /file/audio.flv -s 2x2 -t 90 -r 1 -g 0 -acodec copy /tmp/out.flv 2>&1
The number 90 in command is specify the file duration.this can work well except one thing: The output files for several executions of the previous command is not same. After i analysed the file's with flvparser i found that the position of the first video tag of these files were not same.
- For the first situation, the first video tag is the third tag, which is following script tag
- For the second situation, the first video tag is the fifth tag, there are three audio tags between it and script tag.
- For the third situation, the first video tag is the sixth tag.
I just got these three situations for my test. But other video tags are in the same position of tag-index in output file. I have no idea why is just the first video tag has different position. I want all video tag will be at same tag-indexes. Could anyone give me some advise? Thanks!
-
ffmpeg and streaming video - frame time issue
6 mai 2014, par 4ntoineI've compiled ffmpeg-android (https://github.com/appunite/AndroidFFmpeg) and it works for files. The problem is that it shows nothing for network streams (both rtmp and hls) as frame timestamp is too big and it seems to be not from video beginning (as for file). Then it waits for the first frame time which for network stream is too big:
player_decode_video copying... 05-05 18:11:26.994: INFO/player.c(16998): player_decode_video Decoded video frame: 568.233000, time_base: 51140970 05-05 18:11:26.994: INFO/player.c(16998): player_wait_for_frame[0] start ... 05-05 18:11:30.587: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (568.233000) - (0.000977) 05-05 18:11:30.587: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: 568232023 05-05 18:11:31.088: INFO/player.c(16998): player_wait_for_frame[0] timeout 05-05 18:11:31.088: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (568.233000) - (0.501542) 05-05 18:11:31.088: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: 567731458 05-05 18:11:31.588: INFO/player.c(16998): player_wait_for_frame[0] timeout 05-05 18:11:31.588: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (568.233000) - (1.002778) 05-05 18:11:31.588: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: 567230222 05-05 18:11:32.089: INFO/player.c(16998): player_wait_for_frame[0] timeout 05-05 18:11:32.089: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (568.233000) - (1.504563) 05-05 18:11:32.089: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: 566728437 05-05 18:11:32.590: INFO/player.c(16998): player_wait_for_frame[0] timeout 05-05 18:11:32.590: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (568.233000) - (2.005708) 05-05 18:11:32.590: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: 566227292
also i can't figure out what timestamp for frame for network stream means (for file frames it's a time from video beginning)
for file it's clear: time_base is frame number and timestamp is time from video beginning and it plays the files:
player_decode_video Decoded video frame: 0.320000, time_base: 8 05-05 18:32:42.344: INFO/player.c(16998): player_wait_for_frame[0] start 05-05 18:32:42.344: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (0.320000) - (0.344337) 05-05 18:32:42.344: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: -24337 05-05 18:32:42.344: INFO/player.c(16998): player_wait_for_frame[0] finish[0] 05-05 18:32:42.344: INFO/player.c(16998): player_update_time: 0.346169/4.000000 05-05 18:32:42.344: INFO/player.c(16998): player_decode waiting for frame[0] 05-05 18:32:42.344: INFO/player.c(16998): player_decode decoding frame[0] 05-05 18:32:42.344: INFO/player.c(16998): player_decode_video decoding 05-05 18:32:42.344: INFO/player.c(16998): player_decode_video copy wait 05-05 18:32:42.344: INFO/player.c(16998): player_read_from_stream Read frame 05-05 18:32:42.344: INFO/player.c(16998): player_read_from_stream looking for stream 05-05 18:32:42.344: INFO/player.c(16998): player_read_from_stream stream found [0] 05-05 18:32:42.344: INFO/player.c(16998): player_read_from_stream waiting for queue 05-05 18:32:42.344: INFO/player.c(16998): Format: WINDOW_FORMAT_RGBA_8888 05-05 18:32:42.344: INFO/player.c(16998): Buffer: width: 1280, height: 720, stride: 1280 05-05 18:32:42.344: INFO/player.c(16998): player_decode_video copying... 05-05 18:32:42.425: INFO/player.c(16998): player_decode_video Decoded video frame: 0.360000, time_base: 9 05-05 18:32:42.425: INFO/player.c(16998): player_wait_for_frame[0] start 05-05 18:32:42.425: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (0.360000) - (0.427994) 05-05 18:32:42.425: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: -67994 05-05 18:32:42.425: INFO/player.c(16998): player_wait_for_frame[0] finish[0] 05-05 18:32:42.425: INFO/player.c(16998): player_update_time: 0.429214/4.000000 05-05 18:32:42.425: INFO/player.c(16998): player_decode waiting for frame[0] 05-05 18:32:42.425: INFO/player.c(16998): player_decode decoding frame[0] 05-05 18:32:42.425: INFO/player.c(16998): player_decode_video decoding 05-05 18:32:42.425: INFO/player.c(16998): player_read_from_stream Read frame 05-05 18:32:42.425: INFO/player.c(16998): player_read_from_stream looking for stream 05-05 18:32:42.425: INFO/player.c(16998): player_read_from_stream stream found [0] 05-05 18:32:42.425: INFO/player.c(16998): player_read_from_stream waiting for queue 05-05 18:32:42.425: INFO/player.c(16998): player_decode_video copy wait 05-05 18:32:42.435: INFO/player.c(16998): Format: WINDOW_FORMAT_RGBA_8888 05-05 18:32:42.435: INFO/player.c(16998): Buffer: width: 1280, height: 720, stride: 1280 05-05 18:32:42.435: INFO/player.c(16998): player_decode_video copying... 05-05 18:32:42.495: INFO/player.c(16998): player_decode_video Decoded video frame: 0.400000, time_base: 10 05-05 18:32:42.495: INFO/player.c(16998): player_wait_for_frame[0] start 05-05 18:32:42.495: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (0.400000) - (0.494742) 05-05 18:32:42.495: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: -94742 05-05 18:32:42.495: INFO/player.c(16998): player_wait_for_frame[0] finish[0] 05-05 18:32:42.495: INFO/player.c(16998): player_update_time: 0.495993/4.000000 05-05 18:32:42.495: INFO/player.c(16998): player_decode waiting for frame[0] 05-05 18:32:42.495: INFO/player.c(16998): player_decode decoding frame[0] 05-05 18:32:42.495: INFO/player.c(16998): player_decode_video decoding 05-05 18:32:42.495: INFO/player.c(16998): player_decode_video copy wait 05-05 18:32:42.495: INFO/player.c(16998): player_read_from_stream Read frame 05-05 18:32:42.495: INFO/player.c(16998): Format: WINDOW_FORMAT_RGBA_8888 05-05 18:32:42.495: INFO/player.c(16998): Buffer: width: 1280, height: 720, stride: 1280 05-05 18:32:42.495: INFO/player.c(16998): player_decode_video copying... 05-05 18:32:42.495: INFO/player.c(16998): player_read_from_stream looking for stream 05-05 18:32:42.495: INFO/player.c(16998): player_read_from_stream stream found [0] 05-05 18:32:42.495: INFO/player.c(16998): player_read_from_stream waiting for queue 05-05 18:32:42.555: INFO/player.c(16998): player_decode_video Decoded video frame: 0.440000, time_base: 11 05-05 18:32:42.555: INFO/player.c(16998): player_wait_for_frame[0] start 05-05 18:32:42.555: INFO/player.c(16998): player_wait_for_frame[0 = Video] = (0.440000) - (0.556698) 05-05 18:32:42.555: INFO/player.c(16998): player_wait_for_frame[0] Waiting for frame: sleeping: -116698 05-05 18:32:42.555: INFO/player.c(16998): player_wait_for_frame[0] finish[0] 05-05 18:32:42.555: INFO/player.c(16998): player_update_time: 0.557858/4.000000 05-05 18:32:42.555: INFO/player.c(16998): player_decode waiting for frame[0] 05-05 18:32:42.555: INFO/player.c(16998): player_read_from_stream Read frame 05-05 18:32:42.555: INFO/player.c(16998): player_read_from_stream looking for stream 05-05 18:32:42.555: INFO/player.c(16998): player_read_from_stream stream found [0] 05-05 18:32:42.555: INFO/player.c(16998): player_read_from_stream waiting for queue 05-05 18:32:42.555: INFO/player.c(16998): player_decode decoding frame[0] 05-05 18:32:42.555: INFO/player.c(16998): player_decode_video decoding 05-05 18:32:42.555: INFO/player.c(16998): player_decode_video copy wait 05-05 18:32:42.565: INFO/player.c(16998): Format: WINDOW_FORMAT_RGBA_8888 05-05 18:32:42.565: INFO/player.c(16998): Buffer: width: 1280, height: 720, stride: 1280 05-05 18:32:42.565: INFO/player.c(16998): player_decode_video copying... 05-05 18:32:42.625: INFO/player.c(16998): player_decode_video Decoded video frame: 0.480000, time_base: 12
So what is the meaning of timestamp for stream and what should i change to make it playing streams (rtmp/hls - its can be opened now but it wait for frame time which is far in the future)?
UPDATE:
int64_t pts = av_frame_get_best_effort_timestamp(frame); if (pts == AV_NOPTS_VALUE) { pts = 0; } int64_t time = av_rescale_q(pts, stream->time_base, AV_TIME_BASE_Q); LOGI(10, "player_decode_video Decoded video frame: %f, time_base: %" SCNd64, time/1000000.0, pts); player_wait_for_frame(player, time, stream_no);
it extracts time which is far in future:
player_wait_for_frame[0 = Video] = (568.233000) - (0.000977)
Is it correct?
-
compile librtmp for android error : cannot find -ldl collect2 : error : ld returned 1 exit status
6 mai 2014, par hoseinI have problem on comple librtmp for android using : https://github.com/OnlyInAmerica/FFmpeg-Android
./build_librtmp_for_android.sh
/home/user/loc_app/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_so.o: No such file or directory /home/user/loc_app/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_so.o: No such file or directory /home/user/loc_app/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lssl /home/user/loc_app/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lcrypto /home/user/loc_app/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lz /home/user/loc_app/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc /home/user/loc_app/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl collect2: error: ld returned 1 exit status make: *** [librtmp.so.1] Error 1
here is build_librtmp_for_android.sh :
#!/bin/bash NDK=/home/user/loc_app/android-ndk-r9 #/home/user/loc_app/android-ndk-r9/platforms/android-19/arch-arm SYSROOT=$NDK/platforms/android-18/arch-arm #platforms/android-19/arch-arm/ TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64 #/home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 OPENSSL_DIR=/home/user/libs/openssl-android-master/ # Note: Change the above variables for your system. function build_one { set -e make clean ln -s ${SYSROOT}usr/lib/crtbegin_so.o ln -s ${SYSROOT}usr/lib/crtend_so.o export XLDFLAGS="$ADDI_LDFLAGS -L${OPENSSL_DIR}libs/armeabi -L${SYSROOT}usr/lib " export CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi- export XCFLAGS="${ADDI_CFLAGS} -I${OPENSSL_DIR}include -isysroot ${SYSROOT}" export INC="-I${SYSROOT}" make prefix=\"${PREFIX}\" OPT= install } CPU=arm PREFIX=$(pwd)/android/$CPU ADDI_CFLAGS="-marm" build_one
OS: Fedora 64bit
EDIT 1: that seems to Makefile so i added it here
VERSION=v2.4 prefix=/usr/local incdir=$(prefix)/include/librtmp bindir=$(prefix)/bin libdir=$(prefix)/lib mandir=$(prefix)/man BINDIR=$(DESTDIR)$(bindir) INCDIR=$(DESTDIR)$(incdir) LIBDIR=$(DESTDIR)$(libdir) MANDIR=$(DESTDIR)$(mandir) CC=$(CROSS_COMPILE)gcc LD=$(CROSS_COMPILE)ld AR=$(CROSS_COMPILE)ar SYS=posix CRYPTO=OPENSSL #CRYPTO=GNUTLS DEF_POLARSSL=-DUSE_POLARSSL DEF_OPENSSL=-DUSE_OPENSSL DEF_GNUTLS=-DUSE_GNUTLS DEF_=-DNO_CRYPTO REQ_GNUTLS=gnutls,hogweed,nettle REQ_OPENSSL=libssl,libcrypto PUB_GNUTLS=-lgmp LIBZ=-lz LIBS_posix= LIBS_darwin= LIBS_mingw=-lws2_32 -lwinmm -lgdi32 LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ) LIB_OPENSSL=-lssl -lcrypto $(LIBZ) LIB_POLARSSL=-lpolarssl $(LIBZ) PRIVATE_LIBS=$(LIBS_$(SYS)) CRYPTO_LIB=$(LIB_$(CRYPTO)) $(PRIVATE_LIBS) CRYPTO_REQ=$(REQ_$(CRYPTO)) CRYPTO_DEF=$(DEF_$(CRYPTO)) PUBLIC_LIBS=$(PUB_$(CRYPTO)) SO_VERSION=1 SOX_posix=so SOX_darwin=dylib SOX_mingw=dll SOX=$(SOX_$(SYS)) SO_posix=.$(SOX).$(SO_VERSION) SO_darwin=.$(SO_VERSION).$(SOX) SO_mingw=-$(SO_VERSION).$(SOX) SO_EXT=$(SO_$(SYS)) SODIR_posix=$(LIBDIR) SODIR_darwin=$(LIBDIR) SODIR_mingw=$(BINDIR) SODIR=$(SODIR_$(SYS)) SO_LDFLAGS_posix=-shared -Wl,-soname,$@ SO_LDFLAGS_darwin=-dynamiclib -twolevel_namespace -undefined dynamic_lookup \ -fno-common -headerpad_max_install_names -install_name $(libdir)/$@ SO_LDFLAGS_mingw=-shared -Wl,--out-implib,librtmp.dll.a SO_LDFLAGS=$(SO_LDFLAGS_$(SYS)) INSTALL_IMPLIB_posix= INSTALL_IMPLIB_darwin= INSTALL_IMPLIB_mingw=cp librtmp.dll.a $(LIBDIR) INSTALL_IMPLIB=$(INSTALL_IMPLIB_$(SYS)) SHARED=yes SODEF_yes=-fPIC SOLIB_yes=librtmp$(SO_EXT) SOINST_yes=install_so SO_DEF=$(SODEF_$(SHARED)) SO_LIB=$(SOLIB_$(SHARED)) SO_INST=$(SOINST_$(SHARED)) DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF) OPT=-O2 CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF) LDFLAGS=$(XLDFLAGS) OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o all: librtmp.a $(SO_LIB) clean: rm -f *.o *.a *.$(SOX) *$(SO_EXT) librtmp.pc librtmp.a: $(OBJS) $(AR) rs $@ $? librtmp$(SO_EXT): $(OBJS) $(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB) ln -sf $@ librtmp.$(SOX) log.o: log.c log.h Makefile rtmp.o: rtmp.c rtmp.h rtmp_sys.h handshake.h dh.h log.h amf.h Makefile amf.o: amf.c amf.h bytes.h log.h Makefile hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h Makefile parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile librtmp.pc: librtmp.pc.in Makefile sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \ -e "s;@VERSION@;$(VERSION);" \ -e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \ -e "s;@PUBLIC_LIBS@;$(PUBLIC_LIBS);" \ -e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS);" librtmp.pc.in > $@ install: install_base $(SO_INST) install_base: librtmp.a librtmp.pc -mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3 $(SODIR) cp amf.h http.h log.h rtmp.h $(INCDIR) cp librtmp.a $(LIBDIR) cp librtmp.pc $(LIBDIR)/pkgconfig cp librtmp.3 $(MANDIR)/man3 install_so: librtmp$(SO_EXT) cp librtmp$(SO_EXT) $(SODIR) $(INSTALL_IMPLIB) cd $(SODIR); ln -sf librtmp$(SO_EXT) librtmp.$(SOX)