Newest 'x264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Gstreamer convert and display video v4l2 - tee problems in rust

    27 mars 2023, par d3im

    I have USB grabber v4l2 source and I want to tee stream to autovideosink and x264enc to file (now as fake black hole)

    When I disable one or another branch it works but together Pipeline goes:

    Pipeline state changed from Null to Ready
    Pipeline state changed from Ready to Paused
    

    and stays there never switches to Playing

    gst-launch-1.0 with similar functionality works well.

        gst::Element::link_many(&[&pw_video, &v_caps, &vid_queuey, &vid_tee]).unwrap();
        gst::Element::link_many(&[&vid_queue1, &autovideoconvert, &vid_queuex, &autovideosink]).unwrap();
        gst::Element::link_many(&[&vid_queue2, &autovideoconvert_x264, &vid_queue3, &x264, &vid_queue4, &fake]).unwrap();
    
        let tee_display_pad = vid_tee.request_pad_simple("src_10").unwrap();
        let vid_queue1_pad = vid_queue1.static_pad("sink").unwrap();
    
        tee_display_pad.link(&vid_queue1_pad).unwrap();
    
        let tee_convert_pad = vid_tee.request_pad_simple("src_20").unwrap();
        let vid_queue2_pad = vid_queue2.static_pad("sink").unwrap();
    
        tee_convert_pad.link(&vid_queue2_pad).unwrap();
    

    How can I use tee in rust properly to have playable pipeline with two branches?

    Update: I read some posts about increasing queue size, so I tried for this and then all queues:

        let vid_queue1 = gst::ElementFactory::make("queue")
            .name("queue1")
            .property("max-size-buffers", 5000 as u32)
            .property("max-size-bytes", 1048576000 as u32)
            .property("max-size-time", 60000000000 as u64)
            .build()
            .expect("queue1");
    

    but it didn't help so I tried set zero latency:

        let x264 = gst::ElementFactory::make("x264enc")
            .name("x264")
            .property_from_str("speed-preset", "ultrafast")
            .property_from_str("pass", "qual")
            .property_from_str("tune", "zerolatency")
            .property("quantizer", 0 as u32)
            .property("threads", 8 as u32)
            .build()
            .expect("!x264");
    

    and it works now. But comparable gst-launch-1.0 settings didn't had such option - only queues sizes increased.

    Is there any other option than setting zerolatency?

  • How to fix the "No working C compiler found." problem for compiling x264 in Linux ?

    27 février 2023, par gc xu

    Firstly I have read all other solutions related to this problem, including adding path and reinstall yasm, nasm, gcc... I git clone the source code from https://code.videolan.org/videolan/x264.git. Then, I run command ./configure, it shows

    ./configure: line 169: conftest.log: Invalid argument
    ./configure: line 169: conftest.log: Invalid argument
    ./configure: line 169: conftest.log: Invalid argument
    ./configure: line 169: conftest.log: Invalid argument
    No working C compiler found.
    

    I check the file "config.log". It shows:

    checking for -Werror=unknown-warning-option... no
    Failed commandline was:
    --------------------------------------------------
    gcc conftest.c  -Wall -I. -I$(SRCPATH)   -Werror=unknown-warning-option   -o conftest
    cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    int main (void) {  return 0; }
    --------------------------------------------------
    checking for -Werror=unknown-attributes... no
    Failed commandline was:
    --------------------------------------------------
    gcc conftest.c  -Wall -I. -I$(SRCPATH)   -Werror=unknown-attributes   -o conftest
    cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    int main (void) {  return 0; }
    --------------------------------------------------
    checking for -Werror=attributes... no
    Failed commandline was:
    --------------------------------------------------
    gcc conftest.c  -Wall -I. -I$(SRCPATH)   -Werror=attributes   -o conftest
    cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    int main (void) {  return 0; }
    --------------------------------------------------
    checking for -Werror=ignored-attributes... no
    Failed commandline was:
    --------------------------------------------------
    gcc conftest.c  -Wall -I. -I$(SRCPATH)   -Werror=ignored-attributes   -o conftest
    cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    int main (void) {  return 0; }
    --------------------------------------------------
    x264 configure script
    Command line options: "--enable-shared" "--enable-static"
    
    checking whether gcc works... no
    Failed commandline was:
    --------------------------------------------------
    gcc conftest.c -m64  -Wall -I. -I$(SRCPATH)     -m64  -lm -o conftest
    cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option
    --------------------------------------------------
    Failed program was:
    --------------------------------------------------
    int main (void) {  return 0; }
    --------------------------------------------------
    DIED: No working C compiler found.
    

    Plus I wonder is there something to do with nasm? Becasuse I install nasm with some C grammer problems:

    ./config/config.h:659:16: error: duplicate ‘unsigned’
      659 | #define size_t unsigned int
          |                ^~~~~~~~
    ./config/config.h:659:25: error: two or more data types in declaration specifiers
      659 | #define size_t unsigned int
          |                         ^~~
    In file included from /usr/include/string.h:633,
                     from ./include/compiler.h:89,
                     from asm/nasm.c:38:
    ./include/compiler.h:241:7: error: expected identifier or ‘(’ before ‘__extension__’
      241 | char *strsep(char **, const char *);
          |       ^~~~~~
    ./include/compiler.h:241:7: error: expected identifier or ‘(’ before ‘)’ token
      241 | char *strsep(char **, const char *);
          |       ^~~~~~
    make[1]: *** [asm/nasm.o] Error 1
    make[1]: Leaving directory `/mnt/nfs0/gengcheng/ffmpeg-5.0.2/nasm-2.15.05'
    make: *** [all] Error 2
    

    I have read all other solutions related to this problem, including adding path and reinstall yasm, nasm, gcc... I want to install x264 to configure it in ffmpeg. Thanks for all your answers!

  • How to use x264 encoder in Ant Media Server v2.5

    26 février 2023, par faraway

    Ant Media Server starts to use OpenH264 as a software encoder in v2.5 but I need to use x264. How can I use x264 in Ant Media Server v2.5?

    https://github.com/ant-media/Ant-Media-Server/releases/tag/ams-v2.5.0 https://antmedia.io

  • Write x264 from OBS rtmp stream to file

    28 décembre 2022, par Dropye

    I wrote an Module for apache2 to receive RTMP streams from OBS. This works so far that I get Video and Audio messages. The first thing I would like to do is write that down into a file.

    The messages I get look like this:

     RTMP Body:    
        Control: 0xaf (HE-AAC 44 kHz 16 bit stereo)    
        Audio data: 00119056e500
    
    RTMP Body:
        Control: 0x17 (keyframe H.264)
        Video data: 000000000164001fffe1001d6764001facd94050053fa9a808080a000003000200000300791e30632c01000468efbcb0
    

    Iam not quite sure yet how to combine these Messages into a videofile. At first I thought of ffmpeg and wrote the Video into a pipe

    connection->output = popen("ffmpeg -v debug -y -f h264 -i - -an /usr/videos/output.mp4", "w");
    char controll = message->chunk_data[0];
        fwrite(&(message->chunk_data[0]), 1, message->message_header.length, connection->output);
    

    Output of ffmpeg is this:

    [h264 @ 0x561181677540] Unknown NAL code: 0 (445 bits)
    
    [h264 @ 0x561181677540] Unknown NAL code: 0 (18063 bits)
    
    [h264 @ 0x561181677540] no frame!
    
    Error while decoding stream #0:0: Invalid data found when processing input
    
    cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    
    Cannot determine format of input stream 0:0 after EOF
    
    Error marking filters as finished
    
    [AVIOContext @ 0x561181678380] Statistics: 0 seeks, 0 writeouts
    
    [AVIOContext @ 0x561180932000] Statistics: 6675219 bytes read, 0 seeks
    
    Conversion failed!
    

    Ffmpeg is clearly trying, but fails to read the input.

    How do I process these messages?

    EDIT:

    It seems that OBS is writing these packets with libx264 I will dig into this.

  • ffmpeg convert from H.264 (High 4:4:4 Profile) to H.265 (Main Profile)

    30 novembre 2022, par David Alonso Ruiz

    How can I convert a video from H.264 (High 4:4:4 Profile) to H.265 (Main Profile 4:2:0) using ffmpeg?

    I can't do that with this command: ffmpeg -i input.mkv -c:v hevc_nvenc -c:a copy output2.mkv

    That'd return an error, does not recognize the source format