encode job failing

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
kasper22
Newcomer
Posts: 2
Joined: Sun Feb 16, 2020 11:14 pm
United States of America

encode job failing

Post 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
Last edited by Steve Goodey on Mon Feb 17, 2020 2:07 am, edited 1 time in total.
Reason: url amended.
daraden
Senior
Posts: 175
Joined: Tue Feb 23, 2016 7:33 am
United States of America

Re: encode job failing

Post 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 https://github.com/daraden/transcode-myth. It has most of the same features and hopefully none of the bugs.
User avatar
dnalorernst
Developer
Posts: 105
Joined: Mon Feb 17, 2020 8:03 pm
Austria

Re: encode job failing

Post 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 https://www.mythtv.org/wiki/Release_Notes_-_30
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)
    else:
        try:
            rectime = datetime.frommythtime(starttimeutc, tz='UTC')
            rec = Recorded((chanid, rectime), db = db)
        except:
            print("Cannot find recording '%s_%s' in database." % (chanid, starttimeutc))
            sys.exit(1)

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

    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,
                        dest='starttimeutc',
                        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)
        run(jobid=args.jobid)
        sys.exit(0)
    if args.chanid and args.starttimeutc:
        run(chanid=args.chanid, starttimeutc=args.starttimeutc)
        sys.exit(0)
    else:
        print('Script must be provided jobid, or chanid and starttimeutc.')

if __name__ == '__main__':
    main()

This script will print the location of the file, if found in database.
Please try this script report back.
kasper22
Newcomer
Posts: 2
Joined: Sun Feb 16, 2020 11:14 pm
United States of America

Re: encode job failing

Post 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.

Thanks
Post Reply