Skip to content

Comments

Add source for video files#698

Merged
SamCarlberg merged 6 commits intoWPIRoboticsProjects:masterfrom
SamCarlberg:feat/video-file-source
May 9, 2017
Merged

Add source for video files#698
SamCarlberg merged 6 commits intoWPIRoboticsProjects:masterfrom
SamCarlberg:feat/video-file-source

Conversation

@SamCarlberg
Copy link
Member

@SamCarlberg SamCarlberg commented Nov 1, 2016

Currently supports:

  • mp4
  • mpeg
  • avi

Currently only supports .mp4
@codecov-io
Copy link

codecov-io commented Nov 1, 2016

Codecov Report

Merging #698 into master will decrease coverage by 1.01%.
The diff coverage is 19.91%.

@@             Coverage Diff              @@
##             master     #698      +/-   ##
============================================
- Coverage     52.45%   51.43%   -1.02%     
- Complexity        0     1146    +1146     
============================================
  Files           240      247       +7     
  Lines          7708     7955     +247     
  Branches        522      539      +17     
============================================
+ Hits           4043     4092      +49     
- Misses         3480     3678     +198     
  Partials        185      185

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d3fa6c...bc0b475. Read the comment docs.

eventBus.post(new SourceHasPendingUpdateEvent(VideoFileSource.this));
Thread.sleep((long) (1e3 / fps));
} catch (InterruptedException | FrameGrabber.Exception e) {
getExceptionWitness().flagException(e);
Copy link
Member

Choose a reason for hiding this comment

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

@vampjaz
Copy link

vampjaz commented Jan 8, 2017

I don't know if/when this will get merged but I'm very interested in using video files for testing pipelines instead of static images.

getExceptionWitness().flagException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
getExceptionWitness().flagException(e, "Interrupted while waiting for next frame");
Copy link
Member

Choose a reason for hiding this comment

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

You probably don't want to flag and you probably want to exit the while loop.

* A source for a video file input.
*/
@XStreamAlias("grip:VideoFile")
public class VideoFileSource extends Source {
Copy link
Member

Choose a reason for hiding this comment

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

There seems to be duplicate code between this and the Camera source. Can any of that be refactored into a base class?

Also, I notice you are using a thread. We had issues with threads and their weirdness. Any reason you didn't implement this as a restarting service?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are some fundamental differences between them. Camera frame grabbers don't get null frame mats from the conversion; video files do. The grabber for the video file needs to update at a specific rate specified by the file itself; camera sources just grab as fast as possible.

And I'm using a Thread (scheduled executor now) to grab the frames because of these two issues.

Should keep the FPS steady.
Also allows it to be paused by external controls if they get added.
@JLLeitschuh
Copy link
Member

Can you rewind or perhaps restart the video?
What about advancing one frame at a time? Would either of these features be useful?

@nightpool
Copy link

nightpool commented Mar 11, 2017 via email

@SamCarlberg
Copy link
Member Author

That is something that would be worthwhile to include. It would act similar to the multi-image file source, but with a scrubber and play/pause button as well.

Also adds a basic observable framework because JavaFX's observables aren't available to the core module.
@SamCarlberg
Copy link
Member Author

SamCarlberg commented Mar 13, 2017

There's something weird with the FFMpegFrameGrabber where it'll segfault, seemingly at random. Seems to only happen when scrubbing through a long video?

.mpeg files don't seem to work very well, either. Scrubbing is laggy and I keep getting errors in the console like

[mpegts @ 0x7fce787cda00] Invalid timestamps stream=0, pts=333257999, dts=333261000, size=221

I only have a ~7MB mpeg file though, maybe a smaller one would work better.

Edit: the size doesn't seem to matter, I can use a 20MB mpeg just fine. Might just be a corrupt or poorly encoded file that's causing the problems.

@JLLeitschuh
Copy link
Member

Seems like you are re-inventing the wheel here:
https://github.com/ReactiveX/RxJava

This library also provides synchronization guarantees.

@SamCarlberg
Copy link
Member Author

I wanted to keep it similar to JavaFX's Observables

@JLLeitschuh
Copy link
Member

Do you want to provide any synchronization guarantees about adding/removing observers?

@SamCarlberg
Copy link
Member Author

There are in SynchronizedObservable. Adding or removing an observer will block until all the observers are notified when the value changes.

@JLLeitschuh
Copy link
Member

Are you sure you don't want to just use RX java's observable?

Copy link
Member

@JLLeitschuh JLLeitschuh left a comment

Choose a reason for hiding this comment

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

This looks good. Merge away.

@SamCarlberg SamCarlberg merged commit 182363c into WPIRoboticsProjects:master May 9, 2017
@SamCarlberg SamCarlberg deleted the feat/video-file-source branch January 28, 2019 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants