FFmpeg Recorder

dobbelina

Developer
Aug 11, 2013
30
6
8
Hi all!

I got bored testing different addons in regard to recording/downloading, 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.
It's not perfect, but the best i found so far.

So here's how i do it:
Download ffmpeg from here: https://ffmpeg.zeranoe.com/builds/
It's a zip archive, so no installation required, just extract ffmpeg.exe to a location of your choice.
Now start FFMPEG_Recorder.exe that you got from here, 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.

Press "Q" to stop an ongoing recording/download.
Delete ffmpeg.ini to re-start setup.

Created in Autohotkey

Download here: https://github.com/dobbelina/Playground/releases/download/v1.1-Windows/FFMPEG_Recorder.zip
Below is the script for those who want to compile it for themselves:
#NoEnv
#SingleInstance force
SetWorkingDir %A_ScriptDir%
IniName = ffmpeg.ini
Incoming := chr(34) . A_Args[1] . chr(34)
Clipboard := Incoming
Datefile := "%Y-%m-%d_%H-%M-%S.mp4"
if (A_ScriptDir = A_AppData . "\Kodi\userdata")
{
msgbox, Do Not Run From The Userdata Folder!
ExitApp
}
IfNotExist, %IniName%
{
FileSelectFile, SelectedFile, 3, , Select ffmpeg.exe, ffmpeg (*.exe)
if (SelectedFile = "")
{
MsgBox, The user didn't select anything.
ExitApp
}
else
IniWrite, %SelectedFile%, %IniName%, Init, ffmpeg

FileSelectFolder, OutputVar, , 3, Choose Output Folder
if OutputVar =
{
MsgBox, You didn't select a folder.
FileDelete, %IniName%
ExitApp
}
else
IniWrite, %OutputVar%, %IniName%, Init, outputfolder
FileInstall, playercorefactory.xml, playercorefactory.xml
FileInstall, playercorefactory2.xml, playercorefactory2.xml
FileInstall, Switch.ico, Switch.ico
if (A_Is64bitOS = 1)
FileInstall, default.bat, default.bat
else
FileInstall, default32.bat, default.bat
filePath := "playercorefactory.xml"
lineNumToReplace := 4
newLine := " <filename>" . A_ScriptDir . "\FFMPEG_Recorder.exe" . "</filename>"
ReplaceLine(filePath, lineNumToReplace, newLine)
filePath := "playercorefactory2.xml"
ReplaceLine(filePath, lineNumToReplace, newLine)

FileCreateShortcut, %A_ScriptDir%\default.bat, %A_Desktop%\FFMPEG_Recorder Default Change.lnk, "%A_ScriptDir%", , FFMPEG_Recorder Default Change, %A_ScriptDir%\Switch.ico
FileDelete, Instructions.txt
FileAppend,
(
Now copy the created playercorefactory.xml & playercorefactory2.xml to this folder:
%A_AppData%\Kodi\userdata
A shortcut has been created on the desktop to toggle between
the 2 playercorefactory files, making FFMPEG Recorder default or not.
Press "Q" to stop an ongoing recording/download.
), Instructions.txt
Run, Instructions.txt
ExitApp
}
IniRead, ffmpeg, ffmpeg.ini, Init, ffmpeg
IniRead, outputfolder, ffmpeg.ini, Init, outputfolder
PathFile := chr(34) . outputfolder . "\" . Datefile . chr(34)
Recorder := chr(34) . ffmpeg . chr(34)

Run, %Recorder% -i %Incoming% -c copy -f segment -segment_time 21600 -strftime 1 %PathFile%
ExitApp

ReplaceLine(filePath, lineNum, text) {
oFile := FileOpen(filePath, "rw")
start := oFile.Pos
Loop % lineNum {
line := oFile.ReadLine()
if (A_Index = lineNum - 1)
linePos := oFile.Pos
if (A_Index = lineNum && notEOF := true)
rest := oFile.Read()
} until oFile.AtEOF
if notEOF {
oFile.Pos := linePos
oFile.Write( text . RegExReplace(line, "[^`r`n]+") )
oFile.Write(rest)
oFile.Length := oFile.Pos
}
oFile.Close()
}
 

dobbelina

Developer
Aug 11, 2013
30
6
8
I might add,
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.
 

capslock

Guest
Jan 1, 2018
112
16
18
Well, so many options as there are people. The video-addons (several) that I use ALL download movies and shows perfectly, so I do not see the problem.
 

dobbelina

Developer
Aug 11, 2013
30
6
8
Options is not a problem, lack of them usually are.
There are addons where you don't have a download option.
On those that do, most of them will lock your player until the download is finished, this one wont.
ffmpeg can also download livestreams.
As with all options, maybe the best one is the option not to use it if you don't want to 😊
 
  • Sad
Reactions: capslock

capslock

Guest
Jan 1, 2018
112
16
18
Don't agree. Many of the most popular video-addons (Kodi) do NOT block your player ! You can search AND watch for new/other movies and shows, you can even exit your add-on, BUT staying in Kodi (Main screen) and the downloads will continue and will show pop-usp of the progress. If you want to know the names of these add-ons, please react and I will type them, IF it is allowed on this forum.
 

dobbelina

Developer
Aug 11, 2013
30
6
8
Hi capslock,

If you know of a download addon that works globally, that is on all addons, i would be interested.
For example, a legal addon where downloads isn't a feature is Retrospect, no such option there.
I don't see any other solution than mine to d/l from it.

At the moment I'm working on an update to "FFmpeg Recorder", where you can watch the video
at the same time as you are downloading it.
Works fine in my tests, and no extra bandwidth being consumed, as it's done thru a pipe to ffplay.exe.
Work in progress...
 
  • Like
Reactions: RavRob

dobbelina

Developer
Aug 11, 2013
30
6
8
Major update to FFmpeg Recorder!

Added option to watch the video at the same time as it's being downloaded, this is especially useful on livestreams.
This is done thru a "pipe", so no extra bandwidth is being consumed.
You can also choose what type of container format you prefer by editing the ffmpeg.ini file.
mp4 is the default.
(In this version you also need ffplay.exe in the same folder as ffmpeg.exe, that comes with the ffmpeg package)

Download here: https://github.com/dobbelina/Playground/...der-V2.zip

For those that want to compile it for themselves, here's the source files:
https://github.com/dobbelina/Playground/...20Recorder

Have fun with it! 😁
 

dobbelina

Developer
Aug 11, 2013
30
6
8
To download from the youtube addon, adjust it's settings like this:
Settings=>MPEG-DASH Disable
Settings=>Advanced=>Support alternative player Enable
 

dobbelina

Developer
Aug 11, 2013
30
6
8
Update 2020-12-12 v1.4
  • Added parsing of rtmp links to ffmpeg.

This makes it possible to download from more addons.
If you have installed it before, simply overwrite the old exe with the new one.
Download: https://github.com/dobbelina/Playground/releases/download/v1.4-Windows/FFMPEG_Recorder-v1.4.zip
(In this version you also need ffplay.exe in the same folder as ffmpeg.exe, that comes with the ffmpeg package)

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

For those that want to compile it for themselves, here's the source files:
 
  • Like
Reactions: RavRob

dobbelina

Developer
Aug 11, 2013
30
6
8
Update 2020-12-17 v1.5
  • "Watch Only" option added
  • Added parsing of rtmp links to ffmpeg
  • ffmpeg command editable in ffmpeg.ini
  • Improved detection of Kodi install location
This makes it possible to download from more addons.
If you have installed it before, simply overwrite the old exe with the new one and delete ffmpeg.ini to restart setup.
Download: https://github.com/dobbelina/Playground/releases/download/v1.5-Windows/FFMPEG_Recorder-v1.5.zip

(In this version you also need ffplay.exe in the same folder as ffmpeg.exe, that comes with the ffmpeg package)

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

For those that want to compile it for themselves, here's the source files:
 
  • Like
Reactions: RavRob