mbebenita / Broadway

A JavaScript H.264 decoder.
Other
2.73k stars 427 forks source link

How to get actual size of frame after decoded #152

Open chjcken opened 7 years ago

chjcken commented 7 years ago

Hi @soliton4

As I know, H264 compression algorithms require all video widths and heights to be multiples of 16. So that if I have a 360x640 image, it has to be placed in a larger frame (368x640) for compression (see attachment)

I use broadway decoder to decode the frame (in attachment), width and height that I get from "onPictureDecoded" are 368x640

My question is how can I get actual frame size? I found that I should look in sps/pps data for cropping information but I can't find them in broadway decoder.

h264frame.zip

soliton4 commented 7 years ago

that is actually a good question. i thought the value was provided already but it turns out i allways know the size of my video stream. i should propagate the true width in the onpicdecoded function.

the height is allways the true height

OllieJones commented 6 years ago

Both mp4 and webm carry the actual video source dimensions in their preambles.

soliton4 commented 6 years ago

@OllieJones thanks for trying to help. the data in the source stream is not a mystery to us. we just would need to change the decoder to carry that data up until the output function is called. would you care to implement that change?