Hello, I'm using libswscale to scale and convert pixel format from frames that I capture from the screen. In my windows build the frames that I capture are in DIB format. I'm using FFMPEG SVN rev 16437. Calling sws_scale normally I get the image correctly, except that it's vertically flipped. If I change the srcSliceY from 0 to srcHeight and srcSliceH from srcHeight to 0, I get a grey image (with correct dimensions). If I keep the srcSliceY in 0 and change srcSliceH from srcHeight to -srcHeight, I also get that grey image. Is there a way to make sws_scale flip the image for me ?
On date Thursday 2009-01-08 17:08:26 -0200, R?mulo Fernandes encoded:
Hello,
I'm using libswscale to scale and convert pixel format from frames that I capture from the screen. In my windows build the frames that I capture are in DIB format. I'm using FFMPEG SVN rev 16437.
DIB format? Can you explain what is it?
Calling sws_scale normally I get the image correctly, except that it's vertically flipped.
If I change the srcSliceY from 0 to srcHeight and srcSliceH from srcHeight to 0, I get a grey image (with correct dimensions). If I keep the srcSliceY in 0 and change srcSliceH from srcHeight to -srcHeight, I also get that grey image.
Is there a way to make sws_scale flip the image for me ?
No, you need to use a filter for that. Check out the code of libavfilter in the SOC repo. Regards. -- ffmpeg-user random tip #3 Some few multimedia formats (mpeg-1, mpeg-2:PS, DV) support physical merge consistency, which means you can merge two files with cat. E.g.: cat input1.mpeg input2.mpeg > output.mpeg See: http://ffmpeg.mplayerhq.hu/faq.html#SEC25
On Thu, Jan 8, 2009 at 3:51 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
On date Thursday 2009-01-08 17:08:26 -0200, R?mulo Fernandes encoded:
Hello,
I'm using libswscale to scale and convert pixel format from frames that I capture from the screen. In my windows build the frames that I capture are in DIB format. I'm using FFMPEG SVN rev 16437.
DIB format? Can you explain what is it?
http://en.wikipedia.org/wiki/Device-independent_bitmap Dark Shikari
The DIB that I have is basically an BGR array (1 byte per component) with 32-bit alignment per line. And the lines are in reverse order (last line first). It's something like this: | Line N | Line N-1 |... |B|G|R|B|G|R|...|B|G|R|Padding|B|G|R|B|G|R|...|B|G|R|Padding|... The problem is not with the DIB structure, because it works without flipping. The only problem is that I'm being able make sws_scale flip it for me, if it's really possible. On Thu, Jan 8, 2009 at 8:27 PM, Jason Garrett-Glaser <darkshikari at gmail.com>wrote:
On Thu, Jan 8, 2009 at 3:51 PM, Stefano Sabatini <stefano.sabatini-lala at poste.it> wrote:
On date Thursday 2009-01-08 17:08:26 -0200, R?mulo Fernandes encoded:
Hello,
I'm using libswscale to scale and convert pixel format from frames that I capture from the screen. In my windows build the frames that I capture are in DIB format. I'm using FFMPEG SVN rev 16437.
DIB format? Can you explain what is it?
http://en.wikipedia.org/wiki/Device-independent_bitmap
Dark Shikari _______________________________________________ ffmpeg-user mailing list ffmpeg-user at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Top-posting is frowned upon here. On date Thursday 2009-01-08 20:39:08 -0200, R?mulo Fernandes encoded:
The DIB that I have is basically an BGR array (1 byte per component) with 32-bit alignment per line. And the lines are in reverse order (last line first).
It's something like this:
| Line N | Line N-1 |... |B|G|R|B|G|R|...|B|G|R|Padding|B|G|R|B|G|R|...|B|G|R|Padding|...
The problem is not with the DIB structure, because it works without flipping. The only problem is that I'm being able make sws_scale flip it for me, if it's really possible.
I don't think sws_scale() support vertical flipping, furthermore I don't think libav* supports that kind of video frame, check libavutil/avutil.h for the definition of all the formats supported. And I still don't know how do you set the sws context, that is which source pixel format do you set. But you should be able to easily convert those frames to your favourite pixel format (supported by ffmpeg) with some routine, then use sws_scale() to convert/scale. Or even better you could add support to that format into FFmpeg itself. [...] Regards. -- ffmpeg-user random tip #7 If you're asking about problems with an ffmpeg tool, *always* post the command you're using and the complete output.
Hi, Romulo Fernandes said:
Hello,
I'm using libswscale to scale and convert pixel format from frames that I capture from the screen. In my windows build the frames that I capture are in DIB format. I'm using FFMPEG SVN rev 16437.
Calling sws_scale normally I get the image correctly, except that it's vertically flipped.
If I change the srcSliceY from 0 to srcHeight and srcSliceH from srcHeight to 0, I get a grey image (with correct dimensions). If I keep the srcSliceY in 0 and change srcSliceH from srcHeight to -srcHeight, I also get that grey image.
Is there a way to make sws_scale flip the image for me ?
I faintly recall that using a negative value for some vertical parameter flips it. Don't remember more, you'll need to search the mail archives or run some experiments. Regards, V?ctor
On Friday 09 January 2009 10:30, V?ctor Paesa wrote:
Romulo Fernandes said:
I'm using libswscale to scale and convert pixel format from frames that I capture from the screen. In my windows build the frames that I capture are in DIB format. I'm using FFMPEG SVN rev 16437.
Calling sws_scale normally I get the image correctly, except that it's vertically flipped.
If I change the srcSliceY from 0 to srcHeight and srcSliceH from srcHeight to 0, I get a grey image (with correct dimensions). If I keep the srcSliceY in 0 and change srcSliceH from srcHeight to -srcHeight, I also get that grey image.
Is there a way to make sws_scale flip the image for me ?
I faintly recall that using a negative value for some vertical parameter flips it. Don't remember more, you'll need to search the mail archives or run some experiments.
I am not sure on the details either anymore (has been a while since I last worked on swscale), but I think you can use a negative stride for either the source or the destination image. In that case, you also need to point to the last scanline, instead of the first. --Ivo
There is a commentary in the source code of sws_scale, saying about flipping. I read the code it a little, and I thought that swapping the srcSliceY with srcSliceH should do the trick, but instead I got a gray image. On Fri, Jan 9, 2009 at 9:49 AM, Ivo <ivop at euronet.nl> wrote:
On Friday 09 January 2009 10:30, V?ctor Paesa wrote:
Romulo Fernandes said:
I'm using libswscale to scale and convert pixel format from frames that I capture from the screen. In my windows build the frames that I capture are in DIB format. I'm using FFMPEG SVN rev 16437.
Calling sws_scale normally I get the image correctly, except that it's vertically flipped.
If I change the srcSliceY from 0 to srcHeight and srcSliceH from srcHeight to 0, I get a grey image (with correct dimensions). If I keep the srcSliceY in 0 and change srcSliceH from srcHeight to -srcHeight, I also get that grey image.
Is there a way to make sws_scale flip the image for me ?
I faintly recall that using a negative value for some vertical parameter flips it. Don't remember more, you'll need to search the mail archives or run some experiments.
I am not sure on the details either anymore (has been a while since I last worked on swscale), but I think you can use a negative stride for either the source or the destination image. In that case, you also need to point to the last scanline, instead of the first.
--Ivo _______________________________________________ ffmpeg-user mailing list ffmpeg-user at mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
A filter would work, but if you're doing a conversion/scaling anyway with sw_scale(), theoretically it's faster to flip at the same time. I saw this posted somewhere else... int nDivisor, nMaxLineSize = 0; // find max linesize for (int i = 0; i < 4; i++) { if (pic->linesize[i] > nMaxLineSize) { nMaxLineSize = pic->linesize[i]; } } if (pic->linesize[0]) { nDivisor = (nMaxLineSize / pic->linesize[0]); if (!nDivisor) { nDivisor = 1; } pic->data[0] += (pic->linesize[0] * ((nHeight/nDivisor) - 1)); } if (pic->linesize[1]) { nDivisor = (nMaxLineSize / pic->linesize[1]); if (!nDivisor) { nDivisor = 1; } pic->data[1] += (pic->linesize[1] * ((nHeight/nDivisor) - 1)); } if (pic->linesize[2]) { nDivisor = (nMaxLineSize / pic->linesize[2]); if (!nDivisor) { nDivisor = 1; } pic->data[2] += (pic->linesize[2] * ((nHeight/nDivisor) - 1)); } if (pic->linesize[3]) { nDivisor = (nMaxLineSize / pic->linesize[3]); if (!nDivisor) { nDivisor = 1; } pic->data[3] += (pic->linesize[3] * ((nHeight/nDivisor) - 1)); } pic->linesize[0] *= -1; pic->linesize[1] *= -1; pic->linesize[2] *= -1; pic->linesize[3] *= -1; -- View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Flip-in-sws-scale-tp939665p3516095.... Sent from the FFmpeg-users mailing list archive at Nabble.com.
hi, i encounter this problem too. i use this can solve the problem. You need to reset src and linesize of source image, in my case is use sws_scale from rgb24, 640x480 -> YUV420 176x144 the code goes: if (option & VIDEO_FLIP) { src[0] += linesize[0]*(height-1); linesize[0] = -linesize[0]; } sws_scale(ctx, src, linesize, 0, height, dst, dst_linesize); Maybe some help for you. -- View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Flip-in-sws-scale-tp939665p3543657.... Sent from the FFmpeg-users mailing list archive at Nabble.com.
void FlipFrame(AVFrame* pFrame) { for (int i = 0; i < 4; i++) { pFrame->data[i] += pFrame->linesize[i] * (pFrame->height-1); pFrame->linesize[i] = -pFrame->linesize[i]; } } void UnflipFrame(AVFrame* pFrame) { for (int i = 0; i < 4; i++) { pFrame->linesize[i] = -pFrame->linesize[i]; pFrame->data[i] -= pFrame->linesize[i] * (pFrame->height-1); } } -- View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Flip-in-sws-scale-tp939665p4385701.... Sent from the FFmpeg-users mailing list archive at Nabble.com.
If the planes in the image are unequal size (e.g. YUV420) you need to adapt the height. There may be better ways to do it, but this works for me: void FlipFrameJ420(AVFrame* pFrame) { for (int i = 0; i < 4; i++) { if (i) { pFrame->data[i] += pFrame->linesize[i] * ((pFrame->height >> 1)-1); } else { pFrame->data[i] += pFrame->linesize[i] * (pFrame->height-1); } pFrame->linesize[i] = -pFrame->linesize[i]; } } -- View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Flip-in-sws-scale-tp939665p4675092.... Sent from the FFmpeg-users mailing list archive at Nabble.com.
participants (8)
-
darkshikari@gmail.com -
erikjn -
ivop@euronet.nl -
Ph0t0n -
romulo.fernandes@gmail.com -
stefano.sabatini-lala@poste.it -
wzrlpy@arsystel.com -
xiel88