forked from j62/ctbrec
1
0
Fork 0
ctbrec/client/src/main/resources/html/docs/PostProcessing.md

3.3 KiB

Post-Processing

The post-processing gives you the possibility to run any script / program after a recording has finished. You can use that to convert the files to another format, create preview images, rename / move the file etc. There are example scripts included in the distribution zip (pp.bat, pp.ps1, pp.sh). See also the comments in those files.

Local Recording

If you are using the local recording mode, you can set the post-processing script / program on the settings tab under Recorder -> Post-Processing. ctbrec will call the selected script after the recording has finished with the following parameters:

  1. directory (absolute path)
  2. file (absolute path)
  3. model name
  4. site name
  5. unixtime (seconds since 1/1/1970 00:00)
Remote Recording (server)

If you are running the server and want to run a post-processing script, you have to edit the configuration file. Just set the absolute path to an executable script / program for the setting postProcessing. Since the recordings look a bit different for the server, the parameters, which are passed to the script are a bit different, too:

  1. parent directory (absolute path)
  2. directory of the recording (absolute path) - this directory contains the segments and the playlist
  3. model name
  4. site name
  5. unixtime (seconds since 1/1/1970 00:00)
Example Scripts

Server script by @uo0Evx99@mastodon.cloud used on a Raspberry Pi 3 B+ to convert recordigns to mp4 files:

#!/bin/bash

#
#Explanation of the code: It first takes all the .ts files (because sadly the server
#doesnt save the video in 1 big file instead) and creates one big .ts file in the same
#folder called "all".
#
#Then it uses ffmpeg to re-encode the .ts file to .mp4 while just copying the audio
#and video codec to reduce the encoding time. It also uses the -movflags faststart so
#the video can be played back instantly when viewing online (e.g. with Plex)
#That re-encoded file is being stored in the folder /home/pi/hdd/plex/"MODEL NAME"/ 
#with the name "CURRENT TIME"-"MODEL NAME".mp4
#
#Then it deletes the folder in which all the .ts files were, because we dont need
#those anymore as we have our .mp4 file re-encoded already and ready to use/stream.
#
#This script has been used on a Raspberry Pi 3 B+
#

# $1 directory (absolute path)
# $2 file (absolute path)
# $3 model name
# $4 site name
# $5 unixtime

# format unixtime to human readable
TIME=$(date --date="@$5" +%H:%M_%d.%m.%Y)

cat $2/*.ts > "$2/all.ts" && ffmpeg -i "$2/all.ts" -acodec copy -vcodec copy -movflags faststart "/home/pi/hdd/plex/$3/$TIME-$3.mp4" && rm -r "$2"

Windows script by @electrotek@mastodon.cloud. Automatically converts .ts files into mkv after recording ended, factors in multiple/split files. Assumes mkvtoolnix installed in path stated

@echo off	

set directory=%1
set file=%2
set model=%3
set site=%4
set unixtime=%5

FOR %%f in (%directory%\*.ts) do (
    "C:\Program Files\MKVToolNix\mkvmerge.exe" -o "%directory%\%%~nf.mkv" --title "%model%" "%directory%\%%~nf.ts"
    del "%directory%\%%~nf.ts"
)
Video Tutorials