Skip to content

Automatic MP4 muxing without external tools#441

Open
5p4k wants to merge 3 commits intowaveform80:masterfrom
5p4k:mp4
Open

Automatic MP4 muxing without external tools#441
5p4k wants to merge 3 commits intowaveform80:masterfrom
5p4k:mp4

Conversation

@5p4k
Copy link

@5p4k 5p4k commented Sep 12, 2017

Hello! This is a minimal implementation of a MP4 muxer directly in python, so we do not need a second pass through ffmpeg or avconv. This introduces a dependency from pymp4 and, through that, from construct.

To use it, just record to a .mp4 file or use format='mp4'. I tested this in several ways in on a Raspberry Pi 2 model B (this started actually as a separate project), and so far I had no issue.

What is missing:

  • Documentation
  • Testcases
  • Possibly specifying multiple chunks in the stsc atom

Regarding the last item, I think that, formally, every time a different SPS header is issued together with a keyframe, we should specify a new chunk in there. Also, although it seems that the SPS/PPS parameters are usually always the same, perhaps we should allocate a different sample descriptor for those chunks. Nevertheless, the current one-chunk approach was playable on all platforms and all players I could get my hands on.

@5p4k 5p4k closed this Jan 18, 2018
@5p4k 5p4k deleted the mp4 branch January 18, 2018 21:49
@5p4k 5p4k restored the mp4 branch January 18, 2018 21:49
@5p4k 5p4k reopened this Aug 1, 2018
@waveform80
Copy link
Owner

Fascinating! Many thanks for the PR - proper MP4 muxing has been something I've been dying to research for picamera for ages but it's always been too big a job to start on top of everything else. Unfortunately, the external dependency this adds (pymp4) complicates things as it's not debian/raspbian packaged which means this'd break the primary means by which picamera is distributed (i.e. as a .deb package in raspbian). However, this is sufficiently interesting that it might be worth adding as an optional dependency for pip-based installs. I'll have a deeper dig into the PR for 1.14; I can't promise I'll include it yet, but it's definitely very interesting.

Many thanks for the PR, and sorry it's taken so long to get around to looking at it!

@waveform80 waveform80 self-assigned this Sep 29, 2018
@waveform80 waveform80 added this to the 1.14 milestone Sep 29, 2018
@5p4k
Copy link
Author

5p4k commented Sep 30, 2018

Sounds good! Let me know if there is something that I can contribute with for this merge. In the past year I’ve been using this extensively with no issues.

Having it as a pip optional dep would be nice; re-implementing all those atoms required by MP4 is quite some effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants