Newest 'x264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Compiling x264 for iOS 7

    25 janvier 2016, par user500

    I'm getting error on compiling x264 for iOS.

    I have Xcode Version 5.0 (5A1413) with Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn). I'm compiling x264-snapshot-20130925-2245.

    Config:

    CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang ./configure \
    --host=arm-apple-darwin \
    --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk \
    --prefix=armv7 \
    --extra-cflags='-arch armv7' \
    --extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/system -arch armv7" \
    --enable-pic \
    --enable-static
    

    Getting error:

    common/arm/cpu-a.S:29:7: error: unknown token in expression
    .align
          ^
    common/arm/cpu-a.S:139:5: error: instruction 'suble' can not set flags, but 's' suffix specified
        subles ip, ip, #1
        ^
    
  • How to get h264 video info ?

    3 janvier 2016, par Zelenov

    How can I get specific h264 video information from video file? I need to know profile (Baseline/Main/High) and is there B-Frames in movie?

  • How to enable X264 with thread for Android on Mac OS X ?

    3 janvier 2016, par Jerikc XIONG

    I use the following script to compile x264:

    #!/bin/bash
    # Based on https://github.com/yixia/x264/blob/master/build_android.sh
    
    if [ -z "$ANDROID_NDK" ]; then
        echo "You must define ANDROID_NDK before starting."
        echo "They must point to your NDK directories.\n"
        exit 1
    fi
    
    # Detect OS
    OS=`uname`
    HOST_ARCH=`uname -m`
    export CCACHE=; type ccache >/dev/null 2>&1 && export CCACHE=ccache
    if [ $OS == 'Linux' ]; then
        export HOST_SYSTEM=linux-$HOST_ARCH
    elif [ $OS == 'Darwin' ]; then
        export HOST_SYSTEM=darwin-$HOST_ARCH
    fi
    
    
    SOURCE=`pwd`
    PREFIX=$SOURCE/build/android
    
    SYSROOT=$ANDROID_NDK/platforms/android-12/arch-arm
    CROSS_PREFIX=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/$HOST_SYSTEM/bin/arm-linux-androideabi-
    EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__"
    EXTRA_LDFLAGS="-nostdlib"
    
    ./configure  --prefix=$PREFIX \
        --cross-prefix=$CROSS_PREFIX \
        --extra-cflags="$EXTRA_CFLAGS" \
        --extra-ldflags="$EXTRA_LDFLAGS" \
        --enable-pic \
        --enable-static \
        --enable-strip \
        --disable-cli \
        --host=arm-linux \
        --sysroot=$SYSROOT
    
    make clean
    make STRIP= -j4 install || exit 1
    

    After i add '-lpthread' , i got the following compile error:

    $ sh build_android.sh 
    No working C compiler found.
    Makefile:3: config.mak: No such file or directory
    ./configure
    platform:      X86_64
    byte order:    little-endian
    system:        MACOSX
    cli:           yes
    libx264:       internal
    shared:        no
    static:        no
    asm:           yes
    interlaced:    yes
    avs:           avxsynth
    lavf:          no
    ffms:          no
    mp4:           no
    gpl:           yes
    thread:        posix
    opencl:        yes
    filters:       crop select_every 
    debug:         no
    gprof:         no
    strip:         no
    PIC:           no
    bit depth:     8
    chroma format: all
    
    You can run 'make' or 'make fprofiled' now.
    dependency file generation...
    clang: error: no such file or directory: '/common/mc.c'
    clang: error: no such file or directory: '/common/predict.c'
    clang: error: no such file or directory: '/common/pixel.c'
    clang: error: no such file or directory: '/common/macroblock.c'
    clang: error: no such file or directory: '/common/frame.c'
    clang: error: no such file or directory: '/common/dct.c'
    clang: error: no such file or directory: '/common/cpu.c'
    clang: error: no such file or directory: '/common/cabac.c'
    clang: error: no such file or directory: '/common/common.c'
    clang: error: no such file or directory: '/common/osdep.c'
    clang: error: no such file or directory: '/common/rectangle.c'
    clang: error: no such file or directory: '/common/set.c'
    clang: error: no such file or directory: '/common/quant.c'
    clang: error: no such file or directory: '/common/deblock.c'
    clang: error: no such file or directory: '/common/vlc.c'
    clang: error: no such file or directory: '/common/mvpred.c'
    clang: error: no such file or directory: '/common/bitstream.c'
    clang: error: no such file or directory: '/encoder/analyse.c'
    clang: error: no such file or directory: '/encoder/me.c'
    clang: error: no such file or directory: '/encoder/ratecontrol.c'
    clang: error: no such file or directory: '/encoder/set.c'
    clang: error: no such file or directory: '/encoder/macroblock.c'
    clang: error: no such file or directory: '/encoder/cabac.c'
    clang: error: no such file or directory: '/encoder/cavlc.c'
    clang: error: no such file or directory: '/encoder/encoder.c'
    clang: error: no such file or directory: '/encoder/lookahead.c'
    clang: error: no such file or directory: '/x264.c'
    clang: error: no such file or directory: 'x264.o'
    clang: error: no input files
    clang: error: no such file or directory: '/input/input.c'
    clang: error: no such file or directory: 'input/input.o'
    clang: error: no input files
    clang: error: no such file or directory: '/input/timecode.c'
    clang: error: no such file or directory: 'input/timecode.o'
    clang: error: no input files
    clang: error: no such file or directory: '/input/raw.c'
    clang: error: no such file or directory: 'input/raw.o'
    clang: error: no input files
    clang: error: no such file or directory: '/input/y4m.c'
    clang: error: no such file or directory: 'input/y4m.o'
    clang: error: no input files
    clang: error: no such file or directory: '/output/raw.c'
    clang: error: no such file or directory: 'output/raw.o'
    clang: error: no input files
    clang: error: no such file or directory: '/output/matroska.c'
    clang: error: no such file or directory: 'output/matroska.o'
    clang: error: no input files
    clang: error: no such file or directory: '/output/matroska_ebml.c'
    clang: error: no such file or directory: 'output/matroska_ebml.o'
    clang: error: no input files
    clang: error: no such file or directory: '/output/flv.c'
    clang: error: no such file or directory: 'output/flv.o'
    clang: error: no input files
    clang: error: no such file or directory: '/output/flv_bytestream.c'
    clang: error: no such file or directory: 'output/flv_bytestream.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/filters.c'
    clang: error: no such file or directory: 'filters/filters.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/video.c'
    clang: error: no such file or directory: 'filters/video/video.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/source.c'
    clang: error: no such file or directory: 'filters/video/source.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/internal.c'
    clang: error: no such file or directory: 'filters/video/internal.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/resize.c'
    clang: error: no such file or directory: 'filters/video/resize.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/cache.c'
    clang: error: no such file or directory: 'filters/video/cache.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/fix_vfr_pts.c'
    clang: error: no such file or directory: 'filters/video/fix_vfr_pts.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/select_every.c'
    clang: error: no such file or directory: 'filters/video/select_every.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/crop.c'
    clang: error: no such file or directory: 'filters/video/crop.o'
    clang: error: no input files
    clang: error: no such file or directory: '/filters/video/depth.c'
    clang: error: no such file or directory: 'filters/video/depth.o'
    clang: error: no input files
    clang: error: no such file or directory: '/extras/getopt.c'
    clang: error: no such file or directory: 'extras/getopt.o'
    clang: error: no input files
    make: *** [.depend] Error 1
    

    How to enable pthread support?

  • Encoding Android Camera Frames h263/h264 [closed]

    29 décembre 2015, par Another Guy

    I want to implement a Video Chatting app on Android . I created a SurfaceView , get Camera preview and captured the frame as a byte[ ] using Camera.PreviewCallback.onPreviewFrame( ) method . Now I want to encode that byte[ ] to a h263 frame , pass over the network . Also get similar type of frame over network , decode it to a byte[ ] ( or a displayable format ) , and show it in a View . I want to do it at least 15 FPS rate . I am asking help for the encoding/decoding part .

    For that purpose , which library would be suitable for me ? From where I should start ? Is my starting point wrong ? Is there any support on SDK or would I have to use NDK ? I have heard about FFMpeg/x264 library , but I could not figure out how I can use them in my purpose . It's highly appreciated If you name any library , any reference , learning path , link or code snippet . Can you help me saying any workflow I should follow ? What if I want to use h264 encoding ? I just want to get it done , GPL/LGPL license of library would not matter a lot .

    I am a beginner in Android development . Any kind of assistance would be highly appreciated . Thanks in advance .

  • Latency in Gst-rtsp-server using appsrc

    18 décembre 2015, par alasin

    I'm trying to setup my own appsrc based Gst-rtsp-server which captures frames through Directshow, encodes to h264 stream and broadcasts the stream over LAN. Using this example as a reference, I have something like this:

    void need_data(GstElement *appsrc, guint unused, MyContext *ctx)
    {
        buffer = gst_buffer_new_allocate(NULL, size, NULL);
    
        captureThread->setMutex();
    
        gst_buffer_map (buffer, &info, GST_MAP_WRITE);
        memcpy (info.data, captureThread->getFrame(), size);
        gst_buffer_unmap (buffer, &info);
    
        /* Increment the timestamp for 25 fps */
        GST_BUFFER_PTS(buffer)      = ctx->timestamp;
        GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale_int(1, GST_SECOND, 40);
        ctx->timestamp             += GST_BUFFER_DURATION(buffer);
    
        g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret);
    
        captureThread->unsetMutex();
    }
    
    void media_configure(GstRTSPMediaFactory *factory, GstRTSPMedia *media, gpointer user_data)
    {
        GstElement *element, *appsrc;
        MyContext  *ctx;
    
        /* get the element used for providing the streams of the media */
        element = gst_rtsp_media_get_element(media);
    
        /* get our appsrc, we named it 'mysrc' with the name property */
        appsrc = gst_bin_get_by_name_recurse_up(GST_BIN(element), "mysrc");
    
        /* this instructs appsrc that we will be dealing with timed buffer */
        gst_util_set_object_arg(G_OBJECT(appsrc), "format", "time");
    
        /* configure the caps of the video */
        g_object_set(G_OBJECT(appsrc), "caps",
                 gst_caps_new_simple("video/x-raw",
                                     "format", G_TYPE_STRING, "NV12",
                                     "width", G_TYPE_INT, 640,
                                     "height", G_TYPE_INT, 480,
                                     "framerate", GST_TYPE_FRACTION, 25, 1, NULL), NULL);
    
        ctx = g_new0(MyContext, 1);
        ctx->timestamp = 0;
    
        /* make sure the data is freed when the media is gone */
        g_object_set_data_full(G_OBJECT(media), "my-extra-data", ctx, (GDestroyNotify)g_free);
    
        /* install the callback that will be called when a buffer is needed */
        g_signal_connect(appsrc, "need-data", (GCallback)need_data, ctx);
        gst_object_unref(appsrc);
        gst_object_unref(element);
    }
    
    int main(int argc, char *argv[])
    {
        GMainLoop *loop;
        GstRTSPServer *server;
        GstRTSPMountPoints  *mounts;
        GstRTSPMediaFactory *factory;
    
        /* This thread captures frames from dshow source at 30fps */
        captureThread = new CaptureThread();
        captureThread->Launch();
    
        gst_init(&argc, &argv);
    
        loop   = g_main_loop_new(NULL, FALSE);
        server = gst_rtsp_server_new();
    
        /* get the mount points for this server, every server has a default object
         * that be used to map uri mount points to media factories */
        mounts  = gst_rtsp_server_get_mount_points(server);
        factory = gst_rtsp_media_factory_new();
    
        gst_rtsp_media_factory_set_launch(factory,
                                      "( appsrc name=mysrc ! x264enc speed-preset=ultrafast tune=zerolatency ! rtph264pay name=pay0 pt=96 )");
    
        gst_rtsp_media_factory_set_shared(GST_RTSP_MEDIA_FACTORY(factory), TRUE);
    
        //gst_rtsp_media_factory_set_latency(factory, 10);
        g_signal_connect(factory, "media-configure", (GCallback)media_configure, NULL);
        gst_rtsp_mount_points_add_factory(mounts, "/test", factory);
    
        /* don't need the ref to the mounts anymore */
        g_object_unref(mounts);
    
        /* attach the server to the default maincontext */
        gst_rtsp_server_attach(server, NULL);
    
        g_print("stream ready at rtsp://127.0.0.1:8554/test\n");
        g_main_loop_run(loop);
    
        return 0;
    }
    

    I'm able to test the live feed at 25fps from a client but there's a constant lag offset of around 1 second. I've tried changing the fps, buffer timestamp and other things but the this lag still persists.

    Anything that could help me remove this lag would be much appreciated