Conversation
Agent-Logs-Url: https://github.com/fourMs/MGT-python/sessions/804afced-8cfa-4b53-b671-348fedf3ab55 Co-authored-by: alexarje <114316+alexarje@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fourMs/MGT-python/sessions/804afced-8cfa-4b53-b671-348fedf3ab55 Co-authored-by: alexarje <114316+alexarje@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add functionality to read/write original files as arrays
Add numpy read/write for MgVideo/MgAudio and memory-based grid processing
Apr 15, 2026
alexarje
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the ability to read/write
MgVideoandMgAudioobjects as numpy arrays, initializeMgVideofrom an array, and return grid images as arrays instead of writing to disk.Changes
Bug fix:
from_numpypath handlingWhen constructing
MgVideo(filename=..., array=..., fps=..., path=...), the file was correctly written topath/filenamebutself.filenamewas left as the bare filename, causing an immediateFileNotFoundErroringet_video(). Fixed by updatingself.filename,self.of, andself.fexto the actual write path after FFmpeg completes.Features (previously implemented, now tested and documented)
MgVideo.numpy()– returns(array, fps)wherearrayhas shape(N, H, W, 3), BGR uint8MgAudio.numpy()– returns the audio waveform as a 1-D float arrayMgVideo(filename, array=array, fps=fps, path=path)– initializes from a numpy array, writing the encoded video to diskMgVideo.from_numpy(array, fps, target_name=None)– writes an array directly to a specified output pathmg_grid(return_array=True)– returns the grid image as a numpy array without writing to diskUsage
Tests
Added
tests/test_numpy.pywith 18 cases covering all of the above, including thepath-parameter regression.