Commit graph

70 commits

Author SHA1 Message Date
Daniel Hellstern
dafbe71e8e Moved persistence length to fallback configuration section 2021-05-13 21:12:32 +00:00
Daniel Hellstern
9b28a7b81b Increased default persistence length to 300 seconds 2021-05-13 21:10:09 +00:00
Daniel Hellstern
338d8e7d27 Enabled SSH multiplexing/persistence 2021-05-13 20:51:06 +00:00
Joshua Boniface
3945e1c514 Improve error for missing configs 2021-04-29 14:38:41 -04:00
Joshua Boniface
99dbcae966 Fix bug with list reference 2021-04-29 14:37:06 -04:00
Joshua Boniface
0231ee868e Move SSH command to fallback options
Avoids erroring out with existing configs.

Addresses #10
2021-04-29 14:30:53 -04:00
Joshua Boniface
1a0e9f0d2f Add support for full SSH paths
For cases where the SSH command on the $PATH might not be ideal, allow
the user to override this with a full path in the config.

Addresses #10
2021-04-29 14:29:38 -04:00
Joshua M. Boniface
107092d539 Mention caveat about host configs 2021-04-27 18:47:19 -04:00
Joshua M. Boniface
46b709880f Add some more details about weight 2021-04-27 18:45:09 -04:00
Joshua M. Boniface
e0e5e8a551 Make slight tweaks to README
Minor tweaks to spelling, grammar, example commands, and layout.
2021-04-27 18:40:41 -04:00
Joshua M. Boniface
a4da06af51 Add weight to README and rework localhost section 2021-04-27 18:26:41 -04:00
Joshua M. Boniface
386f179cf1 Add support for weighted hosts
Adds an optional new configuration format under the remote hosts
configuration segment, allowing the specification of a weight in
addition to the host name.

Weights are used to refactor the active "count" of a host in order to
bring it lower by the following logic:

1. If a host's weight is not specified, it is 1.

2. If a host's weight is 1, its "weighted_count" is equal to its
"count".

3. If a host's weight is greater than 1, its "weighted_count" is equal
to the floor division of its real "count" and its "weight".

So for example, if there are 2 hosts with weights 1 and 2, and there is
currently 1 process running against each, the "weighted_count"s would
be:
    host1: 1
    host2: 1//2 = 0
And thus host2 would be considered the "least loaded" host. Then, if
another process started:
    host1: 1
    host2: 2//2 = 1
Resulting in the last host on the list (the first to run a process)
getting the next one, and so on.

This logic should make sense, but I cannot extensively test it.

Closes #8 aspect 1 (aspect 2 is out-of-scope)
2021-04-27 18:17:02 -04:00
Joshua M. Boniface
41ae3190f8 Add logging of running processes on startup 2021-04-27 17:47:06 -04:00
Joshua M. Boniface
711bf6d3b5 Improve command handling, organization, and logs
1. Split the command string into an "rffmpeg_ssh_command" and
"rffmpeg_ffmpeg_command". The first contains the SSH arguments, the
second contains anything run on the remote system. For consistency,
also rename the local command string to "rffmpeg_ffmpeg_command". Join
these commands  commands together as rffmpeg_command before executing on
the remote host.

2. The split is done so that the output log can properly quote the SSH
remote portion with single-quotes, thus avoiding BASH syntax errors on
parenthesis characters which do not seem to cause a problem for
subprocess itself, when manually running the printed command. Helps
address confusion in #10.

3. Reorganize the functions to better reflect their order.

4. Improve logging by removing some superfluous messages and making
others clearer.
2021-04-27 17:32:00 -04:00
Joshua M. Boniface
8c1f63d2d9 Fix stray print statement
This breaks ffprobe's JSON mode
2021-02-11 01:53:01 -05:00
Joshua M. Boniface
d0fd57309f
Merge pull request #9 from crisidev/master 2021-02-10 12:47:28 -05:00
Bigo
e199b5ad68
Remove leftover in config example 2021-02-06 14:55:36 +00:00
Bigo
8fba9d5a7f
Modernize code and logging, simplify localhost handling 2021-02-06 14:53:13 +00:00
Joshua M. Boniface
3ece634417
Merge pull request #7 from markv9401/master
Update rffmpeg.py
2020-11-20 16:55:50 -05:00
markv9401
7e16cb8d65
Update rffmpeg.py
Fixed absent '-hwaccels' special parameter
2020-11-20 20:39:34 +01:00
Joshua M. Boniface
b5ea20e079 Clean up properly on unclean termination 2020-11-20 12:04:31 -05:00
Joshua M. Boniface
a74806722a Include square brackets in quote handler 2020-08-16 20:13:45 -04:00
Joshua M. Boniface
e5f351f5b4 Correct typo in command path 2020-08-12 09:28:22 -04:00
Joshua M. Boniface
dcd08f6713 Support independent fallback commands
Allow specifying separate fallback commands. Not required, and will use
the main commands if not specified.

Closes #2
2020-08-11 23:23:27 -04:00
Joshua M. Boniface
a0cda2755e
Merge pull request #1 from mothlyme/master
Fix a bug where pipe symbols break execution
2020-08-11 23:15:26 -04:00
Joshua M. Boniface
18b7acf562 Fix ordering of statefile and its removal 2020-08-11 20:24:07 -04:00
Joshua M. Boniface
d61a6c5bf3 Clean up filenotfound error and log retcode 2020-08-11 20:20:38 -04:00
52462
9bd28ea079 Fix a bug where pipe symbols break execution
When a pipe symbol is introduced in any ffmpeg flag bash tries to pipe
the output to the second half of the command instead of passing it to
ffmpeg. Therefore it is necessary to escape
2020-07-11 01:42:24 +02:00
Joshua M. Boniface
bd277855e8 Mention hardware accel in local fallback 2020-06-30 18:35:51 -04:00
Joshua M. Boniface
4cc50686ea Add local fallback mode
Fall back to using the local ffmpeg binary (at the same path as the
remote system) if we are unable to reach a remote server. Prevents
rffmpeg from getting stuck if it can find no valid remote servers.
2020-06-30 18:16:39 -04:00
Joshua M. Boniface
1e51fccba4 Refactor rffmpeg to support bad host checking
Allow rffmpeg to determine if a host is "bad", i.e. if the SSH
connection times out or fails, for instance due to an unreachable host
down for maintenance. In such a case, instead of exiting abruptly, we
will mark the host as "bad" in the current state file, and then retry
the whole process, skipping the bad hosts. If other rffmpeg processes
start while the current one is still running, they will also treat the
host as "bad", until the original process ends at which point the
statefile marking it bad will be removed and it will be retried by
future processes. This helps ensure that redundancy of transcode hosts
can actually be achieved, as before if the first host was down, the
process would simply fail, retry, and then fail again if the down host
was first in the list.

This required some major refactoring of the code, including
functionalizing various elements of the process as well as adding an
infinite loop to the main execution in order to keep looping through
hosts after marking one as bad.
2020-06-30 15:22:06 -04:00
Joshua M. Boniface
ded1d6304a Mention redundancy in README 2020-06-30 14:29:59 -04:00
Joshua M. Boniface
28b72c922a Add connection timeout to SSH command 2020-06-30 13:28:09 -04:00
Joshua M. Boniface
809e900588 Fix bad step reference 2020-06-30 12:58:39 -04:00
Joshua M. Boniface
47ac42c45a Remove reference to transcode directory 2020-06-30 12:57:47 -04:00
Joshua M. Boniface
775d2009c4 Mention unrecommended full-network export ACLs 2020-06-30 12:55:51 -04:00
Joshua M. Boniface
b341305ff1 Move Docker caveat up 2020-06-30 12:53:39 -04:00
Joshua M. Boniface
37db1e7a60 Update README to reflect full data path
Without the full path, various alternative uses of ffmpeg (e.g. subtitle
extraction, image extraction) were not working. Recommend exporting the
entire Jellyfin data directory instead and make note that changing path
locations may alter this. Also includes some other tweaks to make this
work (e.g. putting the ssh public key step earlier in the NFS export).
2020-06-30 12:50:49 -04:00
Joshua M. Boniface
4285b9c380 Fix bad path to ffprobe 2020-06-04 12:09:44 -04:00
Joshua M. Boniface
bc14cdf2bd Add LICENSE file 2020-06-04 12:09:44 -04:00
Joshua M. Boniface
34a47c07bd
Use BaseLoader for YAML configuration file 2020-03-24 09:33:42 -04:00
Joshua M. Boniface
e58df24e7f Use consistent logger function naming 2020-02-26 18:26:00 -05:00
Joshua M. Boniface
fe91730d56 Fix typo in error output 2020-02-26 16:35:09 -05:00
Joshua M. Boniface
72a1da23a7 Clean up handling of stdout/stderr/stdin 2020-02-23 23:56:24 -05:00
Joshua M. Boniface
e431c4072b Remove the SSH pseudoterminal
This caused some issues with ffprobe if the remote command ever sends
something to stderr (which then gets sent to stdout locally, causing
format issues).

However, from some testing, this was original though needed to ensure
the 'q' sent to FFmpeg was sent directly over the pipe, but this seems
to not be required (any longer?).
2020-02-23 23:54:12 -05:00
Joshua M. Boniface
f83ab6de74 Major revamp fixing some bugs
From top to bottom:
1. Use dict comprehension instead of try/catch
2. Never output anything to stdout; this breaks Jellyfin's parsing
3. Print more helpful debug messages including PID
4. Fix broken handling of full command paths vs. basenames
5. Use stdout=stdout for ffprobe
6. Only quote arguments that need it (bad shell chars)
2020-02-08 03:22:18 -05:00
Joshua M. Boniface
d664e8c766 Include encoders/decoders strings in stdout fix 2020-02-08 02:19:04 -05:00
Joshua M. Boniface
6a62ae4c83 Revert "Remove bad workaround with stdout"
This reverts commit 750461620e.
2020-02-08 02:17:14 -05:00
Joshua M. Boniface
750461620e Remove bad workaround with stdout
Not needed and breaks encoding parameter selection.
2020-02-08 02:07:15 -05:00
Joshua M. Boniface
48b9741af5 Update README with new setup information 2020-02-08 00:35:43 -05:00