Project

General

Profile

Tvheadend post recording scripts » History » Version 2

Hein Rigolo, 2010-03-07 12:51
possible commflag script

1 2 Hein Rigolo
= Post recording scripts =
2 1 Hein Rigolo
On this page you can find a number of (proposed) post recording scripts that you could use to process the Tvheadend recording.
3 2 Hein Rigolo
4
== post recording basics ==
5
In the DVR configuration page you can specify a "Post-processor command". This can be reference to any program/script that tvheadend will run after the recording has been finished. In order to make it possible to give the program/script some information about the recording that has just finished you can use some variables to build up the actual command that will be executed. Here is the extract from the Tvheadend help page:
6
7
'''Post-processor command'''
8
 Command to run after finishing a recording. The command will be run in background and is executed even if a recording is aborted or an error occurred. Use the %e error formatting string to check for errors, the error string is empty if recording finished successfully.
9
10
{{{
11
    Support format strings:
12
    Format	Description	Example value
13
    %f	Full path to recording	/home/user/Videos/News.mkv
14
    %b	Basename of recording	News.mkv
15
    %c	Channel name	BBC world
16
    %C	Who created this recording	user
17
    %t	Program title	News
18
    %c	Program description	News and stories...
19
    %S	Start time stamp of recording, UNIX epoch	1224421200
20
    %E	Stop time stamp of recording, UNIX epoch	1224426600
21
}}}
22
23
Example usage: /path/to/ffmpeg -i %f -vcodec libx264 -acodec copy "/path/with white space/%b"
24
You need to use quotes or escape white spaces if you want white spaces in an argument. 
25
26
== possible uses ==
27
The post-processor command can be used to start anything, like in the example about you could use it to transcode the recording to an other format, or anything else you would like. Here we will list some options. Some are complete scripts, others are just thoughts that need to be worked out further.
28
29
=== Commercial Flagging ===
30
[[span('''Work in Progress''', style=color: red; font-size: 100%)]]
31
32
Tvheadend does not have it's own build in commercial flagging tool. This was done on purpose because Tvheadend wants to concentrate on the recording and streaming side and leave any post processing to applications/scripts that are much better at this. This means that in order to detect and possibly remove commercials you will need to use seperate programs.
33
34
One of the most known commercial detection programs is the one included with MythTV: mythcommflag. This program can also be run as a stand alone tool to detect and flag commercials in valid MPEG files. At the moment Tvheadend does not record directly to MPEG, but it is using the MKV container.
35
36
A possible be script would do these steps:
37
 * recode the MKV to a MPEG-TS file
38
 * Flag commercials to a cut list
39
 * remove the suggested frames from the mpeg-ts
40
41
flagging the commercials using mythcommflag could possibly be done like this:
42
 * use the "--file filename" option to point to the mpeg file
43
 * use the "--gencutlist" option to generate a new cutlist for the file
44
 * use the undocumented "--outputfile FILE " option to dump the cutlist to a file
45
46
removing the commercials from the file could posisbly be done by mythtranscode. This needs further investigation, because it looks that mythtranscode does not have an option to specify a cutlist from a file. It expects the cutlist to be available in the mythtv database (which we do not have ofcourse)