Skip to content

Conversation

@papr
Copy link
Contributor

@papr papr commented Sep 10, 2019

Pupil Invisible support

Open Pupil Invisible Companion recordings in Pupil Player.

Variable-framerate video support

Instead of writing a fixed timing into the the video files, Pupil Capture and Pupil Invisible Companion keep the original timing of the video frames. This allows correct playback of intermediate recordings, i.e. videos that have not been exported by Pupil Player.

Pupil Player Format 2.0

A new and clean recording format for Pupil Capture/Player. Consistent recording updates and logic for backwards/forwards compatibility.

papr and others added 30 commits June 9, 2019 23:55
Fix bad class logic:
- BrokenStream should inherit from Decoder
- Decoder method signatures did not match

Fix bad naming:
- Decoder.next_frame returns a frame iterator
- File_Source.next_frame holds a frame iterator
Before the timestamps in the video objects were still uncleaned and thus could not be matched appropriately.
File_Source.shape was only used for generating FakeFrames and was filled by unnecessarily iterating over the first frames of the video.
Replaced with File_Source.frame_size, which reads the format directly from the decoder interface.
Timeline will convert lines to float32, but with PI we have unix epoch timestamps.
While they are in range of float32, the precision suffers greatly and will be in the order of days!
Thus by subtracting t0, we can shift the timestamps to a more reasonable range and thus increase float32 precision.

NOTE: Currently this will have no effect because of a bug with PI recordings from the Android side!
Removed the old way of calculating the pts from frame index and instead always calculate pts from timestamp.
When exporting with AV_Writer it is much easier to have variable pts if the Frames coming from the file-backend already have that information.
Luckily we know the pts of the frames when getting them, so I just attached that.
Needed to adjust FakeFrames as well and did a little bit of cleanup.
I kept the old classes and put an underscore _ in front of them in order to keep the git diff cleaner.
Otherwise git would try to match all kind of hunks and produce complete chaos.

Summary of changes:

1. Instead of two separate but overlapping classes (AV_Writer and JPEG_Writer) we now have an abstract base class AV_Writer and two specializations, MPEG_Writer and JPEG_Writer.
This makes more sense, as the JPEG_Writer also uses pyAV and the previous AV_Writer was only writing MPEG.

2. Extracting common code was challenging, as the data flow was very different between AV_Writer and JPEG_Writer, although both classes did inherently similar things.
The main point of generalization was to have an abstract method encode_frame(), which receives a frame-object and returns a number of Packets.
This is the main difference between both writers and lining that out made everything a lot clearer.

3. Audio writing functionality was apparently hacked into AV_Writer at some point, but was quite different from the rest of the flow.
I created a child class of MPEFG_Writer, called MPEG_Audio_Writer, which wraps additional audio encoding to separate audio from video.
Currently this is only used for world export.

4. All dependecy on the FPS has been removed from both writers, as this was only used to write fixed-rate PTS.

5. The writers now have two modes for PTS, controlled by the __init__ parameter frame_pts_timebase:
* If no timebase is set, frame-pts will be calculated from their timestamps.
* If a timebase is set, frames are expected to carry their own pts. The output stream will be created with the same timebase.
This goes together with the previous commit, but the git history was cleaner when split into two commits.
This was disabled because of a bug in pyAV where the av.VideoFrame does not allow writing dts.
# Conflicts:
#	pupil_src/shared_modules/av_writer.py
Patrick Faion and others added 20 commits September 10, 2019 12:28
@papr papr merged commit fbd8e9f into master Sep 10, 2019
@pfaion pfaion deleted the pi_develop branch September 10, 2019 17:13
@papr papr added the product: Pupil Invisible Issues related to Pupil Invisible label Sep 17, 2019
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.

4 participants