Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NullPointerException when playing some videos #362

Closed
tpenguinltg opened this issue Feb 12, 2018 · 3 comments
Closed

NullPointerException when playing some videos #362

tpenguinltg opened this issue Feb 12, 2018 · 3 comments
Labels

Comments

@tpenguinltg
Copy link
Contributor

A NullPointerException occurs when the tbr of a video is not completely numeric. Example video: 103482 - Rhodanthe* - Jumping!! (TV Size)

Here is the relevant line from FFmpeg output. Note that 90k tbr does not match the regex in FFmpeg.java:111, which looks for a number with an optional decimal point followed by "tbr", causing the regex utility to return null.

    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 854x480, 90k tbr, 90k tbn, 90k tbc

FFmpeg's output to stderr is not meant to be parsed. The proper way to solve this is to use FFprobe, with the flags given in this Ask Ubuntu answer. The output is printed to stdout and the result of the division gives you the frame rate.

$ ffprobe -v 0 -of csv=p=0 -select_streams v:0 -show_entries stream=r_frame_rate OP480.avi
90000/1

Note that we don't currently bundle ffprobe.


Stack trace

Sun Feb 11 19:00:55 EST 2018 ERROR:null
java.lang.NullPointerException
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
        at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
        at java.lang.Float.parseFloat(Float.java:451)
        at itdelatrisu.opsu.video.FFmpeg.extractMetadata(FFmpeg.java:111)
        at itdelatrisu.opsu.video.Video.<init>(Video.java:80)
        at itdelatrisu.opsu.states.Game.loadVideo(Game.java:1976)
        at itdelatrisu.opsu.states.Game.enter(Game.java:1654)
        at org.newdawn.slick.state.StateBasedGame.update(StateBasedGame.java:248)
        at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:702)
        at itdelatrisu.opsu.Container.gameLoop(Container.java:136)
        at itdelatrisu.opsu.Container.start(Container.java:80)
        at itdelatrisu.opsu.Opsu.main(Opsu.java:213)
@itdelatrisu
Copy link
Owner

It looks like FFprobe binaries are huge, so including them doesn't make sense if we can just fix the regex... thoughts?

@tpenguinltg
Copy link
Contributor Author

Looks like it might be doable. According to dump.c#print_fps, the only abbreviation it does is "k" for 1000, so we only need to additionally handle that case.

@itdelatrisu
Copy link
Owner

Fixed in 0b36328, let me know if it didn't work. Thanks! :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants