[mythtv-users] Commercial flagging not working after transcoding with a user job

Jeremy Jones jeremy.dwain.jones at gmail.com
Mon Sep 5 23:00:20 UTC 2011


On Sun, Sep 4, 2011 at 11:56 PM, Raymond Wagner <raymond at wagnerrp.com>wrote:

>  On 9/4/2011 22:48, Jeremy Jones wrote:
>
>
>
> On Sat, Sep 3, 2011 at 12:22 AM, Raymond Wagner <raymond at wagnerrp.com>wrote:
>
>> On 9/3/2011 01:14, Jeremy Jones wrote:
>> >
>> > After re-looking at thwarting backend settings, I already have it set
>> > to run transcoding jobs first. I checked the backend logs and the
>> > commercial detection is running first anyway, so I assume that setting
>> > just does not apply if you are transcoding with a user job.  Is that
>> > correct?
>> >
>>
>>  That setting only functions with the specific commflag and transcode
>> tasks.  If you want it to work with your custom transcoding task, you
>> must replace the command for mythtranscode in mythtv-setup.
>>
>>
> I notice the command in setup for transcode is simply, "Mythtranscode".  Do
> I need put my entire user job command there complete with the, " --chanid
> %CHANID% --starttime %STARTTIME%" parameters that follow the command, or
> will these be passed automatically, and only the script file path/name is
> needed?
>
>
> The value  'mythtranscode' is a special key that tells the jobqueue to run
> that application with all the command line arguments needed to make it
> work.  If using anything other than 'mythtranscode', you must populate
> whatever arguments you need.
>
>
That makes sense. Thanks.


>
> Also, as I stated in my original post, I used your, "Transcode wrapper
> stub" from the wiki to build my script.  Can you tell me what the line,
> "flush_commskip = True" Does?  Am I deleting the commercial flags with
> this?  Would changing that to false fix my problem, or do I need to leave it
> as true and swap the transcode command like you said above?
>
>
> All that does is flush the stored commercial skip data out of the
> recordedmarkup table.  That data is keyed off the frame number, so if your
> transcoding command cuts out frames, resamples, performs IVTC or
> deinterlacing, that data will no longer be valid and should be deleted.
>
>
> That's what I thought after I read Mike's post, but I wanted to make sure.



So now: I added my entire user job command to the transcode command and
ticked for autotranscode and transcode before comm flag.  Then I unchecked
my userjob, and let Mythbackend do its stuff.  On my backend logs I get
this:

     2011-09-05 17:07:53.291 transcode: Transcode Errored: "Between the
Lions": Autodetect (exit status 0, job status was "Starting")
     2011-09-05 17:07:53.308 JobQueue: Transcode Errored: "Between the
Lions": Autodetect (exit status 0, job status was "Starting")

But, the file was transcoded (or at least it appears to have worked).  What
gives?


Extra info if needed:
---------------------------------------
Transcode command:
/home/jeremy/DVDtranscode.py --chanid %CHANID% --starttime %STARTTIME%

-------------------------------------------
contents of DVDtranscode.py:
#!/usr/bin/env python

from MythTV import Job, Recorded, System, MythDB, findfile, MythError

from optparse import OptionParser
import sys
import os

################################
#### adjust these as needed ####
transcoder = '/usr/bin/ffmpeg'
flush_commskip = True
build_seektable = True
################################

def runjob(jobid=None, chanid=None, starttime=None):
    db = MythDB()
    if jobid:
        job = Job(jobid, db=db)
        chanid = job.chanid
        starttime = job.starttime
    rec = Recorded((chanid, starttime), db=db)

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

    infile = os.path.join(sg.dirname, rec.basename)
    outfile = '%s.mpeg' % infile.rsplit('.',1)[0]
    #### list of segments to be cut
    # rec.markup.gencutlist()
    #### list of segments to keep
    # rec.markup.genuncutlist()

    task = System(path=transcoder, db=db)
    try:
##############################################
#### probably need to adjust this one too ####
        output = task('-y -i "%s" -target ntsc-dvd -async 1 "%s" 2>
/dev/null ' % (infile, outfile) )
##############################################
    except MythError, e:
        print 'Command failed with output:\n%s' % e.stderr
        sys.exit(e.returncode)

    rec.basename = os.path.basename(outfile)
    os.remove(infile)
    rec.filesize = os.path.getsize(outfile)
    rec.transcoded = 1
    rec.seek.clean()

    if flush_commskip:
        for index,mark in reversed(list(enumerate(rec.markup))):
            if mark.type in (rec.markup.MARK_COMM_START,
rec.markup.MARK_COMM_END):
                del rec.markup[index]
        rec.bookmark = 0
        rec.cutlist = 0
        rec.markup.commit()

    if build_seektable:
        task = System(path='mythcommflag')
        task.command('--chanid %s' % chanid,
                     '--starttime %s' % starttime,
                     '--rebuild')

    rec.update()


def main():
    parser = OptionParser(usage="usage: %prog [options] [jobid]")

    parser.add_option('--chanid', action='store', type='int', dest='chanid',
            help='Use chanid for manual operation')
    parser.add_option('--starttime', action='store', type='int',
dest='starttime',
            help='Use starttime for manual operation')
    parser.add_option('-v', '--verbose', action='store', type='string',
dest='verbose',
            help='Verbosity level')

    opts, args = parser.parse_args()

    if opts.verbose:
        if opts.verbose == 'help':
            print MythLog.helptext
            sys.exit(0)
        MythLog._setlevel(opts.verbose)

    if len(args) == 1:
        runjob(jobid=args[0])
    elif opts.chanid and opts.starttime:
        runjob(chanid=opts.chanid, starttime=opts.starttime)
    else:
        print 'Script must be provided jobid, or chanid and starttime.'
        sys.exit(1)

if __name__ == '__main__':
    main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20110905/879eafd7/attachment.html 


More information about the mythtv-users mailing list