jansmolders86 / mediacenterjs

A HTML/CSS/Javascript (NodeJS) based Media center
http://mediacenterjs.com
1.29k stars 243 forks source link

Metadata & Playback Refactoring #176

Closed hoffi closed 9 years ago

hoffi commented 9 years ago

Hey,

i refactored the metadata gathering process and media playback. I think this would make it much more maintainable as i created a Media-Handler which contains all code that is the same for Movies, TV-Shows and Music. The only real difference is the way the metadata is produced. Now every app has its Metadata-Processor which contains all the necessary code to provide the metadata for one file and nothing more. This eliminated much duplicate code and also made it a bit faster (i think thats because i now using file-utils.getLocalFiles instead of the walk-Functions that is implemented the *-functions.js files of the apps).

I also refactored the media playback with same goal of get more maintainability. There is now a music-playback.js file for all music files and a video-playback.js file for all video files in lib/handlers and a folder lib/transcoding with files for desktop, android and iOS transcoding.

What do you think about it? And could you test this on windows? I only have Mac OS X.

jansmolders86 commented 9 years ago

Thanks so much for this Stefan! The code looks amazing! I'll check asap and let you know! Thanks again!

jansmolders86 commented 9 years ago

There still seems to be an issue with the transcoding path. I'm afraid I haven't got time to dig into it right now, but will do so ASAP! But from what I can tell, if I log the FFmpeg variable in desktop.js, I get the correct path!

My output is:

warn: Input #0, avi, from 'C:\Users\Jan\Videos\Frozen (2013).avi': Metadata: encoder : Lavf51.12.1 Duration: 01:42:13.06, start: 0.000000, bitrate: 2473 kb/s Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuv420p, 1280x568 [SAR 1:1 DAR 160:71], 23.98 fps, 23.98 tbr, 23.98 tbn, 47.95 tbc Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, 5.1(side), fltp, 448 kb/s public\data\Movie\C:\Users\Jan\Videos\Frozen-(2013).mp4: Invalid argument

error: FFMPEG error: killed=false, code=1, signal=null Executing (default): SELECT * FROM ProgressionMarkers WHERE ProgressionMarkers.MovieId=1 AND ProgressionMarkers.progression=0 AND Progressi onMarkers.transcodingStatus='pending' LIMIT 1; Executing (default): INSERT INTO ProgressionMarkers (id,progression,transcodingStatus,MovieId) VALUES (NULL,0,'pending',1);

hoffi commented 9 years ago

Hm interesting issue. I have no idea where this path comes from public\data\Movie\C:\Users\Jan\Videos\Frozen-(2013).mp4..

jansmolders86 commented 9 years ago

Got it! it's the "normalizedFilename" on line 56 of the video-playback,js :) (it's still the full path) Will fix it tomorrow!

hoffi commented 9 years ago

Ah i see what the problem is. The path is separated by backslashes instead of normal ones.

jansmolders86 commented 9 years ago

aah of course haha! We'll lay the blame at Microsoft corner shall we

hoffi commented 9 years ago

Yes ;) I think the best solution would be to ensure that always normal slashes would be written to the database in the metadata-processors, if that do not cause any problems on windows. Because it is assumed at multiple locations that the path uses normal slashes. What do you mean?

jansmolders86 commented 9 years ago

Hey Hoffi, I added a regex to the fileurl in the metadata processor to fix the issue. It works now! Would you please test if it still works for you as well?

Jon889 commented 9 years ago

Perhaps the code should be changed to use the node path module to handle all the path manipulations?

hoffi commented 9 years ago

Indeed @Jon889. Haven't thought about the path module. This makes it much easier! @jansmolders86: Can you try again? Make sure to clear the cache before :)

jansmolders86 commented 9 years ago

Naturally, you guys thought of a much nicer and more elegant solution! Works great and I'm gonna merge it right away! Thanks a bunch!

hoffi commented 9 years ago

No problem :)