Own video streaming

Hi, for my project I would like to implement on-demand video streaming. Currently I have no clue, should I implement it myself or should I use a third party api which is expensive. If it's not hard to implement it myself, it's not worth paying for third party. What do you recommend, maybe you have your own experience and can make a guide for it?
64 Replies
JavaBot
JavaBot2w ago
This post has been reserved for your question.
Hey @Serkan Gülbol! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st2w ago
What exactly do you mean with implementing video streaming?
nikcho-kouhai
nikcho-kouhai2w ago
I am currently in the process of implementing something like a streaming application from scratch and I can tell you it's not easy Let's start from the fact that you can't do it in java if you want your performance to be at least half reasonable You are gonna need native code for handling decoding and most probably displaying of frames because you are gonna need fine grained control over the fps at which your frames are displayed The whole thing is a giant headache and trust me implementing it yourself is gonna take a pretty long time
dan1st
dan1st2w ago
you can if you really want to but there are very specific considerations for it
ayylmao123xdd
ayylmao123xdd2w ago
isnt netflix based on java or something lol
dan1st
dan1st2w ago
for the most part, yes
ayylmao123xdd
ayylmao123xdd2w ago
interesting
nikcho-kouhai
nikcho-kouhai2w ago
It's possible that most of it is in Java but I'm telling you you are at the very least gonna have to use native libraries Or bindings to them Like ffmpeg
dan1st
dan1st2w ago
yes but that doesn't mean you can't do your business logic in Java - and you don't need to use other langauges for using native libraries not even if you make your own bindings
nikcho-kouhai
nikcho-kouhai2w ago
And you might be able to (I tried initially with javafx, but performance was bad because of all the copies and frame layout transitions that had to be made)
dan1st
dan1st2w ago
there are some other ways including but not limited to lwjgl (and even Swing)
nikcho-kouhai
nikcho-kouhai2w ago
Yeah, but point stands that it's a headache
dan1st
dan1st2w ago
but the implementation itself is likely not the biggest issue The bigger issue regarding to this question might be hosting the server part of it - using a third-party API will likely be cheaper but it depends on what exactly they want to do
ayylmao123xdd
ayylmao123xdd2w ago
why use javafx in the first place tho
dan1st
dan1st2w ago
depends on the exact goals
nikcho-kouhai
nikcho-kouhai2w ago
That's just what I tried to do originally It depends, maybe they want to make point to point connections and have the one streaming be the host
Itsurran
Itsurran2w ago
What exactly do you mean with implementing video streaming?
dan1st
dan1st2w ago
and even with JavaFX you can get decent performance on these things depending on the exact goals
ayylmao123xdd
ayylmao123xdd2w ago
my question is why use javafx instead of something else for front end ez
nikcho-kouhai
nikcho-kouhai2w ago
You don't need to use javafx
ayylmao123xdd
ayylmao123xdd2w ago
so overall java isnt a bad choice to use at all if even netflix uses it and they dont seem to have a lot of performance issues with it
nikcho-kouhai
nikcho-kouhai2w ago
I'm just telling you what the drawbacks of using a library like javafx that doesn't give you much access to what's going on behind
dan1st
dan1st2w ago
Because it works well for most things once you set it up - you can also use swing or similar but what you use depends on your needs
ayylmao123xdd
ayylmao123xdd2w ago
whats the performance when compared to front end with react or angular
dan1st
dan1st2w ago
probably depends on what you're doing and how you are executing it - for most things, it will probably be better with JavaFX compared to having a website using a JS framework
nikcho-kouhai
nikcho-kouhai2w ago
That might not be the case. I haven't written pretty much anything in JavaScript but clearly hardware acceleration is available there without making a CPU to GPU and back copy Which is a pretty decent bit of what I mean by performance Decoding and changing formats is pretty expensive With javafx you have to do a ton of it And copying * *available perhaps through webgl so honestly I'm not too sure about javafx vs react or the like Look, depending on how you are gonna be using your streaming app as dan1st said javafx or swing or whatever might be fine, but don't expect it to run as good as most others
dan1st
dan1st2w ago
for most things
nikcho-kouhai
nikcho-kouhai2w ago
Well it's a cool project littered with annoying problems (like video and audio synchronization) so you can give it a shot anyway if you have the time and desire
Serkan Gülbol
Serkan GülbolOP2w ago
Why it is so important, I was thinking I am able using a cloud and upload the video there which will be transcoded by ffmpeg by an script easily
dan1st
dan1st2w ago
should work perfectly fine but cloud stuff can be costly especially if you are doing stuff like video streaming
Serkan Gülbol
Serkan GülbolOP2w ago
I mean using a usual cloud and encode it myself, it is cheaper than using a all in the box cloud with video streaming service, isnt it?
nikcho-kouhai
nikcho-kouhai2w ago
you want to stream it though? it has to be decoded on the client machine you can encode it like that, sure but you can't decode it like that
dan1st
dan1st2w ago
which works with ffmpeg as they said Don't be so sure could be but don't assume it
nikcho-kouhai
nikcho-kouhai2w ago
he quoted my comment that was referencing decoding yes, that works with ffmpeg, but you can't do it on the cloud with a script because decoding happens on the client machine
Serkan Gülbol
Serkan GülbolOP2w ago
So this was referred to the front-end site?
dan1st
dan1st2w ago
both frontend and backend but if you are hosting a lot of video material and letting others stream it, it will probably be expensive
Serkan Gülbol
Serkan GülbolOP2w ago
Need I decode it myself, isn't there video players which does it automatically on the client side. So in Flutter there is a package video_player which decodes it Of course it is
dan1st
dan1st2w ago
there are some AFAIK but it depends on what you are using and what you want to decode/play in which way
nikcho-kouhai
nikcho-kouhai2w ago
there probably are, but I couldn't find any in java
Serkan Gülbol
Serkan GülbolOP2w ago
i also dont know if for java is @nikcho-kouhai How long does it take you and what do you think can it take my when using a video player in flutter?
nikcho-kouhai
nikcho-kouhai2w ago
How long it takes depends on how much you know really If you know nothing about this topic it's probably gonna take a pretty decent chunk of time Potentially months before you can get it working properly Although if you are experienced at programming probably less
Serkan Gülbol
Serkan GülbolOP2w ago
I understand, I'm a software engineer, but I have nothing to do with server and this topic
nikcho-kouhai
nikcho-kouhai2w ago
Well it probably won't take too long although I can't say for flutter. I have never used it
Serkan Gülbol
Serkan GülbolOP2w ago
For conclusion what are the steps: upload the video on server/cloud, transcode the video, making dash and HSL - Connection possible, decode it on Client side. Habe I forgotten a step?
dan1st
dan1st2w ago
you probably don't need to know that much about encoding/decoding since libraries are gonna do it for you
nikcho-kouhai
nikcho-kouhai2w ago
I'm talking mostly about dealing with the actual already decoded audio and video and I am speaking based on my experience in java Somewhere else you.might find something that deals with displaying the video and audio properly making it easy In java its kind of a pain You also need something to display the video and audio
dan1st
dan1st2w ago
the foreign function and memory can help if necessary
nikcho-kouhai
nikcho-kouhai2w ago
Again you might find it a lot easier if you can manage to find some tool to do most of the work for you What foreign function and memory? * as in native functions or?
dan1st
dan1st2w ago
it allows access off-heap memory (and also arrays in some ways) and also access native functions but I'm mainly talking about the native memory - there are libraries for encoding/deconding, that isn't the problem but if you deal with large amounts of data you might want to put it to off-heap memory and with jextract you could also generate native bindings pretty easily if necessary but that shouldn't be necessary
nikcho-kouhai
nikcho-kouhai2w ago
Yeah, about decoding there's stuff you can use I'm talking about displaying the decoded stuff That can be surprisingly annoying to deal with properly Especially if you have to do it from scratch But if you can find like a media player that takes in raw decoded audio and video frames, displays the video and plays the audio frames and synchronizes them properly You can probably do it without too much effort, but if you can't find such a player ( I couldn't ) it can be hard to implement
dan1st
dan1st2w ago
there is also stuff for that
nikcho-kouhai
nikcho-kouhai2w ago
Well then it shouldn't be too difficult
Serkan Gülbol
Serkan GülbolOP2w ago
Thank you I will consider it
JavaBot
JavaBot2w ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
nikcho-kouhai
nikcho-kouhai2w ago
If you have any implementation questions you can ask me I've mostly been through the wringer so I hope I can help you
Serkan Gülbol
Serkan GülbolOP2w ago
I appreciate it
nikcho-kouhai
nikcho-kouhai2w ago
Only on mobile
nikcho-kouhai
nikcho-kouhai2w ago
GitHub
javacpp-presets/ffmpeg at master · bytedeco/javacpp-presets
The missing Java distribution of native C++ libraries - bytedeco/javacpp-presets
JavaBot
JavaBot2w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Serkan Gülbol
Serkan GülbolOP2w ago
I decided to use a service first due to lack of time and other priorities. But i'm really looking forward to trying it myself in the future and making my own experience with it. When the time comes to do it myself I will come back to you to exchange the experience and the issues I faced with.
nikcho-kouhai
nikcho-kouhai2w ago
I wish you good luck!
JavaBot
JavaBot2w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?