Recent

Author Topic: Draw frame from FFMpeg  (Read 4168 times)

RedCat

  • New Member
  • *
  • Posts: 28
Draw frame from FFMpeg
« on: April 19, 2020, 01:56:22 pm »
Kind time of the day, the question of drawing using OpenGL means a frame received from the ffmpeg decoder (continuation of this topic:https://forum.lazarus.freepascal.org/index.php/topic,49196.msg356348.html#msg356348) I listened to the tips that were given to me and tried to manually copy the bytes, it seemed to work better than with direct rendering of data from the decoder, but still it is not drawn as it should and I used pixel-by-pixel copying, which is very slow
here is the code:
Code: Pascal  [Select][+][-]
  1. procedure SwapTB(dataIN,dataOUT : Pointer;SizeX,SizeY : Integer);
  2. var
  3.   x,y:GLint;
  4.   temp1,temp2,temp3: GLbyte;
  5. begin
  6. for y := 0 to (SizeY*SizeX)-2 do
  7.    begin
  8.      With TWrap(DataIN^)[SizeY*SizeX-y*4] do
  9.      begin
  10.        TWrap(DataOUT^)[y].R:=R+y*SizeX*4;
  11.        TWrap(DataOUT^)[y].G:=G+y*SizeX*4;
  12.        TWrap(DataOUT^)[y].B:=B+y*SizeX*4;
  13.      end;
  14.    end;
  15.  end;
  16.  
  17. //........
  18. sws_scale(img_convert_context,@frame^.data,@frame^.linesize,0,codec_context^.height,@pFrameYUV420P^.data,@pFrameYUV420P^.linesize);
  19.  SwapTB(pFrameYUV420P^.data[0],pData,codec_context^.width,codec_context^.height);
  20.  //.......
  21. gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Width, Height, GL_RGB, GL_UNSIGNED_BYTE, pData);
  22. //.......
  23.  
  please tell me the normal way to draw frames from ffmpeg (avcodec) to opengl texture
the rendering result is also attached
rendermustbe - original frame
renderresult -  direct rendering of data from a decoder
renderresultnew -  rendering by copying pixels

 

TinyPortal © 2005-2018