Newest 'libx264' Questions - Stack Overflow
Les articles publiés sur le site
-
Changing x264 settings on the fly
22 décembre 2018, par S RedI am curious to know if anyone has experience with modifying x264 settings during encoding (this is for testing live streaming hence I need to be able to modify settings based on cpu and upload characteristics).
I saw an API for encoder_reconfig() in x264.h, curious if folks have used that, and if its accessible from ffmpeg? Is it possible to modify a high-level option like 'preset', or do I need to modify individual options like chroma-me, trellis etc.
-
FFMPEG - MP4 won't play in FireFox - file corrupt
21 décembre 2018, par fightstarr20I am encoding
MP4
file usingFFMPEG
with the following command...ffmpeg -ignore_chapters 1 -i video.mov -c:v libx264 -preset veryslow -crf 23 -an -r 24 -s 1280x720 video.mp4
The resulting
MP4
file plays correctly in Chrome, but inSafari
andFireFox
I get nothing. FireFox tells me the file is corrupt and can't be played.Where am I going wrong?
-
How to disable libx264 stderr output ?
20 décembre 2018, par DaveI'm writing a library that uses the ffmpeg library interface (libavcodec, libavformat, libavutil, etc.) to manipulate some video. Part of this involves some encoding for which I'm using libx264. Everything works great but libx264 writes output to stderr, for example:
[libx264 @ 0x62cbc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512 [libx264 @ 0x62cbc0] profile High, level 5.0, 4:2:0, 8-bit [libx264 @ 0x62cbc0] frame I:28 Avg QP:26.78 size:144822 [libx264 @ 0x62cbc0] frame P:135 Avg QP:32.21 size: 30853 [libx264 @ 0x62cbc0] frame B:108 Avg QP:36.18 size: 15709 [libx264 @ 0x62cbc0] consecutive B-frames: 20.3% 79.7% [libx264 @ 0x62cbc0] mb I I16..4: 9.5% 75.9% 14.6% [libx264 @ 0x62cbc0] mb P I16..4: 1.1% 1.5% 1.4% P16..4: 44.8% 9.6% 4.2% 0.0% 0.0% skip:37.5% [libx264 @ 0x62cbc0] mb B I16..4: 0.3% 0.2% 0.4% B16..8: 49.8% 4.6% 0.9% direct: 1.0% skip:42.7% L0:46.9% L1:49.8% BI: 3.2% [libx264 @ 0x62cbc0] final ratefactor: 26.71 [libx264 @ 0x62cbc0] 8x8 transform intra:68.4% inter:70.4% [libx264 @ 0x62cbc0] direct mvs spatial:87.0% temporal:13.0% [libx264 @ 0x62cbc0] coded y,uvDC,uvAC intra: 76.2% 73.8% 31.6% inter: 9.7% 9.5% 4.2% [libx264 @ 0x62cbc0] i16 v,h,dc,p: 9% 57% 7% 27% [libx264 @ 0x62cbc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 21% 4% 8% 9% 7% 12% 7% 22% [libx264 @ 0x62cbc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 28% 9% 6% 6% 6% 10% 6% 16% [libx264 @ 0x62cbc0] i8c dc,h,v,p: 20% 50% 19% 11% [libx264 @ 0x62cbc0] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 0x62cbc0] ref P L0: 73.2% 12.6% 10.0% 2.7% 1.1% 0.3% [libx264 @ 0x62cbc0] ref B L0: 92.3% 5.6% 1.7% 0.4% [libx264 @ 0x62cbc0] kb/s:7912.01
It is not acceptable for my library to write to stdout or stderr. How can I programmatically disable this output to stderr?
I realize that I can "hijack" stderr, but this seems like a crude hack and I would strongly prefer not to do so.
-
Libsourcey : Segmentation fault
12 décembre 2018, par Iranna PattarI am running WebRTC Native Video Recorder demo Application,but getting Segmentation fault (core dumped).
here is the cmake command:
cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_SHARED_LIBS=OFF -DBUILD_MODULES=OFF -DBUILD_APPLICATIONS=OFF \ -DBUILD_SAMPLES=ON -DBUILD_TESTS=OFF -DWITH_WEBRTC=ON -DWITH_FFMPEG=ON -DBUILD_MODULE_base=ON \ -DBUILD_MODULE_crypto=ON -DBUILD_MODULE_http=ON -DBUILD_MODULE_json=ON -DBUILD_MODULE_av=ON \ -DBUILD_MODULE_net=ON -DBUILD_MODULE_socketio=ON -DBUILD_MODULE_symple=ON -DBUILD_MODULE_stun=ON \ -DBUILD_MODULE_turn=ON -DBUILD_MODULE_util=ON -DBUILD_MODULE_uv=ON -DBUILD_MODULE_webrtc=ON \ -DBUILD_SAMPLES_webrtc=ON -DWEBRTC_INCLUDE_DIR=/home/ubuntu/temp/webrtc-22215-ab42706-linux-x64/include \ -DWEBRTC_LIBRARIES=/home/ubuntu/temp/webrtc-22215-ab42706-linux-x64/lib/ \ -DWEBRTC_ROOT_DIR=/home/ubuntu/temp/webrtc-22215-ab42706-linux-x64 \ -DBUILD_MODULE_openssl=ON -DOPENSSL_ROOT_DIR=/usr/local/ssl -DOPENSSL_LIBRARIES=/usr/local/ssl/lib/ \ -DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include/openssl/
and Resolution is 640*480 , bit rate 128000, profile level is 3.2 .
[libx264 @ 0x7f63dc001600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 LZCNT BMI1 [libx264 @ 0x7f63dc001600] profile High, level 3.2 Segmentation fault (core dumped)
I have tried to track with gdb and backtrace but couldnt find
[libx264 @ 0x7fffa4001600] profile High, level 3.2 Thread 19 "IncomingVideoSt" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffd76fd700 (LWP 21381)] 0x00000001000001e0 in ?? () bt #0 0x00000001000001e0 in ?? () #1 0x00007ffff5380c6c in x264_stack_align () from /usr/lib/x86_64-linux-gnu/libx264.so.155 #2 0x00007fffd76f710c in ?? () #3 0x00007fffd76f7110 in ?? () #4 0x0000000000000000 in ?? ()
How to resolve this error?
-
RTMP live stream directly from NVENC encoder
16 novembre 2018, par rndI am trying to create a live RTMP stream containing the animation generated with NVIDIA OptiX. The stream is to be received by nginx + rtmp module and broadcasted in MPEG-DASH format. Full chain up to dash.js player is working if the video is first saved to .flv file and then I send it with ffmpeg without any reformatting using command:
ffmpeg -re -i my_video.flv -c:v copy -f flv rtmp://x.x.x.x:1935/dash/test
But I want to stream directly from the code. And with this I am failng... Nginx logs an error "dash: invalid avcc received (2: No such file or directory)". Then it seems to receive the stream correctly (segments are rolling, dash manifest is there), however the stream is not possible to play in the browser.
I can see only one difference in the manifest between direct stream and stream from file. Codecs attribute of the representation in the direct stream is missed: codecs="avcc1.000000" instead of "avc1.640028" which I get when streaming from file.
My code opens the stream:
av_register_all(); AVOutputFormat* fmt = av_guess_format("flv", file_name, nullptr); fmt->video_codec = AV_CODEC_ID_H264; AVFormatContext* _oc; avformat_alloc_output_context2(&_oc, fmt, nullptr, "rtmp://x.x.x.x:1935/dash/test"); AVStream* _vs = avformat_new_stream(_oc, nullptr); _vs->id = 0; _vs->time_base = AVRational { 1, 25 }; _vs->avg_frame_rate = AVRational{ 25, 1 }; AVCodecParameters *vpar = _vs->codecpar; vpar->codec_id = fmt->video_codec; vpar->codec_type = AVMEDIA_TYPE_VIDEO; vpar->format = AV_PIX_FMT_YUV420P; vpar->profile = FF_PROFILE_H264_HIGH; vpar->level = _level; vpar->width = _width; vpar->height = _height; vpar->bit_rate = _avg_bitrate; avio_open(&_oc->pb, _oc->filename, AVIO_FLAG_WRITE); avformat_write_header(_oc, nullptr);
Width, height, bitrate, level and profile I get from NVENC encoder settings. I also do the error checking, ommited here. Then I have a loop writing each encoded packets, with IDR frames etc all prepared on the fly with NVENC. The loop body is:
auto & pkt_data = _packets[i]; AVPacket pkt = { 0 }; av_init_packet(&pkt); pkt.pts = av_rescale_q(_n_frames++, AVRational{ 1, 25 }, _vs->time_base); pkt.duration = av_rescale_q(1, AVRational{ 1, 25 }, _vs->time_base); pkt.dts = pkt.pts; pkt.stream_index = _vs->index; pkt.data = pkt_data.data(); pkt.size = (int)pkt_data.size(); if (!memcmp(pkt_data.data(), "\x00\x00\x00\x01\x67", 5)) { pkt.flags |= AV_PKT_FLAG_KEY; } av_write_frame(_oc, &pkt);
Obviously ffmpeg is writing avcc code somewhere... I have no clue where to add this code so the RTMP server can recognize it. Or I am missing something else?
Any hint greatly appreciated, folks!