Newest 'x264' Questions - Stack Overflow
Les articles publiés sur le site
-
When i build x264 and fdk-aac with android-ndk it comes unknown option —target-os=android, ignored
4 avril 2020, par Pradeep SimbaWhen I build x264 and fdk-aac with android-ndk it comes unknown option --target-os=android, ignored.
my build file.
How can I solve this?
-
Encoding YUV420 frames with x264 in C++
2 avril 2020, par Eoin McBennettIm trying to use libx264 to convert YUV 420 frames to H264, as per this question: (How does one encode a series of images into H264 using the x264 C API?) I have got my encoder parameters set up and my encoder initialised, the part that I am confused about is how do I give the encoder the YUV420 data I have? The question above shows how the data would be passed in and converted from RGB to YUV420.
I am also confused about what the stride, planes and nalls are within the x264 library any explanation of these would be greatly appreciated. I am very new to C++ and video processing in general.
The code I have currently is posted below. The YUV420 data I have is an unsigned char* called data that is declared outside of the function. Also the current resolution of the frames being captured is 640x480
void encode(){ x264_param_t param; x264_param_default_preset(¶m,"veryfast","zerolatency"); param.i_threads = 1; param.i_width = camera.getWidth(); param.i_height = camera.getHeight(); param.i_fps_num = 30; param.i_fps_den = 1; // Intra refres: param.i_keyint_max = 30; param.b_intra_refresh = 1; //Rate control: param.rc.i_rc_method = X264_RC_CRF; param.rc.f_rf_constant = 25; param.rc.f_rf_constant_max = 35; //For streaming: param.b_repeat_headers = 1; param.b_annexb = 1; x264_param_apply_profile(¶m, "baseline"); x264_t *encoder = x264_encoder_open(¶m); //H.264 encoder object x264_picture_t pic_in, pic_out; x264_picture_alloc(&pic_in, X264_CSP_I420,camera.getWidth(), camera.getHeight()); x264_nal_t *nals; //What is the purpose of nals? int i_nals; //Im constantly getting frames captured from the camera that I need to encod while(true){ //Im assuming the data would have to be placed within the pic_in pointer some how? int frame_size = x264_encoder_encode(encoder, &nals, &i_nals, &pic_in, &pic_out); if (frame_size >= 0) { std::cout<<"Encoded frame to h264!" << std::endl; } } }
Also if anyone could comment on the viability of this set up for video streaming, the end result of this project is to stream the captured and converted h264 frames over UDP for anything on the network to read and display.
Any help would be greatly appreciated!
-
How to benchmark x264 in ARM9 environment
16 mars 2020, par curious_beast1.How to benchmark x264 video encoder in Dual-core ARM Cortex™-A9?. 2.How to calculate the encoding speed with respect to the CPU clock frequency?. 3.Is h.264 lossless codec?.
-
How to get h264 bitrate
15 mars 2020, par Optimus PrimeTried MediaInfo, tried
ffprobe -show_streams -i "file.mkv"
(or raw file.h264) and it gives mebit_rate=N/A
. MediaInfo gives nothing at all.The only way I found out is by creating the .dga file by indexing it via MegUI and the using its Bitrate Calculator tool and setting the same exact size like the source, then it shows the average bitrate, but this way is ridiculous and who knows how accurate.
-
FFMPEG x264 (fourcc=0x21) codec is not working with OpenCV
6 mars 2020, par dkacI'm trying to use mp4 format coding (fourcc=0x21) on OpenCV 3.2 without success. Probably I have a problem with my Ubuntu 18.04 setup but currently I'm running out of ideas how to fix it. First, I recompiled FFMPEG with x264 support. Than, recompiled OpenCV (with contrib and OPENCV_ENABLE_NONFREE=ON, WITH_FFMPEG=ON). It is still not working.
I cannot use fourcc different than 0x21. I mean.. I cannot use another codec.
Example:
>>> import cv2 >>> out = cv2.VideoWriter('output.mp4', 0x21, 20.0, (640,480)) OpenCV: FFMPEG: tag 0x00000021/'!???' is not found (format 'mp4 / (null)')'
However, this is working fine (other fourcc, codec):
>>> out = cv2.VideoWriter('output.mp4',0x31637661 , 20.0, (640,480))
OpenCV compiled with FFMPEG support (version 3.2), cmake config:
Video I/O: DC1394 1.x: NO DC1394 2.x: YES (ver 2.2.5) FFMPEG: YES avcodec: YES (ver 57.107.100) avformat: YES (ver 57.83.100) avutil: YES (ver 55.78.100) swscale: YES (ver 4.8.100) avresample: YES (ver 3.7.0)
FFMPEG build with x264 support:
ffmpeg -version ffmpeg version N-96891-g60b1f85 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1) configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/user/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree libavutil 56. 42.100 / 56. 42.100 libavcodec 58. 73.102 / 58. 73.102 libavformat 58. 39.101 / 58. 39.101 libavdevice 58. 9.103 / 58. 9.103 libavfilter 7. 77.100 / 7. 77.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100
FFMPEG x264 simple conversion test is working:
ffmpeg -i in.mp4 -vcodec libx264 -f mp4 out.mp4y ffmpeg version N-96891-g60b1f85 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1) configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/user/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree libavutil 56. 42.100 / 56. 42.100 libavcodec 58. 73.102 / 58. 73.102 libavformat 58. 39.101 / 58. 39.101 libavdevice 58. 9.103 / 58. 9.103 libavfilter 7. 77.100 / 7. 77.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.83.100 Duration: 00:00:10.00, start: 0.000000, bitrate: 3826 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x960, 3825 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default) Metadata: handler_name : VideoHandler File 'out.mp4y' already exists. Overwrite? [y/N] y Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))