Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
avcodec_find_encoder(AV_CODEC_ID_H264) returns null
25 mai, par Monjura RumiI am building an android application which will encode image captured from camera preview and later decode it. I am using ffmpeg library to encode and decode. To build static library with x264 I have used this tutorial. http://dl.dropbox.com/u/22605641/ffmpeg_android/main.html. As a source code of ffmpeg if I use the one downloaded from the link given in tutorial I can built it but can't build library if i use source code downloaded from here git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg. I have built library in ubuntu and using it in windows 7 in Eclipse. As I need only h264 encoder and decoder I have used following code for ffmpeg, slightly modified from tutorial.
#!/bin/bash NDK=~/Documents/android-ndk-r8e PLATFORM=$NDK/platforms/android-8/arch-arm PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 PREFIX=/home/android-ffmpeg function build_one { ./configure --target-os=linux --prefix=$PREFIX \ --enable-cross-compile \ --enable-runtime-cpudetect \ --disable-asm \ --arch=arm \ --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \ --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \ --disable-stripping \ --nm=$PREBUILT/bin/arm-linux-androideabi-nm \ --sysroot=$PLATFORM \ --enable-nonfree \ --enable-version3 \ --disable-everything \ --enable-gpl \ --disable-doc \ --enable-avresample \ --disable-ffplay \ --disable-ffserver \ --enable-ffmpeg \ --disable-ffprobe \ --enable-avcodec \ --enable-libx264 \ --enable-encoder=libx264 \ --enable-encoder=libx264rgb \ --enable-decoder=h263 \ --enable-decoder=h264 \ --enable-decoder=svq3 \ --enable-zlib \ --enable-gpl \ --enable-pic \ --disable-devices \ --disable-avdevice \ --extra-cflags="-I/home/android-ffmpeg/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \ --extra-ldflags="-L/home/android-ffmpeg/lib" make -j4 install $PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o $PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -L$PREFIX/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a } build_one
After building library I have been able to build android ndk. A little part of my JNI code is here.
JNIEXPORT jint JNICALL Java_com_example_testjava_TestjniActivity_initencoder(JNIEnv* env,jobject obj){ av_register_all(); avcodec_register_all(); codec = avcodec_find_encoder(AV_CODEC_ID_H264); if (!codec) { __android_log_write(ANDROID_LOG_INFO, "debug", "not found"); return -1; } . . . }
When I run my java source code that calls initencoder() I get -1 as return value and logcat prints "not found". That means avcodec_find_encoder() returns null and if condition is being ok. I don't know what's wrong. Why this function is returning null? I have searched a lot but did not find any solution that could guide me to right direction. some says to use avcodec_init(). But ndk-build command fails and shows error saying undefined reference to 'avcodec_init()'. I have started with library build because I thought may be I am doing wrong from the first stage. Did I make any mistake in library building like not enabling things that I should? Please help me here. This is kind of urgent for me.
-
FFMPEG - can you have comments in script files ?
25 mai, par rossmcmBecause of batch's poor ability to handle multi-line strings, I'm using FFMPEG script files more and more for
filter_complex
arguments. I'm wondering if there is any way to include comments in these files. They seem to be quite tolerant of white space and line breaks. I've tried:# # comment #
and
; ; comment ;
and
` ` comment `
and
' ' comment '
with no success. It doesn't look as if comments are officially supported, but I'm wondering of there is some syntax quirk that allows them?
*** CLARIFICATION ***
I'm not talking about comments in batch files here, but comments in
filter_complex_script
files. FFMPEG supports specifying thefilter_complex
argument string in a separate file. So instead of:ffmpeg -i "input.mp4" -filter_complex "[0:v] crop=w=100:h=100:x=12:y=34 " "output.mp4"
you can specify:
ffmpeg -i "input.mp4" -filter_complex_script "crop.txt" "output.mp4"
where crop.txt contains
[0:v] crop=w=100:h=100:x=12:y=34
This is really handy when the filter_complex string gets more complicated (I routinely deal with arguments 10,000 characters in length).
-
How can i burn in the current video playback percentage on to a video stream using FFMpeg
25 mai, par David ClewsI've taken alook at the drawtext filter in ffmpeg and it offers the ability to burn in the current local time directly on to the video stream. I would like this sort of behaviour but for a integer percentage value and the percentage symbol % after the actual value. I don't know if this is possible using FFMpeg on the command line. The formula should be something like.
ceil((t/duration)*100)
-
FFMPEG RTSP Stream timeout triggered after 30015.187000 ms
25 mai, par BatCoderI am trying to read several RTSP streams using opencv cv2.VideoCapture(URL). It has FFMPEG backend. Sometimes for few streams it is throwing timeout warning after 30 seconds.
[ WARN:0@123.394] global cap_ffmpeg_impl.hpp:453 _opencv_ffmpeg_interrupt_callback Stream timeout triggered after 30015.187000 ms
I tried setting up the timeout flag.
import os os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "timeout;5000" # 5 seconds cv2.VideoCapture("rtsp://URL", cv2.CAP_FFMPEG)
Ref: How to terminate cv2.VideoCapture(rtsp_url) call if execution stalls due to RTSP camera issues?
But still, it is waiting for 30 seconds before raising the warning.
OpenCV version: 4.4.0.x Python version: 3.9.x
Can we decrease the wait time from 30 seconds to a lower number ?
-
Convert m3u8 (HLS) to mpd (MPEG-DASH)
24 mai, par AlmogI have Live stream of HLS [https://82-80-192-30.vidnt.com/ipbc_IPBCchannel11LVMRepeat/definst/IPBCchannel11LVM_3.stream/playlist.m3u8] and I want to convert it to MPEG-DASH.
What is the best practice?
The stream is already h264 aac therefore I understand I do not need to reencode and I just need to transmux.
What should I use? ffmpeg? mp4box?
Notes:
I used nginx-rtmp-module (https://github.com/ut0mt8/nginx-rtmp-module/) in order to create DASH from RTMP stream according to this tutorial: https://isrv.pw/html5-live-streaming-with-mpeg-dash But nginx-rtmp-module can get as input just rtmp streams and it did not work for me with HLS stream.
I used ffmpeg in order to create dash from m3u8 as following:
ffmpeg -i https://82-80-192-30.vidnt.com/ipbc_IPBCchannel11LVMRepeat/_definst_/IPBCchannel11LVM_3.stream/playlist.m3u8 -strict -2 -min_seg_duration 2000 -window_size 5 -extra_window_size 5 -use_template 1 -use_timeline 1 -f dash out.mpd
But this is very limited. I can't control the segment duration. The
min_seg_duration
parameter of ffmpeg does not work very well for me, and also it can set the minimum duration while I want to limit the maximum duration of each segment (the segment comes out with ~10 seconds, while I need it to be ~2-4 seconds as I'm playing live).