Encoding failed when using gstreamer and enabled two-pass cbr mode

Hello,

I am trying to encode h264 files using gstreamer on the TX2 platform. Since we need to improve the video quality, we need to enable the two-pass-cbr mode. But there is a segment fault, the log is as follows:

gst-launch-1.0 filesrc location=dump_720p_v300_6.264 ! 'video/x-h264,stream-format=byte-stream,framerate=(fraction)30/1' ! h264parse ! queue ! omxh264dec ! nvvidconv ! 'video/x-raw(memory:NVMM), format=(string)I420,framerate=(fraction)30/1' ! omxh264enc iframeinterval=90 EnableTwopassCBR=1 control-rate=2 preset-level=3 profile=8 num-B-Frames=2  bitrate=900000 ! 'video/x-h264,stream-format=byte-stream' ! filesink location=dump_720p_v300_6_test.264
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
NvMMLiteOpen : Block : BlockType = 261 
TVMR: NvMMLiteTVMRDecBlockOpen: 7905: NvMMLiteBlockOpen 
NvMMLiteBlockCreate : Block : BlockType = 261 
TVMR: cbBeginSequence: 1224: BeginSequence  1280x720, bVPR = 0
TVMR: LowCorner Frequency = 100000 
TVMR: cbBeginSequence: 1623: DecodeBuffers = 2, pnvsi->eCodec = 4, codec = 0 
TVMR: cbBeginSequence: 1694: Display Resolution : (1280x720) 
TVMR: cbBeginSequence: 1695: Display Aspect Ratio : (1280x720) 
TVMR: cbBeginSequence: 1763: ColorFormat : 5 
TVMR: cbBeginSequence:1777 ColorSpace = NvColorSpace_YCbCr601
TVMR: cbBeginSequence: 1905: SurfaceLayout = 3
TVMR: cbBeginSequence: 2006: NumOfSurfaces = 9, InteraceStream = 0, InterlaceEnabled = 0, bSecure = 0, MVC = 0 Semiplanar = 1, bReinit = 1, BitDepthForSurface = 8 LumaBitDepth = 8, ChromaBitDepth = 8, ChromaFormat = 5
TVMR: cbBeginSequence: 2008: BeginSequence  ColorPrimaries = 1, TransferCharacteristics = 13, MatrixCoefficients = 1
Allocating new output: 1280x720 (x 9), ThumbnailMode = 0
OPENMAX: HandleNewStreamFormat: 3464: Send OMX_EventPortSettingsChanged : nFrameWidth = 1280, nFrameHeight = 720 
Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
===== MSENC blits (mode: 1) into tiled surfaces =====
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Caught SIGSEGV
#0  0x0000007f83b44030 in __GI___poll (fds=0x66ffd0, nfds=2, 
#1  0x0000007f83c453ac in ?? () from /lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x000000000049fad0 in ?? ()
Spinning.  Please run 'gdb gst-launch-1.0 6574' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

If I set the profile to baseline or set the B frame to 0 there is no segment fault.
The SDK version I am using is R28.1.0.
I do not know why.

Also, ask, can the two-pass-cbr mode be supported in tegra_multimedia_api?

Thank you for your help

Hi zhangjp,
We are confirming B frame encoding is not supported in two pass CBR mode. Please run without setting ‘num-B-frames’

We have confirmed B frame encoding is not supported in two pass CBR mode on r28.2.1.

Hello, DaneLLL,

Thank you for your reply.

We also experimented on the latest version, there will be no segment fault, but the encoded stream is not correct.

After the B frames is closed, the video quality is degraded too much. Our purpose is also to improve the video quality. It is meaningless to close the b frames.

We still hope to support two-pass mode and support B-frame on R28.1.0, because our products have been delivered to customers, we can not upgrade the system through usb cable, could you tell me how to fix this bug on the R28.1.0 version?

look forward to your help, Thanks!

https://media.xiph.org/video/derf/y4m/park_joy_1080p50.y4m

gst-launch-1.0 filesrc location= park_joy_1080p50.y4m ! y4mdec ! omxh264enc bitrate=12000000 profile=8 num-B-Frames=1 iframeinterval=1000 control-rate=constant vbv-size=50 qp-range=1,51:1,51:1,51 preset-level=3 ! 'video/x-h264,level=(string)4.2' ! h264parse ! 'video/x-h264,stream-format=avc' ! qtmux ! filesink location= park_joy.mov

Two pass CBR is strict in bitrate and quality may not be good. PLease run in CBR and set vbv-size. Above pipeline is for your reference.

Thank you, I will try it again!