[libav-api] few questions about using libav's api

steve at chinavfx.net steve at chinavfx.net
Mon May 6 18:52:31 CEST 2013


 

Hi there, 

 I'm totally new to libav, but I want to use it with my
engine to work with some projects. But I have few problems now. 

 1.
how is libswscale's stride direction decided? I've check the source, but
I can not fully understand this. for example, under windows, every
captured image from a webcam are upside-down, and which of course will
have a negative stride, but in order to use this image, I have to
convert and flip the image, so with negative stride, and start address
of a captured image(actually bottom line of pixels), libswscale will
crash, (of course it will crash), so I have to manually calculate the
real first row's address based on the stride and pass that to sws_scale.
after this I'll get correct image. So, is this designed to be or this
can be improved by sws_scale to calculate the real first row of src/dest
image? 

 2. I need to convert images captured from a webcam, as you
know, webcams support many image formats, like rgb, yuy2, these formats
are common, but how about MJPG, I420, NV12, YV12? how to convert these
formats to RGB formats? can I use swscale to convert MJPG, I420, NV12,
YV12 to rgb? If swscale can convert, how should I mapping these formats
to AVPixelFormat enum? 

 3. I also need libavresample to convert
32bit/float audio to 16-bit signed audio, but my engine need audio to be
filled into some buffer, and buffer size are calculated for each file
about to 0.5 seconds. then here comes a problem, in libav, each frame of
audio might contain different audio samples, so how can I estimate the
number of sample on next frame without actually read next packet/frame,
or is there any way to estimate the biggest number of samples per frame
in a audio file? 

 Thanks for helping me with these problems. 

Best
regards, 

Steve Yin 

 


More information about the libav-api mailing list