Newest 'libx264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • GStreamer x264enc not found

    5 avril 2017, par Dominik Schreiber

    I installed GStreamer-0.10 and all modules (base, good, bad, ugly, ffmpeg) according to these instructions (browse through by clicking prev/next): http://www.linuxfromscratch.org/blfs/view/svn/multimedia/gst-plugins-ugly.html

    Everything seemed to have worked just fine but when I want to execute my pipeline I got this error:

    glib.GError: no element "x264enc"
    

    Apparently the module was not installed:

    gst-inspect x264enc
    No such element or plugin 'x264enc'
    

    After that I installed the codec by executing:

    sudo apt-get install x264
    

    This did not work either. So I installed the latest build manually: http://www.videolan.org/developers/x264.html

    After a successful installation of x264 I ran ./configure on the gstreamer-0.10 ugly modules once again and found out about this:

    configure: *** checking feature: x264 plug-in ***
    configure: *** for plug-ins: x264 ***
    checking for X264... no
    configure: No package 'x264' found
    configure: *** These plugins will not be built: x264
    configure: creating ./config.status
    

    A check if x264 is available seems to get fullfilled:

    which x264
    /usr/local/bin/x264
    

    I'm using ubuntu server 12.04 LTS. Any ideas what I have to do to compile this module properly? Thanks!

  • very low latency streaminig with ffmpeg using a webcam

    22 mars 2017, par userDtrm

    I'm trying to configure ffmpeg to do a real-time video streaming using a webcam. The ffmpeg encoder command I use is as follows.

    ffmpeg -f v4l2 -input_format yuyv422 -s 640x480 -i /dev/video0 -c:v libx264 -profile:v baseline -trellis 0 -subq 1 -level 32 -preset superfast -tune zerolatency -me_method epzs -crf 30 -threads 0 -bufsize 1 -refs 4 -coder 0 -b_strategy 0 -bf 0 -sc_threshold 0 -x264-params vbv-maxrate=2000:slice-max-size=1500:keyint=30:min-keyint=10: -pix_fmt yuv420p -an -f mpegts udp://192.168.1.8:5001
    

    The ffplay command used to display the video feed is,

    ffplay -analyzeduration 1 -fflags -nobuffer -i udp://192.168.1.8:5001
    

    However, I'm experiencing a latency of 0.5 - 1.0s latency in the video stream. Is there a way to reduce this to a number less than 100ms. Also, when I replace the v4l2 camera capture with a screen capture using x11grab, the stream is almost real-time and I experience no noticeable delays. Moreover, changing the encoder from x264 to mpeg2 had no effect on the latency. In addition, the statistics from the ffmpeg shows that the encoder is performing at a 30fps rate, which I believe indicates that the encoding is real-time. This leaves me with only one reason for the experienced delay.

    • Is there a significant delay in buffers when using v4l2 during video capturing in a webcam?
    • I don't think the transmission delay is in effect in this case as I see no latencies when screen capture is used under the same conditions.
    • Can this latency be further reduced?. Can someone think of a different encoder configuration to be used instead of the one that I've been using?.

    Any suggestions or assistance is highly appreciated.

    Thank You.

  • Video streaming- control frame rate x264

    3 mars 2017, par H.A

    I'm new to video coding, I found this https://github.com/RafaelPalomar/H264LiveStreamer application code very useful to my project. I want to live stream a webcam over RTP . However, I'm having problem selecting the Frame Per Seconds (FPS). below is the function that controls the encoding param.

    void x264Encoder::initilize()
    {
      x264_param_default_preset(&parameters, "veryfast", "zerolatency");
      parameters.i_log_level =  X264_LOG_DEBUG;
      parameters.i_threads = 1;
      parameters.i_width = 640;
      parameters.i_height = 480;
      parameters.i_fps_num = 25;
      parameters.i_fps_den = 1;
      parameters.i_keyint_max = 25;
      parameters.b_intra_refresh = 1;
      parameters.rc.i_rc_method = X264_RC_CRF;
      parameters.rc.i_vbv_buffer_size = 1000000;
      parameters.rc.i_vbv_max_bitrate = 90000;
      parameters.rc.f_rf_constant = 25;
      parameters.rc.f_rf_constant_max = 35;
      parameters.i_sps_id = 7;
      // the following two value you should keep 1
      parameters.b_repeat_headers = 1;    // to get header before every I-Frame
      parameters.b_annexb = 1; // put start code in front of nal. we will remove start code later
      x264_param_apply_profile(&parameters, "baseline");
    
      encoder = x264_encoder_open(&parameters);
      x264_picture_alloc(&picture_in, X264_CSP_I420, parameters.i_width, parameters.i_height);
      picture_in.i_type = X264_TYPE_AUTO;
      picture_in.img.i_csp = X264_CSP_I420;
      // i have initilized my color space converter for BGR24 to YUV420 because my opencv video capture gives BGR24 image. You can initilize according to your input pixelFormat
      convertContext = sws_getContext(parameters.i_width,parameters.i_height, PIX_FMT_BGR24, parameters.i_width,parameters.i_height,PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
    }
    

    I'm using VLC as client whatever number i set i_fps_num to, I always get 12-14 FPS. fore example, in VLC Codec tab shows 25 FPS but in Stream statistics tab it shows it only display 13 FPS on average. here is the X264 encoder output

    x264 [debug]: frame=  72 QP=22.24 NAL=2 Slice:P Poc:144 I:97   P:116  SKIP:987  size=1464 bytes
    x264 [info]: frame I:1     Avg QP:20.06  size: 17848
    x264 [info]: frame P:72    Avg QP:22.12  size:  1337
    x264 [info]: mb I  I16..4: 40.2%  0.0% 59.8%
    x264 [info]: mb P  I16..4:  3.1%  0.0%  2.3%  P16..4:  8.3%  2.0%  0.6%  0.0%  0.0%    skip:83.7%
    x264 [info]: coded y,uvDC,uvAC intra: 53.6% 46.4% 7.4% inter: 3.0% 1.6% 0.0%
    x264 [info]: i16 v,h,dc,p: 11% 65% 12% 12%
    x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 46% 16%  3%  4%  3%  5%  3%  6%
    x264 [info]: i8c dc,h,v,p: 46% 42% 10%  2%
    x264 [info]: kb/s:312.60
    

    the last frame number that was encoded is 72 while in VLC stream statistics it shows that 133 frames are Displayed and 66 blocks are decoded for 10 seconds streaming in addition the video playback is bursty.

    my question is how to change the x264 parameters to get 25 FPS ?

  • Video streaming- control frame rate x264

    3 mars 2017, par H.A

    I'm new to video coding, I found this https://github.com/RafaelPalomar/H264LiveStreamer application code very useful to my project. I want to live stream a webcam over RTP . However, I'm having problem selecting the Frame Per Seconds (FPS). below is the function that controls the encoding param.

    void x264Encoder::initilize()
    {
      x264_param_default_preset(&parameters, "veryfast", "zerolatency");
      parameters.i_log_level =  X264_LOG_DEBUG;
      parameters.i_threads = 1;
      parameters.i_width = 640;
      parameters.i_height = 480;
      parameters.i_fps_num = 25;
      parameters.i_fps_den = 1;
      parameters.i_keyint_max = 25;
      parameters.b_intra_refresh = 1;
      parameters.rc.i_rc_method = X264_RC_CRF;
      parameters.rc.i_vbv_buffer_size = 1000000;
      parameters.rc.i_vbv_max_bitrate = 90000;
      parameters.rc.f_rf_constant = 25;
      parameters.rc.f_rf_constant_max = 35;
      parameters.i_sps_id = 7;
      // the following two value you should keep 1
      parameters.b_repeat_headers = 1;    // to get header before every I-Frame
      parameters.b_annexb = 1; // put start code in front of nal. we will remove start code later
      x264_param_apply_profile(&parameters, "baseline");
    
      encoder = x264_encoder_open(&parameters);
      x264_picture_alloc(&picture_in, X264_CSP_I420, parameters.i_width, parameters.i_height);
      picture_in.i_type = X264_TYPE_AUTO;
      picture_in.img.i_csp = X264_CSP_I420;
      // i have initilized my color space converter for BGR24 to YUV420 because my opencv video capture gives BGR24 image. You can initilize according to your input pixelFormat
      convertContext = sws_getContext(parameters.i_width,parameters.i_height, PIX_FMT_BGR24, parameters.i_width,parameters.i_height,PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
    }
    

    I'm using VLC as client whatever number i set i_fps_num to, I always get 12-14 FPS. fore example, in VLC Codec tab shows 25 FPS but in Stream statistics tab it shows it only display 13 FPS on average. here is the X264 encoder output

    x264 [debug]: frame=  72 QP=22.24 NAL=2 Slice:P Poc:144 I:97   P:116  SKIP:987  size=1464 bytes
    x264 [info]: frame I:1     Avg QP:20.06  size: 17848
    x264 [info]: frame P:72    Avg QP:22.12  size:  1337
    x264 [info]: mb I  I16..4: 40.2%  0.0% 59.8%
    x264 [info]: mb P  I16..4:  3.1%  0.0%  2.3%  P16..4:  8.3%  2.0%  0.6%  0.0%  0.0%    skip:83.7%
    x264 [info]: coded y,uvDC,uvAC intra: 53.6% 46.4% 7.4% inter: 3.0% 1.6% 0.0%
    x264 [info]: i16 v,h,dc,p: 11% 65% 12% 12%
    x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 46% 16%  3%  4%  3%  5%  3%  6%
    x264 [info]: i8c dc,h,v,p: 46% 42% 10%  2%
    x264 [info]: kb/s:312.60
    

    the last frame number that was encoded is 72 while in VLC stream statistics it shows that 133 frames are Displayed and 66 blocks are decoded for 10 seconds streaming in addition the video playback is bursty.

    my question is how to change the x264 parameters to get 25 FPS ?

  • testOnDemandRTSPServer opencv makefile

    7 février 2017, par user1683302

    I've been trying to create a Makefile to compile the files in this Live555: X264 Stream Live source based on "testOnDemandRTSPServer" answer . I'm having problems in compiling the files. I used Live555 Makefile as starting point but I have problem adding H.264 and opencv links and compile .cpp .h files. my opencv path is ~/src/opencv and h264 path is ~/src/h264 I have saved the files in a separate folder here is s list of filenames

    H264LiveServerMediaSession.cpp H264LiveServerMediaSession.h
    LiveSourceWithx264.cpp LiveSourceWithx264.h
    x264Encoder.cpp x264Encoder.h
    
    testOnDemandRTSPServer.cpp
    

    Here is my Makefile:

    INCLUDES = -I../src/live/UsageEnvironment/include -I../src/live/groupsock/include -I../src/live/liveMedia/include -I../src/live/BasicUsageEnvironment/include
    
    libliveMedia_LIB_SUFFIX = $(LIB_SUFFIX)
    libBasicUsageEnvironment_LIB_SUFFIX = $(LIB_SUFFIX)
    libUsageEnvironment_LIB_SUFFIX = $(LIB_SUFFIX)
    libgroupsock_LIB_SUFFIX = $(LIB_SUFFIX)
    ##### Change the following for your environment:
    COMPILE_OPTS =      $(INCLUDES) -I. -O2 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
    C =         c
    C_COMPILER =        cc
    C_FLAGS =       $(COMPILE_OPTS) $(CPPFLAGS) $(CFLAGS)
    CPP =           cpp
    CPLUSPLUS_COMPILER =    c++
    CPLUSPLUS_FLAGS =   $(COMPILE_OPTS) -Wall -DBSD=1 $(CPPFLAGS) $(CXXFLAGS)
    OBJ =           o    
    LINK =          c++ -o
    LINK_OPTS =     -L. $(LDFLAGS)
    CONSOLE_LINK_OPTS = $(LINK_OPTS)
    LIBRARY_LINK =      ar cr 
    LIBRARY_LINK_OPTS = 
    LIB_SUFFIX =            a
    
    ##### End of variables to change
    
    UNICAST_STREAMER_APPS = testOnDemandRTSPServer
    
    PREFIX = /usr/local
    
    all:$(UNICAST_STREAMER_APPS)
    
    
    
    .$(C).$(OBJ):
    $(C_COMPILER) -c $(C_FLAGS) $<
    .$(CPP).$(OBJ):
    $(CPLUSPLUS_COMPILER) -c $(CPLUSPLUS_FLAGS) $<
    
    
    ON_DEMAND_RTSP_SERVER_OBJS  = testOnDemandRTSPServer.$(OBJ)
    
    USAGE_ENVIRONMENT_DIR = ..../src/live/UsageEnvironment
    USAGE_ENVIRONMENT_LIB =       $(USAGE_ENVIRONMENT_DIR)/libUsageEnvironment.$(libUsageEnvironment_LIB_SUFFIX)
    BASIC_USAGE_ENVIRONMENT_DIR = ../src/live/BasicUsageEnvironment
    BASIC_USAGE_ENVIRONMENT_LIB = $(BASIC_USAGE_ENVIRONMENT_DIR)/libBasicUsageEnvironment.$(libBasicUsageEnvironment_LIB_SUFFIX)
    LIVEMEDIA_DIR = ../src/live/liveMedia
    LIVEMEDIA_LIB = $(LIVEMEDIA_DIR)/libliveMedia.$(libliveMedia_LIB_SUFFIX)
    GROUPSOCK_DIR = ../src/live/groupsock
    GROUPSOCK_LIB = $(GROUPSOCK_DIR)/libgroupsock.$(libgroupsock_LIB_SUFFIX)
    LOCAL_LIBS =    $(LIVEMEDIA_LIB) $(GROUPSOCK_LIB) \
        $(BASIC_USAGE_ENVIRONMENT_LIB) $(USAGE_ENVIRONMENT_LIB)
    LIBS =          $(LOCAL_LIBS) $(LIBS_FOR_CONSOLE_APPLICATION)
    
    
    testOnDemandRTSPServer: $(ON_DEMAND_RTSP_SERVER_OBJS) $(LOCAL_LIBS)
      $(LINK)$@ $(CONSOLE_LINK_OPTS) $(ON_DEMAND_RTSP_SERVER_OBJS) $(LIBS)
    
    
    
    clean:
    -rm -rf *.$(OBJ)