Page 1 of 1

encode job failing

Posted: Sun Feb 16, 2020 11:36 pm
by kasper22
Hi Mythtv people,

I'm trying to use a script I found here viewtopic.php?t=1502. I've fixed a few issues I had with it and feel like I have it almost working, but I'm not a Python dev so I'm not real sure what's happening when the Record() method is called. I just know that it's failing there with
DBData() could not read from database
Here the output from the log
2020-02-16 17:22:39,110:INFO:Started
2020-02-16 17:22:39,111:DEBUG:ffmpeg=/usr/bin/ffmpeg ffprobe=usr/bin/mythffmpeg
2020-02-16 17:22:39,111:DEBUG:ffmpeg=/usr/bin/ffmpeg ffprobe=usr/bin/mythffmpeg
2020-02-16 17:22:39,111:DEBUG:ffmpeg=/usr/bin/ffmpeg ffprobe=usr/bin/mythffmpeg
2020-02-16 17:22:39,111:DEBUG:chanid=10188 starttime=20200209042900
2020-02-16 17:22:39,117:DEBUG:utcstarttime=2020-02-09 04:29:00-06:00
2020-02-16 17:22:39,122:ERROR:DBData() could not read from database
This is coming from around line 110ish where I added a try catch around the Recorded() call to see why it was failing out there

My thought is this might be related to the start time. In the database I'm seeing 2020-02-09 04:29:00, as you can see above the start time has -6:00 at the end. From what I can tell the date object is provided by the MythTV library, so I feel like maybe I'm wrong on my guess, but my Python experience is super minimal.

Thanks for any help

Re: encode job failing

Posted: Wed Feb 19, 2020 5:11 pm
by daraden
Been a while since I've looked at that code. You are correct that it an issue with processing the starttime. I eventually added logic to workaround these issues.

Any specific feature you were looking to use? have a look at It has most of the same features and hopefully none of the bugs.

Re: encode job failing

Posted: Sun Feb 23, 2020 7:36 pm
by dnalorernst
Since you have not provided any version information, I will try to give you a workaround for MythTV v.29 onwards to overcome this issue:

Since Ubuntu 16.04, MythTV v.29 has a bug finding the correct local timezone which was fixed in v30:
See release notes at
section 'Special Notices & Instructions'.

Below script uses the starttime in UTC, provided by MythTV's frontend:
Press 'i' on the Recording screen and you will see something like
"Filename: 3032_20200222191100.ts"
This is the 'chanid' and the 'starttimeutc' the below scripts is asking for:

Code: Select all

#!/usr/bin/env python2
# -*- coding: UTF-8 -*-

import argparse
import sys
import os
from MythTV import MythDB, Recorded, Job, datetime, findfile

def run(jobid=None, chanid=None, starttimeutc=None):
    db = MythDB()
    # Configure chanid and starttime from userjob input
    if jobid:
        job = Job(jobid, db=db)
        rec = Recorded((job.chanid, job.starttime), db = db)
            rectime = datetime.frommythtime(starttimeutc, tz='UTC')
            rec = Recorded((chanid, rectime), db = db)
            print("Cannot find recording '%s_%s' in database." % (chanid, starttimeutc))

    sg = findfile(rec.basename, rec.storagegroup, db=db)
    if sg is None:
        print 'Local access to recording not found.'

    input_file = os.path.join(sg.dirname, rec.basename)
    print("Found '%s' on harddisk." %input_file)
    ### Add Code here for transcoding)

def main():
    parser = argparse.ArgumentParser(
        description='MythTV Transcode and Commercial removal tool.')
    parser.add_argument('--chanid', action='store', type=str, dest='chanid',
                        help='Channel-Id of Recording'
    parser.add_argument('--starttimeutc', action='store', type=int,
                        help='Starttime of recording in utc mythformat (YYYYMMDDhhmmss)'
    parser.add_argument('--jobid', action='store', type=int, dest='jobid',
                        help='Database jobid'
    args = parser.parse_args()
    if args.jobid:
        global job
        job = Job(args.jobid, db=db)
    if args.chanid and args.starttimeutc:
        run(chanid=args.chanid, starttimeutc=args.starttimeutc)
        print('Script must be provided jobid, or chanid and starttimeutc.')

if __name__ == '__main__':

This script will print the location of the file, if found in database.
Please try this script report back.

Re: encode job failing

Posted: Mon Feb 24, 2020 9:13 pm
by kasper22
Hey, thanks for the replies. It's been a really busy week and I hadn't had time to get back to tinkering with mythtv.

So system information
os: kubuntu 18.04
mythtv: v30

My main goal is getting the files to my media server in the same format as my existing system I'm trying to replace. Which looks like:
/media/tv/{show name}/{season}/{show name} - {season number}{episode number}.mkv

hopefully this weekend I"ll have some time to sit down and try out both your suggestions see what gets me where I'm trying to go.