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
⌛
This post has been reserved for your question.
Hey @Serkan Gülbol! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose 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.
What exactly do you mean with implementing video streaming?
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
you can if you really want to but there are very specific considerations for it
isnt netflix based on java or something lol
for the most part, yes
interesting
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
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
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)
there are some other ways including but not limited to lwjgl (and even Swing)
Yeah, but point stands that it's a headache
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
why use javafx in the first place tho
depends on the exact goals
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
What exactly do you mean with implementing video streaming?
and even with JavaFX you can get decent performance on these things depending on the exact goals
my question is
why use javafx
instead of something else
for front end
ez
You don't need to use javafx
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
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
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
whats the performance when compared to front end with react or angular
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
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
for most things
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
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
should work perfectly fine
but cloud stuff can be costly
especially if you are doing stuff like video streaming
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?
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
which works with ffmpeg as they said
Don't be so sure
could be but don't assume it
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
So this was referred to the front-end site?
both frontend and backend
but if you are hosting a lot of video material and letting others stream it, it will probably be expensive
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
there are some AFAIK
but it depends on what you are using and what you want to decode/play in which way
there probably are, but I couldn't find any in java
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?
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
I understand, I'm a software engineer, but I have nothing to do with server and this topic
Well it probably won't take too long although I can't say for flutter. I have never used it
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?
you probably don't need to know that much about encoding/decoding since libraries are gonna do it for you
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
the foreign function and memory can help if necessary
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?
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
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
there is also stuff for that
Well then it shouldn't be too difficult
Thank you I will consider it
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.
If you have any implementation questions you can ask me
I've mostly been through the wringer so I hope I can help you
I appreciate it
Maybe these can help you https://developer.android.com/reference/android/media/MediaCodec
Android Developers
MediaCodec | Android Developers
Only on mobile
https://github.com/bytedeco/javacpp-presets/tree/master/ffmpeg
I used this for encoding and decoding
GitHub
javacpp-presets/ffmpeg at master · bytedeco/javacpp-presets
The missing Java distribution of native C++ libraries - bytedeco/javacpp-presets
💤
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.
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.
I wish you good luck!
💤
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.