asticode / go-astiav

Golang ffmpeg and libav C bindings
MIT License
393 stars 45 forks source link

implemented Frame.DataBytes() to receive raw image data #5

Closed chmgr closed 2 years ago

chmgr commented 2 years ago

implemented as discussed here #4

chmgr commented 2 years ago

I implemented SetDataBytes() as the reverse function to DataBytes(). I also added a test verifying that DataBytes() returns the same data as set via SetDataBytes(). It might be better to check against Data() when #4 is fixed.

asticode commented 2 years ago

I also had the need to inject raw video inside an encoding workflow and after trying out several solutions, I ended up using this method (which frees the malloced data once data is not referenced anymore) and then providing the packets to a decoder using codec id rawvideo: it manages memory properly and all internal logic such as padding is handled by the decoder. In all honesty, based on the available libav API, I even have the feeling that libav developers wanted people to do it that way 🤔

Anyway, thanks for taking the time to write this PR, I'll close it now, but feel free to comment it 👍