Vipe
Posts: 4
Joined: Thu Aug 24, 2017 1:09 pm

Hello_videocube play 720p

Thu Aug 24, 2017 1:37 pm

Hello,

I am playing with the example hello_videocube and for two days I'm trying to play 720p via demuxing (and maybe later 1080p).
The 720p's videos have different data here is the metada with mediainfo :

720test_CBR10.mp4 :

Code: Select all

General
Complete name                            : 720test_CBR10.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/mp41)
File size                                : 149 MiB
Duration                                 : 2 min 13 s
Overall bit rate                         : 9 326 kb/s
Encoded date                             : UTC 2017-08-23 17:09:37
Tagged date                              : UTC 2017-08-23 17:09:44
©TIM                                     : 00:00:00:00
©TSC                                     : 25
©TSZ                                     : 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4.1
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 3 frames
Format settings, GOP                     : M=4, N=25
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 2 min 13 s
Bit rate                                 : 9 134 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.396
Stream size                              : 146 MiB (98%)
Language                                 : English
Encoded date                             : UTC 2017-08-23 17:09:37
Tagged date                              : UTC 2017-08-23 17:09:37
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
720test_CBR3.mp4 :

Code: Select all

General
Complete name                            : 720test_CBR3.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/mp41)
File size                                : 48.8 MiB
Duration                                 : 2 min 13 s
Overall bit rate                         : 3 057 kb/s
Encoded date                             : UTC 2017-08-23 17:09:28
Tagged date                              : UTC 2017-08-23 17:09:31
©TIM                                     : 00:00:00:00
©TSC                                     : 25
©TSZ                                     : 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4.1
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 3 frames
Format settings, GOP                     : M=4, N=25
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 2 min 13 s
Bit rate                                 : 2 865 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.124
Stream size                              : 45.7 MiB (94%)
Language                                 : English
Encoded date                             : UTC 2017-08-23 17:09:28
Tagged date                              : UTC 2017-08-23 17:09:28
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
720test_HighFlowRate :

Code: Select all

General
Complete name                            : 720test_HighFlowRate .mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/mp41)
File size                                : 162 MiB
Duration                                 : 2 min 13 s
Overall bit rate                         : 10.1 Mb/s
Encoded date                             : UTC 2017-08-23 17:09:30
Tagged date                              : UTC 2017-08-23 17:09:37
©TIM                                     : 00:00:00:00
©TSC                                     : 25
©TSZ                                     : 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4.1
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 3 frames
Format settings, GOP                     : M=4, N=25
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 2 min 13 s
Bit rate                                 : 9 825 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.426
Stream size                              : 157 MiB (97%)
Language                                 : English
Encoded date                             : UTC 2017-08-23 17:09:31
Tagged date                              : UTC 2017-08-23 17:09:31
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
720test_AverageFlowRate :

Code: Select all

General
Complete name                            : 720test_AverageFlowRate.mp4
Format                                   : MPEG-4
Codec ID                                 : M4V  (M4V /mp42/isom)
File size                                : 54.9 MiB
Duration                                 : 2 min 13 s
Overall bit rate                         : 3 441 kb/s
Encoded date                             : UTC 2017-08-23 17:09:26
Tagged date                              : UTC 2017-08-23 17:09:28
©TIM                                     : 00:00:00:00
©TSC                                     : 25
©TSZ                                     : 1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4.1
Format settings, CABAC                   : No
Format settings, RefFrames               : 2 frames
Format settings, GOP                     : M=1, N=25
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 2 min 13 s
Bit rate                                 : 3 250 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.141
Stream size                              : 51.9 MiB (94%)
Language                                 : English
Encoded date                             : UTC 2017-08-23 17:09:26
Tagged date                              : UTC 2017-08-23 17:09:26
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
If I use a 720p's video downloaded from Youtube it works but with this videos it doesn't. the video Start with a green screen but on the cube it's black on one video, and on other video it's all green. I don't know at all where is the error ...

here is the code :

Code: Select all

void * readVideo(void *argArf){
  int err;

  videoInfo * arg = (videoInfo*) argArf;

  ILCLIENT_T * client;

  if((client = ilclient_init()) == NULL){
    printf("ilclient_init failed\n");
    return (void*)-1;
  }

  if(OMX_Init() != OMX_ErrorNone){
    ilclient_destroy(client);
    printf("omx init failed\n");
    return (void*)-1;
  }

  COMPONENT_T * decodeComponent, * schedulerComponent, * clockComponent;//, * renderComponent;
  decodeComponent = schedulerComponent = clockComponent = NULL;//renderComponent = NULL;

  TUNNEL_T decodeTunnel, schedulerTunnel, clockTunnel;
  
  eglImage = arg->eglImage;
  if(eglImage == 0){
    printf("eglImage is null.\n");
    exit(1);
  }

  ilclient_set_fill_buffer_done_callback(client, my_fill_buffer_done, 0);
  
  err = ilclient_create_component(client, &decodeComponent, "video_decode", (ILCLIENT_CREATE_FLAGS_T)(ILCLIENT_DISABLE_ALL_PORTS | ILCLIENT_ENABLE_INPUT_BUFFERS));
  if(err != 0){
    printf("Setup Decode component failed\n");
    return (void*)-1;
  }
    
  err = ilclient_create_component(client, &renderComponent, "egl_render", (ILCLIENT_CREATE_FLAGS_T)(ILCLIENT_DISABLE_ALL_PORTS /*| ILCLIENT_ENABLE_INPUT_BUFFERS */| ILCLIENT_ENABLE_OUTPUT_BUFFERS));
  if(err != 0){
    printf("Setup Render component failed\n");
    return (void*)-1;
  }  

  err = ilclient_create_component(client, &clockComponent, "clock", (ILCLIENT_CREATE_FLAGS_T)ILCLIENT_DISABLE_ALL_PORTS);
  if(err != 0){
    printf("Setup Clock component failed\n");
    return (void*)-1;
  }

  OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refClock;  
  OMX_INIT_STRUCTURE(refClock);
  refClock.eClock = OMX_TIME_RefClockVideo;
  err = OMX_SetConfig(ilclient_get_handle(clockComponent), OMX_IndexConfigTimeActiveRefClock, &refClock);
  assert(err == OMX_ErrorNone);

  OMX_TIME_CONFIG_SCALETYPE scaleType;
  OMX_INIT_STRUCTURE(scaleType);
  scaleType.xScale =  (-1 << 16) / 1000;//0x00010000;
  err = OMX_SetConfig(ilclient_get_handle(clockComponent), OMX_IndexConfigTimeScale, &scaleType);
  assert(err == OMX_ErrorNone);
  
  err = ilclient_create_component(client, &schedulerComponent, "video_scheduler", (ILCLIENT_CREATE_FLAGS_T)ILCLIENT_DISABLE_ALL_PORTS);
  if(err == -1){
    printf("Setup Scheduler component failed\n");
    return (void*)-1;
  }
  
  OMX_VIDEO_PARAM_PORTFORMATTYPE videoPortFormat;
  OMX_INIT_STRUCTURE(videoPortFormat);
  videoPortFormat.nPortIndex = 130;
  err = OMX_GetParameter(ilclient_get_handle(decodeComponent), OMX_IndexParamVideoPortFormat, &videoPortFormat);
  assert(err == OMX_ErrorNone);
  videoPortFormat.nPortIndex = 130;
  videoPortFormat.nIndex = 0;
  videoPortFormat.eCompressionFormat = OMX_VIDEO_CodingAVC;//OMX_VIDEO_CodingAutoDetect;//
  videoPortFormat.eColorFormat = OMX_COLOR_FormatUnused;
  if(arg->fpsScale > 0 && arg->fpsRate > 0)
    videoPortFormat.xFramerate = (long long)/* (1 << 16) */ arg->fpsRate / arg->fpsScale;
  else
    videoPortFormat.xFramerate = 25 * (1 << 16);
  //  videoPortFormat.xFramerate = 0;
  err = OMX_SetParameter(ilclient_get_handle(decodeComponent), OMX_IndexParamVideoPortFormat, &videoPortFormat);
  assert(err == OMX_ErrorNone);

  OMX_PARAM_PORTDEFINITIONTYPE portParam;
  OMX_INIT_STRUCTURE(portParam);
  portParam.nPortIndex = 130;
  err = OMX_GetParameter(ilclient_get_handle(decodeComponent), OMX_IndexParamPortDefinition, &portParam);
  assert(err == OMX_ErrorNone);
  portParam.nPortIndex = 130;
  portParam.format.video.nFrameWidth = arg->widthVideo;
  portParam.format.video.nFrameHeight = arg->heightVideo;
  err = OMX_SetParameter(ilclient_get_handle(decodeComponent), OMX_IndexParamPortDefinition, &portParam);
  assert(err == OMX_ErrorNone);

  /* OMX_CONFIG_BOOLEANTYPE timeStampMode; */
  /* OMX_INIT_STRUCTURE(timeStampMode); */
  /* timeStampMode.bEnabled = OMX_TRUE; */
  /* err = OMX_SetParameter(ilclient_get_handle(decodeComponent), OMX_IndexParamBrcmVideoTimestampFifo, &timeStampMode); */
  /* assert(err == OMX_ErrorNone); */

  OMX_CONFIG_LATENCYTARGETTYPE latence;
  OMX_INIT_STRUCTURE(latence);
  latence.nPortIndex = 221;
  latence.bEnabled = OMX_TRUE;
  latence.nFilter = 10;//2;
  latence.nTarget = 0;//4000;
  latence.nShift = 3;
  latence.nSpeedFactor = 0;//-135;
  latence.nInterFactor = 0;//500;
  latence.nAdjCap = 100;//20;
  err = OMX_SetConfig(ilclient_get_handle(renderComponent), OMX_IndexConfigLatencyTarget, &latence);
  assert(err == OMX_ErrorNone);
  
  err = ilclient_change_component_state(decodeComponent, OMX_StateIdle);
  assert(err == OMX_ErrorNone);
  
  if(ilclient_enable_port_buffers(decodeComponent, 130, NULL, NULL, NULL) == 0){
    ilclient_enable_port(decodeComponent, 130);
    
    OMX_BUFFERHEADERTYPE *omxBuffer;
    
    ilclient_change_component_state(decodeComponent, OMX_StateExecuting);
    setDecoderConfig(decodeComponent, arg->extradataSize, arg->extradata);

    OMX_TIME_CONFIG_CLOCKSTATETYPE cstate;
    OMX_INIT_STRUCTURE(cstate);
    err = OMX_GetConfig(ilclient_get_handle(clockComponent), OMX_IndexConfigTimeClockState, &cstate);
    assert(err == OMX_ErrorNone);
    cstate.eState = OMX_TIME_ClockStateRunning;//OMX_TIME_ClockStateWaitingForStartTime;
    cstate.nWaitMask = 1;
    err = OMX_SetConfig(ilclient_get_handle(clockComponent), OMX_IndexConfigTimeClockState, &cstate);
    assert(err == OMX_ErrorNone);

    set_tunnel(&decodeTunnel, decodeComponent, 131, schedulerComponent, 10);
    if(ilclient_setup_tunnel(&decodeTunnel, 0, 0) != 0){
      printf("Cannot set clockTunnel\n");
      return (void*)-1;
    }

    set_tunnel(&schedulerTunnel, schedulerComponent, 11, renderComponent, 220);
    if(ilclient_setup_tunnel(&schedulerTunnel, 0, 1000) != 0){
      printf("Cannot set clockTunnel\n");
      return (void*)-1;
    }
    
    set_tunnel(&clockTunnel, clockComponent, 80, schedulerComponent, 12);
    if(ilclient_setup_tunnel(&clockTunnel, 0, 0) != 0){
      printf("Cannot set clockTunnel\n");
      return (void*)-1;
    }
    else{
      ilclient_change_component_state(clockComponent, OMX_StateExecuting);
      OMX_SendCommand(ilclient_get_handle(clockComponent), OMX_CommandPortEnable, 80, NULL);
    }

    AVPacket packet;
    while(av_read_frame(arg->context, &packet) >= 0){
      if(packet.stream_index != arg->videoIndex)
  	continue;

      omxBuffer = ilclient_get_input_buffer(decodeComponent, 130, 1);

      if(((packet.size == 0 && ilclient_wait_for_event(decodeComponent, OMX_EventPortSettingsChanged, 131, 0, 0, 1, ILCLIENT_EVENT_ERROR | ILCLIENT_PARAMETER_CHANGED, /*1000*/0) == 0)
	  || (packet.size > 0 && ilclient_remove_event(decodeComponent, OMX_EventPortSettingsChanged, 131, 0, 0, 10000) == 0))){
	
	if(ilclient_setup_tunnel(&decodeTunnel, 0, 0) != 0){
	  printf("setup decodetunnel failed\n");
	  break;
	}

	ilclient_change_component_state(schedulerComponent, OMX_StateExecuting);

	if(ilclient_setup_tunnel(&schedulerTunnel, 0, 1000) != 0){
	  printf("setup schedulertunnel failed \n");
	  break;
	}

	ilclient_change_component_state(renderComponent, OMX_StateIdle);

	if (OMX_SendCommand(ilclient_get_handle(renderComponent), OMX_CommandPortEnable, 221, NULL) != OMX_ErrorNone){
	  printf("OMX_CommandPortEnable failed.\n");
	  exit(1);
	}

	if (OMX_UseEGLImage(ilclient_get_handle(renderComponent), &eglBuffer, 221, NULL, eglImage) != OMX_ErrorNone){
	  printf("OMX_UseEGLImage failed.\n");
	  exit(1);
	}

	ilclient_change_component_state(renderComponent, OMX_StateExecuting);

	if(OMX_FillThisBuffer(ilclient_get_handle(renderComponent), eglBuffer) != OMX_ErrorNone){
	  printf("OMX_FillThisBuffer failed.\n");
	  exit(1);
	}
      }

      unsigned int size = packet.size;
      uint8_t* content = packet.data;
  
      while(size > 0){
	omxBuffer->nFilledLen = (size > omxBuffer->nAllocLen-1) ? omxBuffer->nAllocLen-1 : size;

	memset(omxBuffer->pBuffer, 0x0, omxBuffer->nAllocLen);
	memcpy(omxBuffer->pBuffer, content, omxBuffer->nFilledLen);

	size -= omxBuffer->nFilledLen;
	content += omxBuffer->nFilledLen;
      }
      omxBuffer->nFlags = 0;

      if(size <= 0)
	omxBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;

      if(packet.dts == 0)
	omxBuffer->nFlags |= OMX_BUFFERFLAG_STARTTIME;
      else
	omxBuffer->nTimeStamp = ToOMXTime( (uint64_t)(packet.pts * 1000000 / arg->timeBase));

      err = OMX_EmptyThisBuffer(ilclient_get_handle(decodeComponent), omxBuffer);  
      if(err != OMX_ErrorNone){
	printf("Empty buffer failed\n");
	return (void*)-1;
      }
      if(size > 0)
	omxBuffer = ilclient_get_input_buffer(decodeComponent, 130, 1);
    }
  }
  return (void*)1;

thanks for your help.


Kind regard

Vipe
Posts: 4
Joined: Thu Aug 24, 2017 1:09 pm

Re: Hello_videocube play 720p

Sat Aug 26, 2017 2:38 pm

Nobody knows? Please at least tell me how to remove the parasites on the videos. I still can not found how to fix it.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4544
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hello_videocube play 720p

Sat Aug 26, 2017 4:12 pm

Vipe wrote:
Sat Aug 26, 2017 2:38 pm
Nobody knows?
You haven't given much to go on.
Do the videos play with omxplayer? The codec parameters look OK, but it's hard to say for definite.
Vipe wrote:
Sat Aug 26, 2017 2:38 pm
Please at least tell me how to remove the parasites on the videos. I still can not found how to fix it.
Parasites?!
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Vipe
Posts: 4
Joined: Thu Aug 24, 2017 1:09 pm

Re: Hello_videocube play 720p

Sun Aug 27, 2017 11:37 am

I am sorry if I wasn't very explicit. The videos works very well with omxplayer but see the image for know what happen with my program (that is the parasite, I don't know the real name sorry ) . And this for all videos. Like I said, if I use a 720p's video downloaded from Youtube it works but with this videos it doesn't.
Also, I don't know if it's related, but, on one of these videos, if the xScale from OMX_TIME_CONFIG_SCALETYPE is set to (-1 << 16) the video play normally but on on another it plays very very fast ....

Image


Kind regards

Vipe
Posts: 4
Joined: Thu Aug 24, 2017 1:09 pm

Re: Hello_videocube play 720p

Tue Aug 29, 2017 7:30 pm

Please ?

Return to “OpenMAX”

Who is online

Users browsing this forum: No registered users and 1 guest