Open jansmolders86 opened 10 years ago
It seems a bit choppy for me.
Also when I closed the page streaming a video, the server looks like its still transcoding? is that the word. Like it is doing work to stream the file even though there is no one watching.
Also it seems to block up the server, are we using some sync code here when it could be async or a spawned off child process?
@LiamKarlMitchell typically, when transcoding video, the server will continue to transcode the video until the file is done. the reasons for this are several, with the top being that if a session is lost while playing it can be recovered without the need to start from the beginning of the file for transcoding. This enables proper seek with the video along with resuming the video from where it was left off.
@jansmolders86 I was browsing through the code (please correct me if I'm wrong) and it looks like video playback is done via the file / transcoded file via it's path. Is there a reason you're not making use of web sockets and chunks? This could allow for better buffering of the video and provide a smoother flow....
also, if you progress with multi user video interaction it may be wise to store the transcoded file name in some sort of store so it can be used for future sessions to watch the video if the same codec is supported by the browser...
My idea was that if you have closed the window it should stop doing the work, just having the internet disconnect and using F5 should allow it to reconnect yes.
We can execute code when a browser window is closed or navigated away from. But I am not sure if we can do a request to stop the operation at that point?
Maybe something like
window.onbeforeunload = function() {
if (streaming_video) {
TellServer('stop_transcode', { video: streaming_video_job_id })
}
};
@Karnith I would very much like to see a code example of handling the transcoding via chunks and websockets. Does this approach tie in with the MPEGTS module you sent me? (thanks for that btw, I didn't have time yet to respond sooner.)
@jansmolders86 I'll need to do a gist of the transcoding via chunks, it's something I'm currently looking into. My theory on this is that by using streams (web sockets) for playback an mp4 file could play while it's being transcoded. The current behavior of playing mp4 while transcoding dictates that the player will only play what the browser has currently downloaded. I have seen this with taking a file and transcoding it to mp4 at the same time as the browser pulls the file. The duration is only as long as the current transcoded duration and only expands in duration if the page is refreshed. By using web sockets, the feed to the player current duration becomes dynamic and live which would enable the player to continue buffering as the mp4 plays, updating the cache duration for the player to pull from. Since web sockets can send chunks of a particular file (video/audio/etc) a method could be created to watch the transcode duration and send a chunk after a predefined chunk size has been met.
I hope this makes sense, I've been drinking today.... :)
@LiamKarlMitchell the issue with doing as you propose is that, for example, a user starts playing a file and accidentally browses away from the file. The user then goes back to the media for play, but since the browser was changed and the file transcode stopped it created a partial transcoded file. The choices now are
a) try to start the transcode where it left off which would require logic to pass the current play time to ffmpeg. This would create a new file which would then need to be merged with the previous transcode and hope that they align properly with a/v for seek functionality
b) start the transcode from the beginning and have a method to remove the previous transcoding to save space on the storage. this could cause frustration with the user if the user is 30 min into the moves and this accident happens (it would mean that the user needs to fast forward to where they last were in the movie).
Either way this could cause high utilization of system resources, which could be better used serving another users transcode.
Hmm that makes sense I suppose.
Is there also a way we can set options like, Low medium high quality. It may be useful over non lan, and also lower spec devices to stutter the video when trying to play 1080p stream.
yes, this is possible. It can be done in a variety of different ways.One method would be to have a default quality setting which would be overridden when the user selects a different quality from the player/user panel before transcoding/playing the media. If it is more of a youtube like quality functionality you want, you would need separate transcodes of the media at different bit rates which ffmpeg is able to do. FFMPEG supports outputting in several different bitrates at the same time which would allow the player to switch from one quality to another based on traffic conditions. Methods can also be created that "pull" the device info of a user (browser/OS/etc) before transcoding and use the info to alter the FFMPEG command to transcode.
I see, and we would have some sort of cache yeah?
So that if another user wants to view the same media which is already being transcoded it would reuse it?. And then if the time from last request to stream is greater than media time
Another thought the other night as I was struggling to get stuff to stream to the PS3 it could be possible to configure a media server to use the same data that mediacenterjs gathers and streams to enable devices such as those that support mediaservers but have a lacking web browser to browse and stream files added.
There seems to be an experimental node.js module here: https://github.com/jacobrask/bragi
To stream to devices it is best to use up np dnla. This would require device profiles for transcode configuration vs native format play on the device.
-------- Original message -------- From: Liam Mitchell Date:06/30/2014 17:10 (GMT-08:00) To: jansmolders86/mediacenterjs Cc: Matthew Marino Subject: Re: [mediacenterjs] Improvements video playback (#38)
I see, and we would have some sort of cache yeah?
So that if another user wants to view the same media which is already being transcoded it would reuse it?. And then if the time from last request to stream is greater than media time
Another thought the other night as I was struggling to get stuff to stream to the PS3 it could be possible to configure a media server to use the same data that mediacenterjs gathers and streams to enable devices such as those that support mediaservers but have a lacking web browser to browse and stream files added.
There seems to be an experimental node.js module here: https://github.com/jacobrask/bragi
Reply to this email directly or view it on GitHubhttps://github.com/jansmolders86/mediacenterjs/issues/38#issuecomment-47603114.
I just looked at the link in your message. Although it's a up np server, it hasn't been worked on in over 2 years. You're on the right track though.
A better upnp server would be upnpserver https://github.com/oeuillot/upnpserver. I tried upnp/dlna with this module and it works. I was able to stream to my 2 Samsung smart tvs without any issues using an mkv with ac3 and h.265
From: Liam Mitchell [mailto:notifications@github.com] Sent: Monday, June 30, 2014 5:11 PM To: jansmolders86/mediacenterjs Cc: Matthew Marino Subject: Re: [mediacenterjs] Improvements video playback (#38)
I see, and we would have some sort of cache yeah?
So that if another user wants to view the same media which is already being transcoded it would reuse it?. And then if the time from last request to stream is greater than media time
Another thought the other night as I was struggling to get stuff to stream to the PS3 it could be possible to configure a media server to use the same data that mediacenterjs gathers and streams to enable devices such as those that support mediaservers but have a lacking web browser to browse and stream files added.
There seems to be an experimental node.js module here: https://github.com/jacobrask/bragi
— Reply to this email directly or view it on GitHubhttps://github.com/jansmolders86/mediacenterjs/issues/38#issuecomment-47603114.
Very cool Matthew! I used https://github.com/jacobrask/node-upnp-device but that module hasn't been active for a lot time. This looks very promising!
I've added the option in the settings to choose the quality of transcoding. If it seems a bit choppy, please try a lower setting. I'm curious if the performance improves.
Transcoding is strenuous for the cpu so if you have an i7, the high setting will not be an issue but if you are running from a nas, high might be a bit too much. Ofcourse all settings still need to be optimized to get the most out of the power available