Newest 'libx264' Questions - Stack Overflow
Les articles publiés sur le site
-
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!
-
ffmpeg ignores -metadata option when video is encoded
30 octobre 2018, par Rafael LimaI have a video with the following metadata:
rotate : 90
I'm using ffmpeg (4.0 binaries from windows downloaded from official website) to encode it and I want to delete this metadata information.
If I do:
ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate= output.mp4
the output will have removed the metadata.But if I do:
ffmpeg -i input.mp4 -c:v libx264 -metadata:s:v:0 rotate= output.mp4
then I still have the undesired metadata.Is there a way to remove metadata while encoding?
-
ffpmeg drops last frame when compressing from MP4 to MP4 (libx264)
28 octobre 2018, par UsoboiSo, I'm using this code to compress my *mp4 file. I need to get lower quality and decrease bitrate:
ffmpeg -i input.mp4 -c:v libx264 output.mp4
The problem is: the last frame of footage is dropped after ffmpeg compression. Screenshot is here: screenshot_ffmpeg_drop frame
I tried to use full preferences I need, but the problem is the same.
ffmpeg -i input.mp4 -c:v libx264 -vf scale=1280:720 -preset fast -crf 29 -r 25 -c:a copy output.mp4
logfile during ffmpeg encoding:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '\input.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41 creation_time : 2018-10-28T11:06:03.000000Z Duration: 00:00:12.76, start: 0.000000, bitrate: 5374 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 5368 kb/s, 25 fps, 25 tbr, 50k tbn, 50 tbc (default) Metadata: creation_time : 2018-10-28T11:06:03.000000Z handler_name : Alias Data Handler encoder : AVC Coding
Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Press [q] to stop, [?] for help [libx264 @ 000002fae8b50780] using SAR=1/1 [libx264 @ 000002fae8b50780] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 000002fae8b50780] profile High, level 3.1 [libx264 @ 000002fae8b50780] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=29.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to '\output.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42mp41 encoder : Lavf58.17.100 Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default) Metadata: creation_time : 2018-10-28T11:06:03.000000Z handler_name : Alias Data Handler encoder : Lavc58.19.104 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 318 fps=127 q=-1.0 Lsize= 855kB time=00:00:12.60 bitrate= 556.0kbits/s speed=5.05x video:851kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.534683% [libx264 @ 0000015d5cef0500] frame I:2 Avg QP:26.18 size: 67800 [libx264 @ 0000015d5cef0500] frame P:80 Avg QP:27.93 size: 5439 [libx264 @ 0000015d5cef0500] frame B:236 Avg QP:32.44 size: 1269 [libx264 @ 0000015d5cef0500] consecutive B-frames: 0.9% 0.0% 0.9% 98.1% [libx264 @ 0000015d5cef0500] mb I I16..4: 10.6% 62.5% 26.8% [libx264 @ 0000015d5cef0500] mb P I16..4: 0.5% 1.0% 0.2% P16..4: 36.1% 5.1% 3.6% 0.0% 0.0% skip:53.6% [libx264 @ 0000015d5cef0500] mb B I16..4: 0.6% 0.5% 0.0% B16..8: 22.2% 0.6% 0.0% direct: 2.0% skip:74.2% L0:44.9% L1:54.5% BI: 0.6% [libx264 @ 0000015d5cef0500] 8x8 transform intra:55.0% inter:86.2% [libx264 @ 0000015d5cef0500] coded y,uvDC,uvAC intra: 48.1% 54.9% 27.0% inter: 3.2% 5.2% 0.2% [libx264 @ 0000015d5cef0500] i16 v,h,dc,p: 19% 56% 10% 15% [libx264 @ 0000015d5cef0500] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 25% 18% 5% 6% 5% 8% 5% 8% [libx264 @ 0000015d5cef0500] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 24% 9% 5% 8% 7% 9% 5% 7% [libx264 @ 0000015d5cef0500] i8c dc,h,v,p: 60% 20% 15% 4% [libx264 @ 0000015d5cef0500] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 0000015d5cef0500] ref P L0: 67.7% 32.3% [libx264 @ 0000015d5cef0500] ref B L0: 80.4% 19.6% [libx264 @ 0000015d5cef0500] ref B L1: 92.1% 7.9% [libx264 @ 0000015d5cef0500] kb/s:547.35
-
How to use commercial libx264 with GStreamer ? [closed]
23 octobre 2018, par Vlad.ZI need to produce an x264 video stream with my product using GStreamer framework, and I am going to get a commercial x264 license for that. But now the question is how to actually plug the commercial x264 into GStreamer, because the x264enc element is under GPL. Anyone has experience with this? Thanks.
-
How can I set x.264 lambda parameter ? [closed]
5 octobre 2018, par AtrinI'm wondering how I can change lambda parameter in x.264? that would be great if I can have a sample command to do that.