hey, may I ask a question about streaming video ? ...
# getting-started
k
hey, may I ask a question about streaming video ? I have written the code, you can see the upload file. but I found that the
mpv
player can just play it for 4 seconds, I can't control the progress bar, but the <video> tag in web browser works well, I don't know what the matter with my code, can you help me out ?
and this is the log when I try to control the progress bar
Copy code
steiner@archlinux ~/w/j/ArgumentParser.jl (master) [128]> mpv "<http://localhost:8083/api/video/1>"
 (+) Video --vid=1 (*) (h264 1920x1080 23.976fps)
 (+) Audio --aid=1 --alang=jpn (*) (aac 2ch 48000Hz)
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: Packet corrupt (stream = 0, dts = 152152).
[ffmpeg] NULL: Invalid NAL unit size (27651 > 15373).
[ffmpeg] NULL: missing picture in access unit with size 15377
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: stream 0, offset 0x1b57cc: partial file
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p
AV: 00:00:01 / 00:23:55 (0%) A-V:  0.000 Cache: 4.7s/1MB
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: stream 0, offset 0x1b7138: partial file
AV: 00:07:53 / 00:23:55 (33%) A-V:  0.000 Cache: 0.0s/57KB
[ffmpeg/video] h264: Invalid NAL unit size (27651 > 15373).
[ffmpeg/video] h264: Error splitting the input into NAL units.
Error while decoding frame!
AV: 00:07:53 / 00:23:55 (33%) A-V:  0.000 Cache: 0.0s/1KB
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: stream 1, offset 0x1b8a45: partial file
AV: 00:00:00 / 00:23:55 (0%) A-V:  0.000 Cache: 5.2s/1MB
[ffmpeg/demuxer] mov,mp4,m4a,3gp,3g2,mj2: stream 1, offset 0x1b8c9d: partial file
AV: 00:07:53 / 00:23:55 (33%) A-V:  0.000 Cache: 0.0s/137KB
[ffmpeg/video] h264: Invalid NAL unit size (27651 > 15373).
[ffmpeg/video] h264: Error splitting the input into NAL units.
Error while decoding frame!
AV: 00:07:53 / 00:23:55 (33%) A-V:  0.000 Cache: 0.0s/1KB

Exiting... (End of file)
d
Unfortunately, this is pretty far off topic for a Kotlin language slack. You'd probably be better off finding information from either Spring or mpv community.
k
As far as your use of Kotlin goes, that doesn't appear to be what is causing the problem. Though this bit is not idiomatic:
Copy code
var range = 0L
        if (!rangeString.isBlank()) {
            range = java.lang.Long.valueOf(rangeString.substring(rangeString.indexOf("=") + 1, rangeString.indexOf("-")))
        }
I would change it to:
Copy code
val range =
            if (!rangeString.isBlank()) 0L
            else (rangeString.substringAfter("=").substringBefore("-")).toLong()
s
I might write that this way instead:
Copy code
val range = rangeString.takeIf { it.isNotBlank() }
    ?.substringAfter("=")
    ?.substringBefore("-")
    ?.toLong()
    ?: 0L
(there might also be a better way of getting the substring in question, but that's a different problem)