Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/main/java/us/ihmc/robotDataLogger/logger/MagewellMuxer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class MagewellMuxer
{
private final FFmpegFrameRecorder recorder;
private boolean closed = false;

public MagewellMuxer(File videoCaptureFile, int captureWidth, int captureHeight)
{
Expand Down Expand Up @@ -55,20 +56,17 @@ public void recordFrame(Frame capturedFrame, long videoTimestamp)
// This is where a frame is record, and we then need to store the timestamps, so they are synced
try
{
if (!recorder.isCloseOutputStream())
{
recorder.record(capturedFrame);
}
recorder.record(capturedFrame);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}

public boolean isCloseOutputStream()
public boolean isClosed()
{
return recorder.isCloseOutputStream();
return closed;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close output stream is only for when you pass one in. we're passing in a file. it's always gonna be false
image
image


public long getTimeStamp()
Expand All @@ -78,10 +76,9 @@ public long getTimeStamp()

public void close()
{
recorder.setCloseOutputStream(true);
closed = true;
try
{
recorder.flush();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop already calls flush
image

recorder.stop();
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void startCapture() throws Exception

long startTime = System.currentTimeMillis();
Frame capturedFrame;
while (!magewellMuxer.isCloseOutputStream() && ((capturedFrame = grabber.grabAtFrameRate()) != null))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, so were we actually using the closeOutputStream variable to signal that we wanted to stop the recording?? 😂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added back the closed logic, but not using an unrelated internal variable

while (!magewellMuxer.isClosed() && ((capturedFrame = grabber.grabAtFrameRate()) != null))
{
long videoTimestamp = CaptureTimeTools.timeSinceStartedCaptureInSeconds(System.currentTimeMillis(), startTime);
magewellMuxer.recordFrame(capturedFrame, videoTimestamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void main(String[] args) throws InterruptedException

// Loop to capture a video, will stop after iterations have been completed
LogTools.info("Starting capture");
while (!magewellMuxer.isCloseOutputStream() && ((capturedFrame = grabber.grabAtFrameRate()) != null))
while (!magewellMuxer.isClosed() && ((capturedFrame = grabber.grabAtFrameRate()) != null))
{
long videoTimestamp = CaptureTimeTools.timeSinceStartedCaptureInSeconds(System.currentTimeMillis(), startTime);
magewellMuxer.recordFrame(capturedFrame, videoTimestamp);
Expand Down
Loading