On 19/03/13 01:54, Eric Urban wrote: > I have reverse engineered what appears to be a proprietary protocol used by > many Chinese designed and manufactured security DVRs. I'm able to extract > h.264 frames from a TCP Data Stream. Initially I was able just writing all > the frames one after another to a file and using avconv to convert to > another video format. The video looks fine, so I am assuming I am doing it > correctly.
Great, would be possible integrate it as an avdevice or a protocol? > Since then I've gotten to the point where I can use libav to decode the > packets. This of course results in an AVFrame. Right now I am trying to > figure out a way to write out the most current frame to a still image. My > current understanding of libav is that the pixel format is depending on the > source data, in this case h.264. Either way, it appears it is accessible > from decoding context struct AVCodecContext::pix_fmt. Yes > Apparently if I just wanted to re-encode this in a better supported > streaming format it would be easy. But to make these security cameras work > with open source software like motion I really need to be able to produce > stills. My logic is that if I can convert the pixels into something like > RGBA, I can from there easily write to whatever format I want like ppm, > jpeg, etc. Apparently this is done with the function sws_scale. The context > is easy enough to create with sws_getContext. But I really have no idea > what the parameters to sws_scale should be. you could have a look at output-example.c > What are slices? What are strides? slices: vertical section of the image at hand, number of rows. strides: linesizes, how many bytes to read before you get to the next row. > Can someone give me an explanation of how sws_scale works? I've found bits > and pieces of information scattered across the internet but nothing really > concrete. Also, I could not figure out how to search this list. Is that > possible? swscale is relatively simple and ugly. you get a context telling which kind of scaler you want and on which kind of picture geometry will work on (from wxh to w1xh1) then you feed the scaler with rows of that image, you can feed the whole picture or just group of rows. a row is described by its stride (or linesize), since for performance reason your picture dimension and the actual size of a line (or row) can be different. I hope it helps. lu _______________________________________________ libav-api mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-api
