Automatically handling split films
Moderator: justinh
Automatically handling split films
A number of the minor channels (random examples: Paramount, ITV4, channel 5), divide feature films with a 5 minute alternative broadcast where you'd normally expect the adverts. This has bitten me many times, the worst case being if I don't notice until the film cuts out half way through when watching it.
I try to remember if it's one of these channels and double check the duration when requesting a record. If it's under 90 mins, I realise it's one of these situations. I address this by checking the end point of the second half, so I know how much significant padding needs to be added at the end of the earlier initial recording so the film is in one file.
However I don't always remember to check. I also believe this should be fixable via some automation so none of us have to do similar again.
I can't see any current threads discussing this but perhaps it's come up years ago. Does any one have any thoughts?
- Damion
I try to remember if it's one of these channels and double check the duration when requesting a record. If it's under 90 mins, I realise it's one of these situations. I address this by checking the end point of the second half, so I know how much significant padding needs to be added at the end of the earlier initial recording so the film is in one file.
However I don't always remember to check. I also believe this should be fixable via some automation so none of us have to do similar again.
I can't see any current threads discussing this but perhaps it's come up years ago. Does any one have any thoughts?
- Damion
Re: Automatically handling split films
I was really intrigued by this and took it as a challenge! A system event at start of recording and a perl script to check the schedule and trigger part 2 of a film does it! Help texts, logging and testing took a bit longer.
I'm running v31 but it should work with 0.28 onward.
Would you (or anyone!) like to beta test the result?
https://pastebin.com/ZEdxjzdJ
Put the script into /usr/local/bin/checkfilm.pl
sudo chmod 755 /usr/local/bin/checkfilm.pl
checkfilm.pl --help
That should tell you how to proceed. Comments invited.
Apart from ITV2, ITV4 and the GREAT (ex Sony) channels, are there any others?
Phil
I'm running v31 but it should work with 0.28 onward.
Would you (or anyone!) like to beta test the result?
https://pastebin.com/ZEdxjzdJ
Put the script into /usr/local/bin/checkfilm.pl
sudo chmod 755 /usr/local/bin/checkfilm.pl
checkfilm.pl --help
That should tell you how to proceed. Comments invited.
Apart from ITV2, ITV4 and the GREAT (ex Sony) channels, are there any others?
Phil
Re: Automatically handling split films
The script is chugging along very happily with my v32 system but I have updated the script:
1. It now matches using title + description rather than just programid because I found a single example where this failed .
2. I revised the pause between requesting a recording and checking that it has been acknowledged.
3. Testing with Mythtv v32 via the new port 6547 showed a compatibility issue. If using this API interface or v33 of Mythtv when released you will also need scan_database.pm to be updated.
Happy viewing!
Phil
1. It now matches using title + description rather than just programid because I found a single example where this failed .
2. I revised the pause between requesting a recording and checking that it has been acknowledged.
3. Testing with Mythtv v32 via the new port 6547 showed a compatibility issue. If using this API interface or v33 of Mythtv when released you will also need scan_database.pm to be updated.
Happy viewing!
Phil
Re: Automatically handling split films
will have a look at this to see if it helps with the new freesat HD itv2,3,4
Re: Automatically handling split films
Hi MozStoss,
The script is fairly lightweight but I am putting a change in my system. In order to reduce system load just as a recording is starting I am now using the 'Recording started Writing' event and putting a delay in it:
Just shout if you have any questions or comments.
Phil
The script is fairly lightweight but I am putting a change in my system. In order to reduce system load just as a recording is starting I am now using the 'Recording started Writing' event and putting a delay in it:
Code: Select all
sleep 20 && /usr/local/bin/checkfilm.pl -v --chanid=%CHANID% >> /var/log/mythtv/checkfilm.log 2>&1
Phil
Re: Automatically handling split films
I have just put this up on the wiki. https://www.mythtv.org/wiki/Split_films
Phil
Phil
Re: Automatically handling split films
I am trying to get this working on my system but I am struggling
So far I have managed to get the checkfilm.pl --help to work
but I can't work out where to put
module scan_database.pm
and what if anything I need to put in it.
So far I have managed to get the checkfilm.pl --help to work
but I can't work out where to put
module scan_database.pm
and what if anything I need to put in it.
Re: Automatically handling split films
Hi. You can put it anywhere in perl path.
You can list perl path with
I put my copy of scan_database.pm in /etc/perl.
Alternatively, put it anywhere you like but change the 'use lib' at the start of scan_database.pm so it can find it. eg
Shout if you have more questions.
Phil
You can list perl path with
Code: Select all
perl -e 'print join ("\n", @INC), "\n"'
Alternatively, put it anywhere you like but change the 'use lib' at the start of scan_database.pm so it can find it. eg
Code: Select all
use lib '/home/phil/utils';
Phil
Re: Automatically handling split films
Thanks. And what is scan_database.pm?
Do I have to create it or download it from somewhere?
Do I have to create it or download it from somewhere?
Re: Automatically handling split films
Look at the setup section in
https://www.mythtv.org/wiki/Split_films#Setup
It points to
https://www.mythtv.org/wiki/Perl_API_examples
The module is at the end. Copy it to a file scan_database.pm
The module provides routines to read the backend and to analyse the data from it.
if you are still stick send me a private message - I'll email you copies.
Phil
https://www.mythtv.org/wiki/Split_films#Setup
It points to
https://www.mythtv.org/wiki/Perl_API_examples
The module is at the end. Copy it to a file scan_database.pm
The module provides routines to read the backend and to analyse the data from it.
if you are still stick send me a private message - I'll email you copies.
Phil
Re: Automatically handling split films
Hi PhilB,
I have amended your script 'checkfilm.pl' to create a file containing the names of the parts of a recording which I then use after recording the last part of the film to concatenate the parts into a single recording, It is my first attempt using perl so the changes may not be written in the most efficient way.
I have a wrapper script, 'rec_start.zsh' that is run from the 'Recording Started Writing' event that starts 'checkfilm_stv.pl' after a delay with some additional parameters and logging.
Once the recordings have finished I have a 'zsh' script, 'concat_film_general.zsh', which is run by the 'Recording Finished' event that does the following:
The work directory is currently set to '/home/tmp' as it is on an SSD which has 40GB of free space.
This is working fine on my system although if I have left mythtv showing the recordings screen, it sometimes shows both halves of the film and I need to move up a level then back to the recordings screen for it to show the film correctly.
Below are the event commands
Recording Started Writing = /usr/local/myth_scripts/rec_start.zsh %FILE% %CHANID% "%TITLE%"
Recording Finished = /usr/local/myth_scripts/concat_film_general.zsh "%TITLE%" >> /usr/local/logs/concat.log 2>&1
The scripts are in a tarball at https://e.pcloud.link/publink/show?code ... xDvLD6Y84V
Stv T
I have amended your script 'checkfilm.pl' to create a file containing the names of the parts of a recording which I then use after recording the last part of the film to concatenate the parts into a single recording, It is my first attempt using perl so the changes may not be written in the most efficient way.
I have a wrapper script, 'rec_start.zsh' that is run from the 'Recording Started Writing' event that starts 'checkfilm_stv.pl' after a delay with some additional parameters and logging.
Once the recordings have finished I have a 'zsh' script, 'concat_film_general.zsh', which is run by the 'Recording Finished' event that does the following:
- Copy all relevant recording files to a work directory
- Concatenate the recording files for the film into a single file using 'mythffmpeg'
- Extract DB information for the last part of the recording
- Replace the original recorded file for the first part of the film with the concatenated file
- Rebuild the seek table for the film
- Run advertisement detection using 'silence.py' or mythcommflag
- Deletes the remaining recorded files and associated DB information using 'delete_rec.pl'
- Update the database entry for the first part of the recording, which is now the full film, with the correct end time and file size
- Create an 'at' job to delete the work directory all work files after 2 days
The work directory is currently set to '/home/tmp' as it is on an SSD which has 40GB of free space.
This is working fine on my system although if I have left mythtv showing the recordings screen, it sometimes shows both halves of the film and I need to move up a level then back to the recordings screen for it to show the film correctly.
Below are the event commands
Recording Started Writing = /usr/local/myth_scripts/rec_start.zsh %FILE% %CHANID% "%TITLE%"
Recording Finished = /usr/local/myth_scripts/concat_film_general.zsh "%TITLE%" >> /usr/local/logs/concat.log 2>&1
The scripts are in a tarball at https://e.pcloud.link/publink/show?code ... xDvLD6Y84V
Stv T