grabbing a frame from a video track with android native sdk

971 views
Skip to first unread message

Eric Davies

unread,
Apr 13, 2017, 8:10:25 PM4/13/17
to discuss-webrtc
Is there some example code of capturing a frame in a bitmap format of some sort from a video track? I've been trying to cobble together something from the VideoFileRenderer class, but not knowing much about opengl ES means I'm just juggling symbols around. In the javascript client world, you would just attach a media stream to a hidden video object and render the video object into a canvas. In the android world, it seems you need to draw textureId into an offscreen buffer. 

Eric Davies

unread,
Apr 17, 2017, 5:56:56 PM4/17/17
to discuss-webrtc
Got it working with only minor hair loss.

Shishram Karwal

unread,
Jun 27, 2017, 1:27:18 AM6/27/17
to discuss-webrtc
Can you post some code or where what u did to get the frame. and can we convert those frames into jpg or bitmap?

Eric Davies

unread,
Jun 27, 2017, 1:33:43 PM6/27/17
to discuss-webrtc

My employer, Priologic Software, was kind enough to let me release the code for this functionality.
You can find it at https://gist.github.com/EricDavies/860c9a73d53649f7399e2a4a02fcb9da
It was cobbled together from other peoples code where-ever I could find it. 
It comes with no guarantees of any sort, but I will try to answer any questions that I can.

Note: it is much easier to grab a frame from Objc because that api provides a method to get an i420 frame that actually has yuv fields you can directly access.

Eric.
Reply all
Reply to author
Forward
0 new messages