Extracating raw values of slices (I/P/B Slices) #1909
-
Hi! Is it possible to extract values of slices (not values/pixels of the video stream itself) using this library? For example, I can see that there's a I've tried using Perhaps I misunderstood how these methods should be used (it looks like I can input per-channel pixel values with For some context, I'm designing a steganography algorithm that will embed data to (alter value of) I/P/B slices (blocks) of compressed H.264 video. I guess I can implement parsing on my own, of course, but if there's a ready-made solution for decoding/encoding video files, I'd like to use that instead. Thanks, and sorry for my ramble. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I can explain the image format. Your original video is likely in yuv420p, where the memory layout typically places the complete Y plane first, followed by the U and V planes. Therefore, the array height becomes 1080 (Y) + 540 (U/V) = 1620, while the width remains the same as the Y plane's width, 1920. If you want to obtain RGB or BGR, you can directly specify the frame's format, such as Regarding fetching I/P/B frames, it seems PyAV cannot specify decoding. If the goal is modification rather than precise retrieval, maybe consider decoding and then re-encoding? |
Beta Was this translation helpful? Give feedback.
I can explain the image format. Your original video is likely in yuv420p, where the memory layout typically places the complete Y plane first, followed by the U and V planes. Therefore, the array height becomes 1080 (Y) + 540 (U/V) = 1620, while the width remains the same as the Y plane's width, 1920.
If you want to obtain RGB or BGR, you can directly specify the frame's format, such as
frame.to_ndarray(format='rgb24')
.Regarding fetching I/P/B frames, it seems PyAV cannot specify decoding. If the goal is modification rather than precise retrieval, maybe consider decoding and then re-encoding?