Comments (9)
Hi
It's not apparent from the image how it should look like normally. But as soon as vertical lines don't get inclined I suppose there's a constant shift in bitmap data. Probably, a wrong start of bitmap data is specified.
What is the source of frames? How do you pass frames to SharpAvi? Which encoder do you use?
from sharpavi.
Hi,
Thanks for responding. The bitmaps are captured from the screen with the following code:
To test, I added some debug code to save the bitmap. When I opened it in Paint.Net, it looked correct.
You can see the video here: https://youtu.be/eAzu7xScquA?t=83
From about 1:20 there is a stream of water that should be at the very right hand edge of the frame, but as you can see, it is wrapped around to the left.
Thanks,
Steve.
from sharpavi.
I see. You should not save a bitmap to the BMP format before passing to SharpAvi. This way the array you pass to WriteFrame
contains not only raw pixel data but also a few excess bytes in the beginning coming from the BMP header. Hence the shift in pixels.
Take a look to a similar code in the sample app.
Line 228 in 02b1447
You just call
LockBits' to get a pointer to a
Bitmap's pixel data. And then you can either copy it to an array, a
MemoryStreamor other managed memory. Or use unsafe code and create a
Spandirectly from the pointer which you can then pass to
WriteFrame`.
var bits = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
var span = new Span<byte>(bits.Scan0.ToPointer(), bits.Stride * bits.Height);
videoStream.WriteFrame(true, span);
bitmap.UnlockBits(bits);
from sharpavi.
Hi,
That seems to have fixed the alignment issue. However the AVI is now upside-down.
Thanks,
Steve.
from sharpavi.
You use an uncompressed video stream without an encoder, it expects pixel data in the bottom-up direction. It worked with the BMP format because it also stores pixels in the bottom-up direction. While the Bitmap
class stores its data in the top-down direction.
You can turn to UncompressedVideoEncoder
which expects top-down data and performs the necessary vertical flipping under the hood. Note that you'll also need to change the bitmap format to PixelFormat.Format32bppRgb
as all encoders in SharpAvi expect pixel data in this format.
from sharpavi.
Perfect, that all works now.
Thank-you for your help with this issue. I presume my original issue was caused by header information that is added when saving a bitmap?
Thanks,
Steve.
from sharpavi.
I presume my original issue was caused by header information that is added when saving a bitmap?
Correct
from sharpavi.
Cool.
Once again, thanks for your help with this!
Steve.
from sharpavi.
Appreciate your help, gave you a shout out here: https://www.outsidecontextproblem.com/threading.html
Cheers,
Steve.
from sharpavi.
Related Issues (20)
- Fody Merge Lib. Trouble.
- AviWrite Close Function Trouble ( Fx35 Version ) HOT 2
- x264vfw Record Error.. HOT 2
- Screen recording as video, audio on SharpAvi - Audio not recording HOT 4
- .NET Core target HOT 1
- This Library not available in .NET Core HOT 1
- x264 popup appears HOT 1
- Continuous recording, writing out to multiple files HOT 1
- Thumbnail Time Trouble..
- How to record audio microphone and speaker HOT 1
- how to close the video at the end of the process HOT 1
- Different resolutions crop in video
- Issue with example HOT 1
- Please turn MAX_SUPER_INDEX_ENTRIES into an optional parameter HOT 3
- Mpeg4VideoEncoderVcm.GetAvailableCodecs returns an empty array HOT 3
- AviWriter does not close file HOT 3
- Trouble with x264vfw HOT 2
- Errors in Mpeg4VcmVideoEncoder Issues HOT 5
- OverflowException in AviWriter.WriteFileHeader HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharpavi.