Newest 'x264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Rebuilding opencv and ffmpeg with x264 results in java.lang.UnsatisfiedLinkError

    30 avril 2013, par kev

    I've followed the readme file included with the cppjars zip file from javacv, I'm able to successfully build the libraries but when i run my app with the new .so files i get a java.lang.UnsatisfiedLinkError yet all the .so files exist in the armeabi folder. the line of code where this exception is triggered looks like this

    yuvIplimage = IplImage.create(imageWidth, imageHeight, IPL_DEPTH_8U, 2);
    

    and the exception is this

    04-29 15:40:46.610: E/AndroidRuntime(23057): FATAL EXCEPTION: main
    04-29 15:40:46.610: E/AndroidRuntime(23057): java.lang.ExceptionInInitializerError
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.sample.Stream.initRecorder(Stream.java:84)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.sample.Stream.onCreate(Stream.java:77)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.app.Activity.performCreate(Activity.java:4469)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.os.Handler.dispatchMessage(Handler.java:99)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.os.Looper.loop(Looper.java:137)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at android.app.ActivityThread.main(ActivityThread.java:4507)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at java.lang.reflect.Method.invokeNative(Native Method)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at java.lang.reflect.Method.invoke(Method.java:511)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at dalvik.system.NativeStart.main(Native Method)
    04-29 15:40:46.610: E/AndroidRuntime(23057): Caused by: java.lang.ExceptionInInitializerError
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at java.lang.Class.classForName(Native Method)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at java.lang.Class.forName(Class.java:217)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.googlecode.javacpp.Loader.load(Loader.java:338)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.googlecode.javacpp.Loader.load(Loader.java:319)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.googlecode.javacv.cpp.opencv_core$CvArr.(opencv_core.java:163)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    ... 16 more
    04-29 15:40:46.610: E/AndroidRuntime(23057): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1965]:   108 could not load needed library 'libopencv_core.so' for 'libjniopencv_core.so' (find_library[1200]:   108 'libopencv_core.so' failed to load previously)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at java.lang.Runtime.loadLibrary(Runtime.java:370)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at java.lang.System.loadLibrary(System.java:535)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:448)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.googlecode.javacpp.Loader.load(Loader.java:372)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.googlecode.javacpp.Loader.load(Loader.java:319)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    at com.googlecode.javacv.cpp.opencv_core.(opencv_core.java:136)
    04-29 15:40:46.610: E/AndroidRuntime(23057):    ... 21 more
    

    I've met all the requirements needed i.e, java SE 6, OpenCV 2.4.5, FFmpeg 1.2, Android NDK r8e. The OS is Ubuntu 11.10.

    I don't think the code is the problem because it works well when i use the bundled libraries from javacv but experience issues when i rebuild the libs to include x264.

    What am i doing wrong? I've tried both the 64 and 32 bit versions of the NDK but same problem persists.

  • FFmpeg screencast recording : which codecs to use ?

    24 avril 2013, par mkaito

    I've been experimenting with recording screencasts using FFmpeg's X11grab module, which has worked more or less fine so far. I understand that a/v encoding is a complex process with many fine details, but I'm doing my best to learn.

    I'd like to do "lightweight" recording of a video stream, that puts as little strain as possible on the system while the stream is being recorded. I record two audio streams separately with pacat and sox. Later, the whole thing is filtered, normalized, encoded, and combined into a Matroska container.

    Right now, I'm having ffmpeg record a rawvideo stream to be fed to x264's yuv4 demuxer. I experimented with ffv1 and straight x264 recording before. My system can't handle real time encoding with x264 on the settings I want for the final stream, so I have to recompress separately once the recording is done. I've found that ffv1 gives me terrible frame dropping, and yuv4 too, but less so. I suspect this is due to hard drive speed, even if I'm sitting in a SATA3 Caviar Black that's being used exclusively to hold the recorded data.

    The question is, which combination of video codecs should I look at? Record straight in x264 and recompress to "better" x264 later? Raw video, then compress? How would I go about pinpointing issues such as the frame drops I've been experiencing?

    EDIT: This is the ffmpeg line I currently use.

    ffmpeg -v warning -f x11grab -s 1920x1080 -r 30000/1001 -i :0.0\
    -vcodec rawvideo -pix_fmt yuv420p -s 1280x720\
    -threads 0\
    recvideo.y4m
    
  • is this right when i use the x264 ?

    22 avril 2013, par chinayin

    is 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) ;
    
  • is this right when i use the x264,thank you for your answer

    22 avril 2013, par chinayin

    is 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) ;
    
  • Mpeg Dash code having compilation issues and want to know what to do after the code is built and how to play the .mpd file generated

    11 avril 2013, par niuuuu

    I'm trying to build the DashEncoder code which I downloaded from github https://github.com/slederer/DASHEncoder. Well, I followed all the instructions given in the how to compile dash file. installed Gpac n X264 and compiled both successfully. Then did make of Dashencoder and ran it as ./Dashencoder. But I found some issues in it. Got this log :

    ==========DASH ENCODER===============
    Unknown option in resourcefile : sql-pw :
    current encoder x264
    YES
    x264 encoding @ 300 kbps: Pass 1 
    x264: x264 --profile baseline --preset slow --verbose --fps 24 --vbv-maxrate 300 --vbv-bufsize 600 --scenecut 0 --keyint 48 --output /opt/lampp/htdocs/tests_updates/sintel_trailer_2k_480p24_300kbit.h264 /home/niu/sintel_trailer_2k_480p24.y4m >out.txt 2>&1 
    mkdir: cannot create directory `/opt/lampp/htdocs/tests_updates/sintel_300kbit': File exists
    cp: omitting directory `/opt/lampp/htdocs/tests_updates/'
    copy audio: cp /opt/lampp/htdocs/tests_updates/ /opt/lampp/htdocs/tests_updates/sintel_300kbit/MP4Box multiplexing Video: /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.h264  
    mp4box: MP4Box -add /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.h264  /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.mp4
    AVC-H264 import - frame size 854 x 480 at 24.000 FPS
    AVC Import results: 1253 samples - Slices: 27 I 1226 P 0 B - 1 SEI - 27 IDR
    Saving to /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.mp4: 0.500 secs Interleaving
    MP4Box multiplexing Audio:/opt/lampp/htdocs/tests_updates/sintel_300kbit/ 
    mp4box: MP4Box -add /opt/lampp/htdocs/tests_updates/sintel_300kbit/ /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.mp4
    Unknown input file type
    Unknown input file type
    Error importing /opt/lampp/htdocs/tests_updates/sintel_300kbit/: Bad Parameter
    MP4Box Cleaning ... 
    mp4box: MP4Box -no-sys  /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.mp4
    Saving /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.mp4: 0.500 secs Interleaving
    MP4Box segmentation: /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.h264  
    mp4box: MP4Box -frag 2000 -dash 2000 -rap -segment-name /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.mp4
    DASH-ing file: 2.00s segments 2.00s fragments single sidx per segment
    Spliting segments at GOP boundaries
    [DASH] Generating MPD at time 2013-03-16T16:40:03Z
    DASHing file /opt/lampp/htdocs/tests_updates/sintel_300kbit/sintel_trailer_2k_480p24_300kbit.mp4
    terminate called after throwing an instance of 'std::out_of_range'
      what():  basic_string::substr
    Error: Unable to open MPD file!Aborted
    

    Why is this error at the end? and also one folder got created in my /opt/lampp/htdocs/tests_updates/sintel_300kbit. which has two types of files : 27 files of .m4s extension 1 file -sintelinit.mp4 1 file- sintel_trailer_2k_480p24_300kbit.mp4 , which when played in vlc player played the video bt no audio! &

    1 file- sintel_trailer_2k_480p24_300kbit.h264 which cannot be opened.

    No .mpd file was created.

    Also I want to know aft creating that .mpd file how will i be able to test it on my android client say media player.

    I am damn confused with all this happening. Please help.