oneam / h264bsd

A simple h264 software decoding library
Other
196 stars 52 forks source link

Question... #11

Closed e1ioan closed 6 years ago

e1ioan commented 6 years ago

I have a question, not an issue, how do I save a frame to bmp or jpeg file?

Regards!

oneam commented 6 years ago

You ca't save a frame to bmp or jpeg with this library alone. I find the easiest way to extract a single frame of video is to use ffmpeg:

ffmpeg -i test_640x360.h264 -vframes 1 thumb.jpg

https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video

e1ioan commented 6 years ago

ffmpeg won't work for me... I need to to do it from scratch, I wanted to port your code to brightscript (roku's made up programming language), but I wanted to understand first how to use it.

One more question, h264bsdNextOutputPictureRGBA(..) returns a byte array of size W x H x 4? 4 byte value for each pixel (R G B and A)?

Thanks

oneam commented 6 years ago

There are 4 useful methods for accessing the decoded images: h264bsdNextOutputPicture(..) outputs in the original i420 format (https://www.fourcc.org/pixel-format/yuv-i420/) h264bsdNextOutputPictureYCbCrA(..) outputs the image in 32 bits per pixel YCbCr

h264bsdNextOutputPictureRGBA(..) output 32 bits per pixel RGBA (The same format used by OpenGL) h264bsdNextOutputPictureBGRA(..) outputs 32 bits per pixel BGRA (The same format used by Windows bitmaps)

Keep in mind that the YCbCr -> RGB conversion is not particularly fast in C. I generally use some other method to perform the conversion. The Javascript implementation for example uses a pixel shader in WebGL to do the conversion (as does the iOS example).