dobbelina / repository.dobbelina

repository.dobbelina- Kodi is a registered trademark of the XBMC Foundation.We are not connected to or in any other way affiliated with Kodi
https://dobbelina.github.io/
277 stars 93 forks source link

Download Tip For Windows Users (FFmpeg) #368

Open dobbelina opened 3 years ago

dobbelina commented 3 years ago

FFmpeg Recorder

I got bored testing different addons in regard to downloading videos, as none of them seems to work the way i want.

so i decided to make use of ffmpeg configured as an external player.

By doing that it will be avaliable for all addons that has playable links, and the download for most part goes on in the background, so i can continue to use kodi while it is ongoing.

You can even start multiple downloads at the same time if you wish, depending on what source you use.

Added option is now that you can watch while you are downloading, this is especially useful on livestreams.

This is done thru a "pipe", so no extra bandwith is being consumed.

So here's how i do it:

Download ffmpeg from here: https://ffmpeg.org/download.html

It's a zip archive, so no installation required, just extract ffmpeg.exe & ffplay.exe to a location of your choice.

They both have to be in the same folder.

For this purpose i have made a custom program to simplify, called FFMPEG_Recorder.exe that you can find a link to at the bottom.

Download it and put in the same folder as ffmpeg.exe, or some other permanent location from where it will work as a "dummy player" before running it.

Now start FFMPEG_Recorder.exe, and point to the location of ffmpeg.exe, after that you will be prompted for a download location for the videos.

After execution, 2 xml files will be created in the same folder as FFMPEG_Recorder.exe, that is playercorefactory.xml & playercorefactory2.xml.

Copy those to the %APPDATA%\Kodi\userdata\ folder.

On the desktop a shortcut will be created called "FFMPEG_Recorder Default Change" that toggles between the 2 xml files, making FFMPEG_Recorder.exe default player.

This is necessary, as some addons don't respect the "Play using.." context menu and will revert to the default player, and others wont display a context menu at all.

Press "Q" to stop an ongoing recording/download.

Default container format is mp4, but you can change it by editing the Options

section in ffmpeg.ini to any of the formats supported by ffmpeg, and there are plenty.

In the Options section you can also edit the timestamp switch to off, if you don't like it in the view window.

Recorded video don't have a timestamp.

Delete ffmpeg.ini to restart setup.

Created in Autohotkey

To download from the youtube addon, adjust it's settings like this: Settings=>MPEG-DASH Disable

Update 2020-12-17 v1.5

If you have installed it before, simply overwrite the old exe with the new one and delete ffmpeg.ini to restart setup.

Download here: https://github.com/dobbelina/Playground/releases/download/v1.5-Windows/FFMPEG_Recorder-v1.5.zip

TarkusLV commented 3 years ago

First, thanks for this. This is very cool!

Unfortunately, there are some issues. If I try to use Play Using, and then select FFMPEG Recorder, it simply plays with the default player. If I change the default using the provided shortcut, I get the following error:

Windows cannot find 'C:\Program Files (x86)\Kodi\kodi.exe'. Make sure you typed the name correctly, and then try again.]

I"m running the 64-bit version of Kodi, so it's not in that folder. It does change my default, however, and FFMPEG Recorder does work when it's set as the default player.

TarkusLV commented 3 years ago

A bit more info. I can't seem to use the built-in player if it's not the default either, at least for the streams I've tried. I can use it for local files. For streams (trying both UWC and Venom), only the default player can be used, even though the option is there for the alternative player.

Also, would it be possible to pull the title from the stream link instead of just using the date-time stamp?

dobbelina commented 3 years ago

Inside the folder where you have FFMPEG_Recorder.exe there's a file called default.bat, right-click it and select Edit. In there edit the path to where you have kodi installed. It's on the line where it says Start "kodi"

The reason to set it as default player is because some addons don't respect the "play using" menu, UWC is such an example. I have no solution to this other than setting FFMPEG_Recorder as default player.

It's not possible to pull the title as that information is not passed on to external players, sorry. I updated the app very recently, Make sure you have a line that says "ffcommand=-c copy" in your ffmpeg.ini file. If not, re-download from the link above and replace the old exe with the new one, and restart setup by deleting ffmpeg.ini

TarkusLV commented 3 years ago

Thanks for the update. I saw the note previously about not respecting "play using," but I was thinking the option wouldn't show up at all if it was not respected. I guess I didn't read that part clearly.

I was wondering if it would be possible to have a "Watch Only" option added to the menu? I usually want to preview a stream before I download it, but that's not an option (when "play using" is not respected).

Also, can the command window be started minimized?

Thanks again.

dobbelina commented 3 years ago

Good idea, i will add a third "Watch Only" option. Running command window minimized is more problematic, but i will have a second look at it.

jdoedev123 commented 3 years ago

@dobbelina I have not looked much at the External Player feature as I use mostly Linux but a few universal notes after I tested with VLC. Some of the website plugins for UWC add "|verifypeer=false" (sometimes twice) to the playback URI which only the built-in Kodi Player knows means do not check the certificate. This confuses VLC and I assume ffmpeg and makes the Video unplayable/undownloadable unless the ending is removed. Personally I use another script to read the Kodi JSON where the playback URI and original Video name is available for the playing video. The script removes the ending "|verifypeer=false" and replaces it with "--no-check-certificate" when it passes it to wget which It uses instead of ffmpeg. Wget uses about 2% of a single core of my CPU while downloading a video file with ffmpeg uses about 750% of my 8 cores (max 800%) downloading the same file.

dobbelina commented 3 years ago

@jdoedev123 The "|verifypeer=false" does not get passed on to ffmpeg, it gets parsed out by my application, which also parses user_agent and referer. The issue is not with FFmpeg Recorder or VLC, it's with the addon. On the youtube addon and several others that i have installed, the "Play using" menu works fine and redirects correctly to the external player. That script that you have sounds interesting, maybe you can give me a copy?

@TarkusLV Your requested feature has been implemented, why didn't I think about that before? šŸ˜œ Download link has been updated to the new version in the first topic. New version is v1.5

dobbelina commented 3 years ago

@TarkusLV If you see this message after you downloaded above, download again. It was a bug with the cookie handling that i have corrected in an updated release.

TarkusLV commented 3 years ago

Thank you, dobbelina! Love the new version with the watch only option.

TarkusLV commented 3 years ago

Not a big deal, but just noticed the timestamp in the filename uses 12-hour time, so videos recorded in the afternoon can look older than videos recorded earlier that morning. Any chance of converting to 24-hour time?

dobbelina commented 3 years ago

Not a big deal, but just noticed the timestamp in the filename uses 12-hour time, so videos recorded in the afternoon can look older than videos recorded earlier that morning. Any chance of converting to 24-hour time?

@TarkusLV Fixed, re-download above again. SHA1: ee3c66ae9e0e9412b8112f72a59204af7dad7897

Keyboard shortcuts for FFplay: https://www.programmersought.com/article/9393356671/

dobbelina commented 3 years ago

@TarkusLV Re-download above again, i fixed the annoying "External player active" pop-up when returning to kodi. SHA1: 5f7f65855b60fa78e230e7b5011000bdc32fc57f

TarkusLV commented 3 years ago

@dobbelina Not sure if this is a bug, or necessary for the above fix, but when selecting Download Only, it continues to show the selected stream as playing in the upper-right corner of Kodi. It stays there until you stop it manually, play something else or exit FFMPEG Recorder from the tray icon. Of course, the recording continues in the command window.

Not a big deal. Just a cosmetic issue, really.

dobbelina commented 3 years ago

@TarkusLV Ok, I removed that behaviour on download option1. The recorder only has to stay active on option 2 & 3 to avoid the "External player active" pop-up. Re-download above again for the updated version. SHA1 9c9369a700b26cd1c440959146c5bbf7efe62462

dobbelina commented 3 years ago

@TarkusLV Yet another little polishing of the diamond šŸ˜„ Did some adjustment to the ability to play/re-encode locally downloaded files. Please re-download above again. SHA1: cae418135144af33c73de9844959a3004482c1d3

losthelp815 commented 3 years ago

I no this thread is quite old but i have just became aware of this recently this tool is incredible. But wanted to no if it would be possible to have an update for Chaturbate when watching to preview the stream is really low quality. And when used for MFC it is perfect stream. Is there anything that can be done for this issue. Also extremely grateful for this tool.

IllusoryPositivity commented 8 months ago

Hello and thanks for Cumination, but I'm having an issue getting this ffmpeg download solution working on pervrzija (per your comment on another post you said this would work in Windows). I'm on Windows 11 and have verified your program works for at least one other site in Cumination.

I'll describe in detail what I did from the beginning just to be clear:

I downloaded your FFMPEG_Recorder and a copy of ffmpeg and ffplay and put them all in the same folder. I then execute FFMPEG_Recorder, point it to ffmpeg, and select an output folder. The Instructions.txt opens. I then copy both playercorefactory and playercorefactory2 to %AppData%\Roaming\Kodi\userdata.

I ran "FFMPEG_Recorder Default Change" and Kodi opens automatically. I then play the pervrzija video. I then see a pop-up that has the three (1-3, DL, DL+Watch, Just Watch) options. I press 1. A cmd window opens and closes immediately. Nothing happens.

I then press 2 instead. A cmd window opens and before closing almost immediately outputs some errors which I read by recording the screen and pausing on playback. The errors are as follows: Error opening input: Invalid data found when processing input Error opening input file C:\Users[user]\AppData\Roaming\Kodi\cache\myParent.m3u8 Error opening input files: Invalid data found when processing input

When I try pressing 3 instead, I get the following errors that I read in a similar fashion: Protocol 'https' not on whitelist 'file,crypto,data'! Failed to open segment 1 of playlist 0 Segment 1 of playlist 0 failed too many times, skipping [And these loop for a finite amount of times until the last line reads:] C:\Users[user]\AppData\Roaming\Kodi\cache\myParent.m3u8: Invalid data found when processing input

Is this something pervrzija changed on their end that made this not work anymore? Could it be patched?

Let me know if I can provide any information to you that would help. Thank you for your time.