Video media track + video encoding

25 views
Skip to first unread message

Attila Sukosd

unread,
May 15, 2016, 12:32:34 PM5/15/16
to Native-Client-Discuss
Hi there,

I've been playing around with taking a video media track and passing that into the hardware accelerated video encoder. I've managed to get a version working
where I do the following:

1. Get a ready frame from the media track (VideoTrack->GetFrame())
2. Get an empty frame from the video encoder (VideoEncoder->GetVideoFrame())
3. memcpy from the ready frame into the video encoder
4. Encode (VideoEncoder->Encode())
5. Get the bitstream

and it seems to work fine. Btw, this is what the video_encode example does too.

As I've read in the documentation it should be possible to pass the PP_VideoFrame given by the Media Track directly to the video encoder,
so in that way I would get rid of that extra pesky memcpy, which takes a lot of time at 1080p@30.
Quote from the docs:
"
 * - Call GetVideoFrame() to get a blank frame and fill it in, or get a video
 *   frame from another resource, e.g. <code>PPB_MediaStreamVideoTrack</code>.
 * - Call Encode() to push the video frame to the encoder. If an external frame
 *   is pushed, wait for completion to recycle the frame.
"


As far as I understand this, I should be able to call VideoTrack->GetFrame() which should give me a VideoFrame resource,
which then I can feed directly? into VideoEncode->Encode()
However when I try that, the encoder's Encode() function tells me that the VideoFrame is an invalid resource  (PP_ERROR_BAD_RESOURCE)

Am I missing something?
Thanks a lot!

Attila

Reply all
Reply to author
Forward
0 new messages