Newest 'libx264' Questions - Stack Overflow
Les articles publiés sur le site
-
Stream video and commands on same connection or split connections ?
10 mai 2013, par bizzehdeeBackground
I am in the middle of writing a client/server app that i will install on every machine within my office (roughly 30 - 35 machines). I currently have the client connecting to the server and it has an ability to send mouse movement, mouse clicks, key strokes and execute certain commands. The next step is to stream back a video output of the screen, i am using the GDI method from Fastest method of screen capturing to capture the entire screen and will be using the x264 encoder to compress the frames and transmit them back to the client which will then decode and display the stream.
Question
is it best (by means of reducing lag, ensuring all commands are delivered as fast as possible and that streaming is as live as possible) that i transmit back along the same connection that i established for the commands, or, should i establish a separate connection on the same port, or on a different port to stream back the video?
P.S.
i am aware that VNC, RD and other things such as TeamViewer already exist and already do this sort of thing, but none of these support all the requirements needed for what we need within this system.
-
is this right when i use the x264 ?
22 avril 2013, par chinayinis this right to use the new x264 api ,i want to get a frame ,and encode it with x264,then save it to a .264 file? but i do not know is this is right ?
picIn.img.plane[0] = pInBuffer ; picIn.img.plane[1] = pInBuffer +m_VideoEncParam.nWidth*m_VideoEncParam.nHeight ; picIn.img.plane[2] = pInBuffer +m_VideoEncParam.nWidth*m_VideoEncParam.nHeight*5/4 ; picIn.img.i_stride[0] = m_VideoEncParam.nWidth ; picIn.img.i_stride[1] = m_VideoEncParam.nWidth /2 ; picIn.img.i_stride[2] = m_VideoEncParam.nWidth /2 ; nRet = x264_encoder_encode( m_pX264Handle, &pNal, &nNalCount, &picIn, &picOut); if (nRet<0) { return -1 ; } for (int i = 0 ;i
/memcpy(pOut+nLenOut,&pNal[i],pNal[i].i_payload) ; x264_nal_encode(m_pX264Handle,pOutBuffer+nLenOut,&pNal[i]); nLenOut += pNal[i].i_payload ; } int nSize = 0 ; FILE *pFile = fopen(pchFileName,"w") ; if (!pFile) { return -1 ; } nSize = fwrite(pOutBuffer,1,nLenOut,pFile) ; fclose(pFile) ; -
ffmpeg + x264 in Android, undefined reference to several functions
13 avril 2013, par user1914692I was trying to use the halfninja's tutorial to get the library for Android.
However, it has error:
error: ERROR: libx264 not found
After painful searching, I found that Panayiotis Karabassis's configuration works.
for x264 configuration, we need to add:
--enable-static \
for ffmpeg configuration,
--ld=arm-linux-androideabi-gcc \ --extra-libs="-lgcc"
I do not know why we should use ld=arm-linux-androideabi-gcc, rather than ld=arm-linux-androideabi-ld. But if we use ld=arm-linux-androideabi-ld, the compiling will not work.
Anyway, now I get libvideokit.so I put it in the jni project folder. I include the header files. So snippet in Android.mk is:
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include LOCAL_LDLIBS += -L$(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm/usr/lib -L$(LOCAL_PATH) LOCAL_LDLIBS += -lvideokit LOCAL_LDLIBS += -llog -ldl LOCAL_LDLIBS += -ljnigraphics
The related ffmpeg configuration are:
featureflags="--disable-everything \ --enable-decoder=mjpeg --enable-demuxer=mjpeg --enable-parser=mjpeg \ --enable-demuxer=image2 --enable-muxer=mp4 --enable-encoder=libx264 --enable-libx264 \ --enable-decoder=rawvideo \ --enable-protocol=file \ --enable-hwaccels" ./configure --enable-cross-compile \ --arch=arm5te \ --enable-armv5te \ --target-os=linux \ --disable-stripping \ --prefix=../output \ --disable-neon \ --enable-version3 \ --enable-shared \ --enable-static \ --enable-gpl \ --enable-memalign-hack \ --cc=arm-linux-androideabi-gcc \ --ld=arm-linux-androideabi-gcc \ --extra-cflags="-fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated" \ $featureflags \ --disable-everything \ --enable-decoders \ --enable-demuxers \ --enable-muxer=mp4 \ --enable-encoders \ --enable-libx264 \ --enable-protocols \ --enable-parsers \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-ffserver \ --enable-network \ --enable-filter=buffer \ --enable-filter=buffersink \ --enable-filter=scale \ --enable-bsfs \ --enable-swscale \ --enable-asm \ --disable-demuxer=v4l \ --disable-demuxer=v4l2 \ --disable-indev=v4l \ --disable-indev=v4l2 \ --extra-cflags="-I../x264" \ --extra-ldflags="-L../x264" \ --extra-libs="-lgcc"
In my jni c file jni_part.cpp, it Here is one snippet:
static int open_input_file(const char *filename, structForInVFile& inVStruct) { int ret; // static AVCodecContext *inCodecContext; inVStruct.video_stream_index = -1; AVCodec* inCodec; if ((ret = avformat_open_input(&(inVStruct.inFormatContext), filename, NULL, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n"); return ret; } if ((ret = avformat_find_stream_info(inVStruct.inFormatContext, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n"); return ret; } /* select the video stream */ ret = av_find_best_stream(inVStruct.inFormatContext, AVMEDIA_TYPE_VIDEO, -1, -1, &(inVStruct.inCodec), 0); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n"); return ret; } inVStruct.video_stream_index = ret; inVStruct.inCodecContext = inVStruct.inFormatContext->streams[inVStruct.video_stream_index]->codec; inVStruct.inFrameRate = inVStruct.inFormatContext->streams[inVStruct.video_stream_index]->r_frame_rate.num; /* init the video decoder */ if ((ret = avcodec_open2(inVStruct.inCodecContext, inVStruct.inCodec, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot open video decoder\n"); return ret; } if (ret == 0) { // Allocate AVFrame, AVPacekt for the input video file: inFormatContext inVStruct.inFrame = avcodec_alloc_frame(); if (!inVStruct.inFrame) { perror("Could not allocate inFrame"); exit(1); } } return 0; }
After building, the console information is:
./obj/local/armeabi-v7a/objs/native_sample/jni_part.o: In function `open_input_file': /AndrVideo/jni/jni_part.cpp:82: undefined reference to `avformat_find_stream_info' /AndrVideo/jni/jni_part.cpp:99: undefined reference to `avcodec_open2'
(and other undefined reference information in the remaining: such as: av_opt_set, av_frame_get_best_effort_timestamp, avcodec_free_frame, avformat_close_input, avcodec_encode_video2 etc.)
You could see that: function "avformat_open_input" can be resolved. But the next function "avformat_find_stream_info", is not undefined. Both functions are in the utils.c file. So the difference might be in the enable options. But I have no clue to find out the solution.
Help!! I have been stuck here for quite a while... BTW, the original cpp file in C++ environment works well.
[Update 1] I found the reason. The grabbed ffmpeg in halfninja is an old one. The old one does not have the function avformat_find_stream_info. I grab latest version of ffmpeg and x264. But there are still errors. Let me try to figure it out.
[Update 2] There are many versions for compiling ffmpeg+libx264 on Android. I want to use the latest version of ffmpeg and libx264. And I found combination of halfninja and vitamio can make compilation work. However, wait... Now I get the -lavdevice -lavformat -lavfilter -lavcodec -lswscale -lavutil -lx264 I include them in the jni in the Android app. Building the app is fine. However, running is not good. Error information is:
04-12 18:50:49.303: D/dalvikvm(8149): Trying to load lib /data/data/com.example.andrvideoprocess/lib/libnative_sample.so 0x4051def8 04-12 18:50:49.303: D/AndroidRuntime(8149): Shutting down VM 04-12 18:50:49.313: W/dalvikvm(8149): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0) 04-12 18:50:49.313: E/AndroidRuntime(8149): FATAL EXCEPTION: main 04-12 18:50:49.313: E/AndroidRuntime(8149): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1312]: 69 cannot locate '__aeabi_llsl'... 04-12 18:50:49.313: E/AndroidRuntime(8149): at java.lang.Runtime.loadLibrary(Runtime.java:434)
I spend a lot of time solving issues one by one. And now I am still far away from success. Help!!!
-
Debug Assertion Failed on dllinit.cpp Line703 by using own regular DLL
20 mars 2013, par user2190325I'm creating a Regular DLL(mylib.dll and mylib.lib) that using libx264.dll(dynamic linking by import lib) and libfaac.lib(static linking). mylib.dll created and has no build errors, but Debug Assertion Failed message popped up at runtime in dllinit.cpp:Line703.
How to solve above DLL-hells ?
-
Encoding h.264 with libavcodec/x264
13 mars 2013, par szatmaryI am attempting to encode video using libavcodec/libavformat. Audio works great, but when I try to encode video I get the following errors:
[libx264 @ 0x10182a000]broken ffmpeg default settings detected [libx264 @ 0x10182a000]use an encoding preset (vpre)
easy to fix using the command line ffmpeg, but I am trying to do this in C. my options are
AVStream *pVideoOutStream = av_new_stream(pOutFormatCtx, 0); AVCodecContext *pVideoOutCodecCtx = pVideoOutStream->codec; pVideoOutCodecCtx->codec_id = CODEC_ID_H264; pVideoOutCodecCtx->codec_type = CODEC_TYPE_VIDEO; pVideoOutCodecCtx->bit_rate = pVideoInCodecCtx->bit_rate; pVideoOutCodecCtx->width = pVideoInCodecCtx->width; pVideoOutCodecCtx->height = pVideoInCodecCtx->height; pVideoOutCodecCtx->pix_fmt = pVideoInCodecCtx->pix_fmt; pVideoOutCodecCtx->sample_rate = pVideoInCodecCtx->sample_rate; pVideoOutCodecCtx->gop_size = 30;
but avcodec_open() fails.
What other values do I need to set to make x264 happy?