7 You need at least 512MB RAM to run the script.
8 Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC.
9 You need to follow all the following steps even if you are on a PeerTube server (including cloning the git repository in a different directory than your production installation because the scripts utilize non-production dependencies).
13 Install the [PeerTube dependencies](/support/doc/dependencies.md) except PostgreSQL and Redis.
17 Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server):
20 git clone https://github.com/Chocobozzz/PeerTube.git
21 CLONE="$(pwd)/PeerTube"
25 Install dependencies and build CLI tools:
28 NOCLIENT=1 yarn install --pure-lockfile
34 The wrapper provides a convenient interface to the following scripts.
35 You can access it as `peertube` via an alias in your `.bashrc` like `alias peertube="cd /your/peertube/directory/ && node ./dist/server/tools/peertube.js"` (you have to keep the `cd` command):
38 Usage: peertube [command] [options]
42 -v, --version output the version number
43 -h, --help output usage information
47 auth [action] register your accounts on remote instances to use them with other commands
48 upload|up upload a video
49 import-videos|import import a video from a streaming platform
50 plugins|p [action] manage instance plugins
51 redundancy|r [action] manage video redundancies
52 help [cmd] display help for [cmd]
55 The wrapper can keep track of instances you have an account on. We limit to one account per instance for now.
58 peertube auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD'
60 ┌──────────────────────────────┬──────────────────────────────┐
62 ├──────────────────────────────┼──────────────────────────────┤
63 │ 'PEERTUBE_URL' │ 'PEERTUBE_USER' │
64 └──────────────────────────────┴──────────────────────────────┘
67 You can now use that account to upload videos without feeding the same parameters again.
70 peertube up <videoFile>
73 To list, install, uninstall dynamically plugins/themes of an instance:
77 peertube plugins install --path /local/plugin/path
78 peertube plugins install --npm-name peertube-plugin-myplugin
79 peertube plugins uninstall --npm-name peertube-plugin-myplugin
82 #### peertube-import-videos.js
84 You can use this script to import videos from all [supported sites of youtube-dl](https://rg3.github.io/youtube-dl/supportedsites.html) into PeerTube.
85 Be sure you own the videos or have the author's authorization to do so.
88 node dist/server/tools/peertube-import-videos.js \
91 --password 'PEERTUBE_PASSWORD' \
92 --target-url 'TARGET_URL'
95 * `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re
96 * `PEERTUBE_USER` : your PeerTube account where videos will be uploaded
97 * `PEERTUBE_PASSWORD` : password of your PeerTube account (if `--password PEERTUBE_PASSWORD` is omitted, you will be prompted for it)
98 * `TARGET_URL` : the target url you want to import. Examples:
100 * Channel: https://www.youtube.com/channel/ChannelId
101 * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName
102 * Video https://www.youtube.com/watch?v=blabla
103 * Vimeo: https://vimeo.com/xxxxxx
104 * Dailymotion: https://www.dailymotion.com/xxxxx
106 The script will get all public videos from Youtube, download them and upload to PeerTube.
107 Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection...
109 Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
111 **NB**: If you want to synchronize a Youtube channel to your PeerTube instance (ensure you have the agreement from the author),
112 you can add a [crontab rule](https://help.ubuntu.com/community/CronHowto) (or an equivalent of your OS) and insert
113 these rules (ensure to customize them to your needs):
116 # Update youtube-dl every day at midnight
117 0 0 * * * /usr/bin/npm rebuild youtube-dl --prefix /PATH/TO/PEERTUBE/
119 # Synchronize the YT channel every sunday at 22:00 all the videos published since last monday included
120 0 22 * * 0 /usr/bin/node /PATH/TO/PEERTUBE/dist/server/tools/peertube-import-videos.js -u '__PEERTUBE_URL__' -U '__USER__' --password '__PASSWORD__' --target-url 'https://www.youtube.com/channel/___CHANNEL__' --since $(date --date="-6 days" +\%Y-\%m-\%d)
123 Also you may want to subscribe to the PeerTube channel in order to manually check the synchronization is successful.
125 #### peertube-upload.js
127 You can use this script to import videos directly from the CLI.
129 Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
133 node dist/server/tools/peertube-upload.js --help
136 #### peertube-plugins.js
138 Install/update/uninstall or list local or NPM PeerTube plugins:
142 node dist/server/tools/peertube-plugins.js --help
143 node dist/server/tools/peertube-plugins.js list --help
144 node dist/server/tools/peertube-plugins.js install --help
145 node dist/server/tools/peertube-plugins.js update --help
146 node dist/server/tools/peertube-plugins.js uninstall --help
148 node dist/server/tools/peertube-plugins.js install --path /my/plugin/path
149 node dist/server/tools/peertube-plugins.js install --npm-name peertube-theme-example
152 #### peertube-redundancy.js
154 Manage (list/add/remove) video redundancies:
156 To list your videos that are duplicated by remote instances:
159 node dist/server/tools/peertube.js redundancy list-remote-redundancies
162 To list remote videos that your instance duplicated:
165 node dist/server/tools/peertube.js redundancy list-my-redundancies
168 To duplicate a specific video in your redundancy system:
171 node dist/server/tools/peertube.js redundancy add --video 823
174 To remove a video redundancy:
177 node dist/server/tools/peertube.js redundancy remove --video 823
182 These scripts should be run on the server, in `peertube-latest` directory.
186 To parse PeerTube last log file:
190 cd /var/www/peertube/peertube-latest
191 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info
193 # Docker installation
194 cd /var/www/peertube-docker
195 docker-compose exec -u peertube peertube npm run parse-log -- --level info
198 `--level` is optional and could be `info`/`warn`/`error`
200 You can also remove SQL or HTTP logs using `--not-tags` (PeerTube >= 3.2):
204 cd /var/www/peertube/peertube-latest
205 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level debug --not-tags http sql
207 # Docker installation
208 cd /var/www/peertube-docker
209 docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql
212 ### regenerate-thumbnails.js
216 Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes:
220 cd /var/www/peertube/peertube-latest
221 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails
223 # Docker installation
224 cd /var/www/peertube-docker
225 docker-compose exec -u peertube peertube npm run regenerate-thumbnails
228 ### create-import-video-file-job.js
230 You can use this script to import a video file to replace an already uploaded file or to add a new webtorrent resolution to a video. PeerTube needs to be running.
231 You can then create a transcoding job using the web interface if you need to optimize your file or create an HLS version of it.
235 cd /var/www/peertube/peertube-latest
236 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
238 # Docker installation
239 cd /var/www/peertube-docker
240 docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
243 ### create-move-video-storage-job.js
247 Use this script to move all video files or a specific video file to object storage.
251 cd /var/www/peertube/peertube-latest
252 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
254 # Docker installation
255 cd /var/www/peertube-docker
256 docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
259 The script can also move all video files that are not already in object storage:
263 cd /var/www/peertube/peertube-latest
264 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage --all-videos
266 # Docker installation
267 cd /var/www/peertube-docker
268 docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos
274 Some transcoded videos or shutdown at a bad time can leave some unused files on your storage.
275 Stop PeerTube and delete these files (a confirmation will be demanded first):
278 cd /var/www/peertube/peertube-latest
279 sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
285 **Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.**
286 If you started PeerTube with a domain, and then changed it you will have
287 invalid torrent files and invalid URLs in your database. To fix this, you have
288 to run the command below (keep in mind your follower instances will NOT update their URLs).
292 cd /var/www/peertube/peertube-latest
293 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
295 # Docker installation
296 cd /var/www/peertube-docker
297 docker-compose exec -u peertube peertube npm run update-host
300 ### reset-password.js
302 To reset a user password from CLI, run:
306 cd /var/www/peertube/peertube-latest
307 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u target_username
309 # Docker installation
310 cd /var/www/peertube-docker
311 docker-compose exec -u peertube peertube npm run reset-password -- -u target_username
315 ### plugin install/uninstall
317 The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running.
318 If PeerTube is running, you need to restart it for the changes to take effect (whereas with `peertube plugins` CLI, plugins/themes are dynamically loaded on the server).
320 To install/update a plugin or a theme from the disk:
323 cd /var/www/peertube/peertube-latest
324 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --plugin-path /local/plugin/path
326 # Docker installation
327 cd /var/www/peertube-docker
328 docker-compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path
334 cd /var/www/peertube/peertube-latest
335 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --npm-name peertube-plugin-myplugin
337 # Docker installation
338 cd /var/www/peertube-docker
339 docker-compose exec -u peertube peertube npm run plugin:install -- --npm-name peertube-plugin-myplugin
342 To uninstall a plugin or a theme:
345 cd /var/www/peertube/peertube-latest
346 sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
348 # Docker installation
349 cd /var/www/peertube-docker
350 docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
355 PeerTube >= 5.2 supports VOD or Live transcoding by a remote PeerTube runner.
361 sudo npm install -g @peertube/peertube-runner
366 The runner uses env paths like `~/.config`, `~/.cache` and `~/.local/share` directories to store runner configuration or temporary files.
368 Multiple PeerTube runners can run on the same OS by using the `--id` CLI option (each runner uses its own config/tmp directories):
371 peertube-runner [commands] --id instance-1
372 peertube-runner [commands] --id instance-2
373 peertube-runner [commands] --id instance-3
376 You can change the runner configuration (jobs concurrency, ffmpeg threads/nice etc) by editing `~/.config/peertube-runner-nodejs/[id]/config.toml`.
380 You need to run the runner in server mode first so it can run transcoding jobs of registered PeerTube instances:
383 peertube-runner server
388 Then, you can register the runner on a new PeerTube instance so the runner can process its transcoding job:
391 peertube-runner register --url http://peertube.example.com --registration-token ptrrt-... --runner-name my-runner-name
394 The runner will then use a websocket connection with the PeerTube instance to be notified about new available transcoding jobs.
398 To unregister a PeerTube instance:
401 peertube-runner unregister --url http://peertube.example.com --runner-name my-runner-name
404 ### List registered instances
407 peertube-runner list-registered