TI中文支持网
TI专业的中文技术问题搜集分享网站

TDA4VM: Modify the video encoding demo by replacing the input source with a local file

Part Number:TDA4VM

Hello,

I wrote a program based on app_multi_cam_encode under the sdk  to try to verify the encode capability of TDA4 by reading a local file.

NOTE:

1.My design logic is to feed the image data into the buffer of appsrc on the basis of a pipeline that can run successfully.

2.There are nine input images, which are continuous video frames with a resolution of 1920X1080 in YUV format.

3,here is my Main function:

x_int32 app_multi_cam_encode_main(vx_int32 argc, vx_char *argv[])
{AppObj *obj = &gAppObj;vx_status status = VX_SUCCESS;//status =0;/*Optional parameter setting*/app_default_param_set(obj);if(!obj){printf("pointer obj is null \n");}/* GStreamer INIT  */gst_init(&argc, &argv);printf("gst_init_done \n");/*Update of parameters are config file read*/app_update_param_set(obj);if (status == VX_SUCCESS){status = app_init(obj);}//tivxTaskWaitMsecs(100);if (status == VX_SUCCESS){APP_PRINTF("App Init Done! \n");status = app_create_graph(obj);printf("4444 \n");status = app_run_graph(obj);APP_PRINTF("App Run Graph Done! \n");printf("run graph done!\n");app_delete_graph(obj);printf("App Delete Graph Done! \n");app_deinit(obj);printf("App De-init Done! \n");}return status;
}

Here is the code I used to read the image and write it to the buffer

vx_status app_run_graph_for_one_frame_pipeline(AppObj * obj, vx_int32 frame_id)
{vx_status status = VX_SUCCESS;vx_char input_file_name[APP_MAX_FILE_PATH];//void *gst_data_ptr[MAX_NUM_CHANNELS];uint8_t *gst_data_ptr =NULL;snprintf(obj->input_file_path, APP_MAX_FILE_PATH,"/opt/vision_apps/test_data/encode_test");snprintf(input_file_name, APP_MAX_FILE_PATH, "%s/out%d.yuv", obj->input_file_path, frame_id);printf("inputfilename=%s \n",input_file_name);obj->gstPipeObj.num_channels = 1;gst_data_ptr = (uint8_t *)calloc(obj->gstPipeObj.size, sizeof(uint8_t));printf("alloc gst_data_ptr is ok\n");// status = copy_image(&img_arr, gst_data_ptr, obj->sensorObj.num_cameras_enabled);printf("we can go to get image \n");//status = readScalerInput1(input_file_name,obj->input.arr[0], APP_MODULES_READ_FILE, 0, &(obj->input.arr[0]), gst_data_ptr, obj->sensorObj.num_cameras_enabled);status = get_image(input_file_name, gst_data_ptr,&obj->gstPipeObj,obj);return status;
}


//add by john 
vx_status get_image(char *file_name, uint8_t *gst_data_ptr,GstPipeObj *gstPipeInst, AppObj *obj){vx_status status = VX_SUCCESS;FILE *fp = fopen(file_name, "rb");// fseek(fp,0,SEEK_END);// long length = ftell(fp);// printf ("the size of input image =%ld\n",length);vx_int32 j;vx_uint32 num_bytes = 0;void * null_test =NULL;void * data_ptr = gst_data_ptr;printf("start to get image\n");int32_t img_height = gstPipeInst->height;int32_t img_width = gstPipeInst->width;printf("img_height=%d\n",img_height);printf("img_width=%d\n",img_width);if (fp == NULL){printf("Unable to open file %s \n", file_name);return (VX_FAILURE);}/* Copy Luma */for (j = 0; j < img_height; j++){num_bytes += fread(data_ptr, 1, img_width, fp);//printf("j=%d,img_height=%d",j,img_height);//printf("numbyts= %d\n",num_bytes);}printf("copy luma done!!!\n");/*copy crcb*/num_bytes = 0;for (j = 0; j < img_height / 2; j++){num_bytes += fread(data_ptr, 1, img_width, fp);}printf("read image done!\n");status = push_image_to_bufffer(&obj->gstPipeObj,gst_data_ptr);//printf("now push none~~\n");//status = push_image_to_bufffer(&obj->gstPipeObj,null_test);printf("gst_data_ptr=%d\n", *gst_data_ptr);fclose(fp);printf("status=%d\n",status);return status;}

//add the own push_data_buffer func
int32_t push_image_to_bufffer(GstPipeObj *gstPipeInst, void* p_dataArr)
{int32_t status =0;
/* Replace by GstBufferPool implementation (dequeue, update, enqueue) */GstBuffer *in_buff = NULL;in_buff = gst_buffer_new_wrapped (p_dataArr, gstPipeInst->size);if (in_buff == NULL){printf("gst_wrapper: gst_buffer_new_wrapped() FAILED!\n");status = -1;}GstFlowReturn ret;ret = gst_app_src_push_buffer(GST_APP_SRC(gstPipeInst->m_srcElemArr[0]), in_buff);if (ret != GST_FLOW_OK){printf("gst_wrapper: Pushing buffer to AppSrc returned %d instead of GST_FLOW_OK:%d\n", ret, GST_FLOW_OK);status = -1;}printf("push buffer data to appsrc successful!!!!!!!!!!!and the status = %d\n",status);if (status==0) gstPipeInst->push_count++;return status;
}

The output file was found to be empty by the printed log:

root@j7-evm:/opt/vision_apps# rm -rf output_video_00.mp4
root@j7-evm:/opt/vision_apps# ./vx_app_encode.out
APP: Init ... !!!
MEM: Init ... !!!
MEM: Initialized DMA HEAP (fd=4) !!!
MEM: Init ... Done !!!
IPC: Init ... !!!
IPC: Init ... Done !!!
REMOTE_SERVICE: Init ... !!!
REMOTE_SERVICE: Init ... Done !!!79.460067 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!79.469812 s:  VX_ZONE_INIT:Enabled79.469822 s:  VX_ZONE_ERROR:Enabled79.469836 s:  VX_ZONE_WARNING:Enabled79.472450 s:  VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!79.474612 s:  VX_ZONE_INIT:[tivxHostInitLocal:86] Initialization Done for HOST !!!
1111
gst_init_done
!!!!appsrcnamearr=myAppSrc0
gst param set ok!
gst_wrapper: GstCmdString:
appsrc format=GST_FORMAT_TIME is-live=true do-timestamp=true block=false name=myAppSrc0 ! queue
! video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, format=(string)NV12, interlace-mode=(string)progressive, colorime
! v4l2h264enc bitrate=10000000
! h264parse
! mp4mux
! filesink location=output_video_00.mp4

GstPipe init done
3333
create a new gstpipe successful
[73.307909] img_enc 4200000.video-encoder: vxe_g_ext_ctrls Invalid control id 0x980927
gst_app_src_set_caps is okkk!
Gst Pipeline done!
4444
set gs[73.316956] img_enc 4200000.video-encoder: vxe_g_ext_ctrls Invalid control id 0x980927
t state OK
here to run the app!
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out0.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img[73.344761] img_enc 4200000.video-encoder: vxe_g_ext_ctrls Invalid control id 0x980928
_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out1.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out2.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out3.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out4.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out5.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out6.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out7.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
start to in cycle!
inputfilename=/opt/vision_apps/test_data/encode_test/out8.yuv
alloc gst_data_ptr is ok
we can go to get image
start to get image
img_height=1080
img_width=1920
copy luma done!!!
read image done!
push buffer data to appsrc successful!!!!!!!!!!!and the status = 0
gst_data_ptr=127
status=0
run graph done!80.391938 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.391964 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.391970 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference
App Delete Graph Done!80.392008 s: ISS: De-initializing sensor [IMX390-UB953_D3] ... !!!80.394225 s: ISS: De-initializing sensor [IMX390-UB953_D3] ... Done !!!80.394238 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394245 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394251 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394256 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394261 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394267 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394273 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394278 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394283 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394288 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394293 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394298 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394304 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394309 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394314 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394321 s:  VX_ZONE_ERROR:[ownReleaseReferenceInt:307] Invalid reference80.394358 s:  VX_ZONE_ERROR:[vxReleaseContext:1102] context is invalid
App De-init Done!80.394373 s:  VX_ZONE_INIT:[tivxHostDeInitLocal:100] De-Initialization Done for HOST !!!80.398757 s:  VX_ZONE_INIT:[tivxDeInitLocal:193] De-Initialization Done !!!
APP: Deinit ... !!!
REMOTE_SERVICE: Deinit ... !!!
REMOTE_SERVICE: Deinit ... Done !!!
IPC: Deinit ... !!!
IPC: DeInit ... Done !!!
MEM: Deinit ... !!!
MEM: Alloc's: 0 alloc's of 0 bytes
MEM: Free's : 0 free's  of 0 bytes
MEM: Open's : 0 allocs  of 0 bytes
MEM: Deinit ... Done !!!
APP: Deinit ... Done !!!

So I'd like to ask you all here about the possible reasons why my buffer file is not being written to the gstreamer's pipe.

Thanks.

Shine:

TDA系列目前主要通过英文e2e论坛提供技术支持。我把您的问题升级到e2e论坛了,请关注下面帖子的回复。https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1129969/tda4vm-modify-the-video-encoding-demo-by-replacing-the-input-source-with-a-local-file

,

Shine:

抱歉这么晚回复,下面是工程师的回复。Couple of questions and suggestions here.1. I see there are VX_ZONE_ERRORs, may be all the parameters are not released correctly. Could you resolve this first by releasing all the parameters? As Proper exit is required for the video file to be playable.2. Also, is the video file of size 0 or is it not playable? 3. You could try Gstreamer pipeline to do the same thing outside of the application first? Like just a gst-launch-1.0 multifilesrc location=out%01d.yuv ! (Rest of the same pipeline) instead of appsrc to see if you get a video file?4. GST_DEBUG and GST_TRACERS utilities could be used to see if where buffers are being lost in GStreamer. Could you provide the logs with this enabled?

赞(0)
未经允许不得转载:TI中文支持网 » TDA4VM: Modify the video encoding demo by replacing the input source with a local file
分享到: 更多 (0)