Thank for your reply so quickly!
I have a try to add a nvvideoconvert before video encoder as follows:
if (!bbox_enabled && (sr_mode == 0 || sr_mode == 1)) {
GstElement *queue_decode = gst_element_factory_make ("queue", NULL);
GstElement *decoder1 = gst_element_factory_make ("nvv4l2decoder", NULL);
GstElement *parser_pre_recordbin =
gst_element_factory_make ("h264parse", "parser-pre-recordbin");
GstElement *swconv_caps = gst_element_factory_make ("capsfilter", NULL);
GstCaps *conv_caps = gst_caps_from_string ("video/x-raw(memory:NVMM),format=(string)NV12,width=(int)320, height=(int)240");
g_object_set (G_OBJECT (swconv_caps), "caps", conv_caps, NULL);
gst_caps_unref (conv_caps);
GstElement *encoder =
gst_element_factory_make ("nvv4l2h264enc", "encoder");
GstElement *nvvidconv3 = gst_element_factory_make ("nvvideoconvert", "nvvidconv3");
gst_bin_add_many (GST_BIN (pipeline), queue_decode,decoder1,swconv_caps, nvvidconv3,encoder, NULL);
gst_bin_add_many (GST_BIN (pipeline), parser_pre_recordbin, NULL);
if (!gst_element_link_many (tee_pre_decode,queue_decode,decoder1,nvvidconv3,swconv_caps,encoder, parser_pre_recordbin,
nvdssrCtx->recordbin, NULL)) {
g_print ("Elements not linked. Exiting. \n");
g_main_loop_quit(loop);
}
gst_element_sync_state_with_parent(parser_pre_recordbin);
}
Now we can record a customed resolution video.
We meet a little problem at the first record which seems can be not synced firstly. But it will be fine at the next record.
Recording started..
In cb_newpad
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
Stream format not found, dropping the frame
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
H264: Profile = 66, Level = 0
NVMEDIA: Need to set EMC bandwidth : 126000
NVMEDIA: Need to set EMC bandwidth : 126000
NVMEDIA_ENC: bBlitMode is set to TRUE
Recording done.
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Recording started..
Recording done.