View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 18 posts ] 
Go to page 1, 2  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Wed Sep 19, 2007 12:21 pm 
Offline
Joined: Tue Jan 30, 2007 1:27 am
Posts: 299
Hi,

I'd like to know the best way to set up a recording to automatically re-encode to Xvid and still be viewable from the "Watch Recordings" screen. Right now, I manually run nuvexport from the command line and from within the /myth/tv directory. After it runs, I go back to the "Watch Recordings" screen to delete the original recording. Then I go back to xterm and use myth.rebuilddatabase.pl to import the avi.

I'm doing this to save disk space, buying another drive is not going to happen for a while.

I have tried running a regular transcode job to re-encode to low quality. Well, the video is really poor quality and only about 20% smaller than the original. The avi generated by nuvexport is much better quality and much smaller. If there's a way to get the regular transcode feature to make a better quality and smaller size I'm open to that as well.

I tried the myth2xvid script from the wiki, but I get errors running it. I also saw that f27 includes a myth2xvid script, however, I didn't know that while I was trying to get the script from the wiki to work. I think I hosed the one that got installed with f27.

TIA for your help.

Athlon xp 3200
1gb ram
250gb SATA disk
2x air2pc "ebay special" tuners
GeForce 6200 AGP card 256mb
all recordings OTA ATSC


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 11:40 am 
Offline
Joined: Mon Jan 24, 2005 11:38 pm
Posts: 109
You can tinker with the settings for the transcode profiles to improve the quality. My recordings are 3GB per hour initially, and after transcoding they are about 1.1 GB/hour. I can see a difference in quality, but they still look pretty good.

I can post my transcode settings later when I get home.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 12:50 pm 
Offline
Joined: Tue Jan 30, 2007 1:27 am
Posts: 299
Please post those settings, thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 1:22 pm 
Offline
Joined: Sat Feb 11, 2006 5:26 pm
Posts: 282
Location: Winnipeg - Canada
I'd be interested to see them as well =)

_________________
Currently Running:
Too lazy to update this with my current hardware, I'll redo it during my next install =)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 9:22 pm 
Offline
Joined: Tue Jan 30, 2007 1:27 am
Posts: 299
Back home now, here's some more details. Again, using I created the script using the instructions in the wiki, so if the one cecil included is different or better, please let me know, and please post it or PM it to me.

In mythtv setup, the xvid conversion is set up a job #1, as such:

/usr/local/bin/myth2xvid "%DIR" "%FILE"

and its named Xvid Encoding

In "post recording options" I select the option for job #1 ("Run 'Xvid Encoding' ") to run. The whole job process took about one second to run. I checked the backend log file, and it shows this error:

[....JobQueue: Started "Xvid Encoding"....]
Use of unitialized value in substr at /usr/local/bin/myth2xvid line 80.
Opps, the file %DIR%FILE does not exist
[...JobQueue: Finished "Xvid Encoding"...]

Here is how the script looks from line 80:

Code:
   $start = substr $file[1],0,14;
   if ($debug == 1){ print "$chanid\n$start\n"};
if (! -e $directory."/".$file{
   print "Opps, the file ".$directory.$file." does not exist.\n";
   exit;
}


----------Any thoughts? TIA


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 21, 2007 5:35 am 
Offline
Joined: Mon Aug 29, 2005 4:04 pm
Posts: 729
Location: Philadelphia, PA US
Your job command is wrong, trailing %.
Code:
 /usr/local/bin/myth2xvid "%DIR%" "%FILE%"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 21, 2007 8:42 am 
Offline
Joined: Tue Jan 30, 2007 1:27 am
Posts: 299
Thanks, I missed that. Now I have SQL errors. Attempting to encode an episode of 'This Old House'. This is from the backend log:
Quote:
Use of uninitialized value in substr at /usr/local/bin/myth2xvid line 80.
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server version for the right syntax to use near 'Old House - 2007-9-21, 8-00 AM - Austin Green Remodel Project.nuv AND DATE_FORM' at line 1 at /usr/local/bin/myth2xvid line 96.
Couldn't execute query 'SELECT title, subtitle, description, category, starttime FROM recorded WHERE chanid = This Old House - 2007-9-21, 8-00 AM - Austin Green Remodel Project.nuv AND DATE_FORMAT(starttime, %Y%m%d%%H%i%s') = ': You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server version for the right syntax to use near 'Old House - 2007-9-21, 8-00 AM - Austin Green Remodel Project.nuv AND DATE_FORM' at line 1


Line 96 is part of the PrepSQLRead() subroutine in myth2xvid. Line 96 is the next to last line of this sequence:
Code:
$SQL = "SELECT title, subtitle, description, category, starttime FROM recorded WHERE chanid = $chanid AND DATE_FORMAT(starttime, '%Y%m%d%%H%i%s') = $start";
$statement =  $db_handle->prepare($sql)
    or die;
$statement->execute()    # this is line 96
or die "Couldn't execute query '$sql': $DBI::errstr\n";


Again, TIA for any help here


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 24, 2007 12:56 pm 
Offline
Joined: Wed Jan 10, 2007 10:59 am
Posts: 25
This question is a little off-thread, but I am interested to find out what you eventually get working.

I am currently running an almost dragon 2.0 box (minus the dvd-drive) and was wondering how long it has been taking to do the transcoding. I just found the nuvexport program and gave it a whirl last night with a one hour HD-broadcast capture (about 7G/hr). Using just the default settings after picking the program to transcode to xvid, it started working on it and was only accomplishing 2.04 frames/sec - so an estimated time of about 14 hours. Is that normal or way slow?

Like you I would like to eventually get it to a way where I can reduce the size of most of my recordings but still have them in the Watch Recordings (but being a linuz noob, things take quite a while to figure out for me).

Thanks for any info.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 24, 2007 2:39 pm 
Offline
Joined: Tue Jan 30, 2007 1:27 am
Posts: 299
Currently I don't have anything working. I haven't had the time to dissect the script to try to fix it, and my programming and sql is very rusty anyways.

I've also tried running nuvexport-xvid as a post recording user job. Its a redirect of nuvexport with the xvid option. It runs, and then craps out at the end saying it doesn't have write permissions in the /myth/tv directory.

Regular transcode has been a mixed bag. Some shows compress a lot, some just a little. SD seems to be fine, but I'm hoping for more compressions. One HD show lost the audio.

If I run nuvexport from the command line it works fine. But I have to manually delete the original recording and then import the shrunken recording.

2 fps sounds slow, but, I don't know what kind of processor and RAM you have, if you use XvMC, and I don't know if you run other programs. That will all impact your speed.

My next step will be to view the permissions for /myth/tv, perhaps changing them will allow me to use nuvexport. My other next step is a second hard drive.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 10, 2007 9:39 pm 
Offline
Joined: Sat Dec 24, 2005 11:33 am
Posts: 400
Location: Kitsap Peninsula, Wa., United States
I have been using the new myth2xvid script with pretty fair success.
a 1.5 hr movie SD movie starting at about 2.5 gig finishes in about 2hrs and it is about 900 megs in size
It seems to be using a default bitrate around 1200.

I found the script listed in the changelog for R5F27. it is called Myt2Xvid3
When it runs as a job it places the finished file in /myth/video/archive and creates an rss that is shown in mythweb xvid feeddir.

Only issues I have found thus far, native it gives me the cryptic ChanID_Date_Time.mpg filename.

I made a change in the script that now my names are first word of the pretty directory. Would like to get that fixed.

Also have been playing with the nuvoptions for screen res and bitrate, haven't quite got it yet, but getting closer there.

Anyway thought I would post what I have found see if it is helpful for you.

BTW processing is on my MBE, it is pseudo Dragon 1.1 Athlon 64 3400+ and 1 gig of Ram. I set it for 3 transcode streams but running more than one of these seems to really slow it down.

Running one of these I am seeing about 55 fps.
Right now I am running two jobs at the same time I see 22 and 24 fps or there abouts. I have one running at the default 1200 bitrate. The second one is compressing to about 500 bitrate.

Running 3 of these they all drop to about 10 fps. There is almost always something going on on the box, but that would seem to show me a b/w bottleneck to the discs. although i also saw it using some swap memory too.

Processed video quality is good at 1200 on a 41" SD, the 500 is watchable but a little marginal on the 41" SD but very good on my Pocket PC.

YMMV


Top
 Profile  
 
PostPosted: Mon Oct 15, 2007 9:01 am 
Offline
Joined: Mon Oct 09, 2006 12:18 pm
Posts: 29
mogator88 wrote:
Hi,

I'd like to know the best way to set up a recording to automatically re-encode to Xvid and still be viewable from the "Watch Recordings" screen. Right now, I manually run nuvexport from the command line and from within the /myth/tv directory. After it runs, I go back to the "Watch Recordings" screen to delete the original recording. Then I go back to xterm and use myth.rebuilddatabase.pl to import the avi.


I wanted to do this as well, so this weekend I took the source code for mythtranscode, and modified it to use nuvexport to transcode to xvid instead. I set my new program up as a user job since I still wanted to use mythtranscode. Works good. I can send you the binary or source if you're interested.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 12:52 pm 
Offline
Joined: Tue Jan 30, 2007 1:27 am
Posts: 299
Yes I'd be interested in the binary and the source. This will be really quite useful, thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 5:58 pm 
Offline
Joined: Mon Oct 09, 2006 12:18 pm
Posts: 29
mogator88 wrote:
Yes I'd be interested in the binary and the source. This will be really quite useful, thank you.


I can't see anyway to attach files to posts here so I'll need your email addy to send the binary. To make it I started with the 20-fixes source from svn (revision 14500 but I'm sure it will work with the latest) following cecil's excellent instructions on getting and compiling it that he posted for upgrading to SchedulesDirect. All I had to change was programs/mythtranscode/main.cpp. The one I wrote (copied mostly) is below:

Code:
#include <qapplication.h>
#include <qsqldatabase.h>
#include <qfile.h>
#include <qmap.h>
#include <qfileinfo.h>
#include <qregexp.h>

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>
#include <fstream>
#include <sys/wait.h>
using namespace std;

#include "exitcodes.h"
#include "programinfo.h"
#include "mythcontext.h"
#include "mythdbcon.h"

void CompleteJob(ProgramInfo *pginfo, int status, QString &outfile);

int main(int argc, char *argv[])
{
    QString chanid, starttime, infile, outfile;
    QDateTime startts;
    QMap<QString, QString> settingsOverride;
    QMap<long long, int> deleteMap;
    QMap<long long, long long> posMap;
    srand(time(NULL));

    QApplication a(argc, argv, false);

    if( a.argc() != 2 )
    {
        cerr << "Incorrect number of arguments\n";
        return -1;
    }

    // filename from myth... format chanid_starttime.mpg
    infile = a.argv()[1];

    int base1, base2;

    base1 = infile.find( '_', 0 );
    base2 = infile.find( '.', 0 );
    if( base1 != -1 && base2 != -1 )
    {
        chanid = infile.left( base1 );
       starttime = infile.mid( base1 + 1, base2 - base1 - 1 );
    }
    else
    {
        cerr << "Could not get chanid and starttime\n";
        return -1;
    }

    //  Load the context
    gContext = NULL;
    gContext = new MythContext(MYTH_BINARY_VERSION);
    if (!gContext->Init(false))
    {
        cerr << "Failed to init MythContext, exiting.\n";
        return -1;
    }

    if (!MSqlQuery::testDBConnection())
    {
        cerr << "couldn't open db\n";
        return -1;
    }

    ProgramInfo *pginfo = NULL;

    pginfo = ProgramInfo::GetProgramFromRecorded(chanid, starttime);

    if (!pginfo)
    {
        cerr << "Couldn't find recording for chanid " << chanid << " @ "
             << starttime << endl;
        return -1;
    }

    QString mytmpfile, repStr;
    QRegExp regx( "[*?/\\\\<>]" );
    QFileInfo myfileinfo;
    int fileNum = 1;

    // make the outputfile Title - Subtitle
    if( pginfo->subtitle.isNull() || pginfo->subtitle.isEmpty() )
       outfile = pginfo->title;
    else
        outfile = pginfo->title + " - " + pginfo->subtitle;

    repStr = "'";
    outfile.replace( '"', repStr );
    repStr = " -";
    outfile.replace( ':', repStr );
    repStr = "";
    outfile.replace( regx, repStr );

    // make sure name is unique   
    mytmpfile = "/myth/tv/" + outfile + ".avi";
    myfileinfo.setFile( mytmpfile );
    while( myfileinfo.exists() )
    {
       fileNum++;
       mytmpfile.sprintf( "/myth/tv/%s.%d.avi", outfile.ascii(), fileNum );
       myfileinfo.setFile( mytmpfile );
    }

    if( fileNum > 1 )
        outfile.sprintf( "%s.%d", outfile.ascii(), fileNum );

    int pid, result;
    int status = 0;

   // fork nuvexport
   pid = fork();
   if( pid < 0 )
   {
        cerr << "fork failed\n";
      return -1;
   }
   else if (pid == 0 )
   {
      QString nuvChan, nuvStart, nuvFile;

      nuvChan.sprintf( "--chanid=%s", chanid.ascii() );
      nuvStart.sprintf( "--start=%s", starttime.ascii() );
      nuvFile.sprintf( "--filename=%s", outfile.ascii() );

      // Run nuvexport
      execl( "/usr/local/bin/nuvexport", "nuvexport", nuvChan.ascii(), nuvStart.ascii(),
         "--mode=XviD", "--nice=19", "--cutlist", "--nodenoise", "--multipass",
         "--force-aspect=1.33", "--transcode", "--path=/myth/tv",
         nuvFile.ascii(), (char*) 0 );
      exit(100);
   }
   else
   {
      // Make sure process terminated normally
      if (waitpid(pid, &result, 0) != pid)
      {
            cerr << "waitpid failed\n";
         status = -1;
      }
      else
      {
         if( !WIFEXITED( result ) || WEXITSTATUS( result ) != 0 )
            {
                cerr << "nuvexport errored\n";
            status = -1;
         }
      }
   }

    CompleteJob(pginfo, status, outfile);

    delete pginfo;
    delete gContext;

    return status;
}

void CompleteJob(ProgramInfo *pginfo, int status, QString &outfile)
{
    QString filename = pginfo->GetPlaybackURL();
    QString mybase = outfile + ".avi";
    QString myfilename = "/myth/tv/" + mybase;
    off_t filesize = 0;
    struct stat st;

    if( status == 0 )
    {
        if (stat(myfilename.ascii(), &st) == 0)
            filesize = st.st_size;

        // To save the original file...
        QString oldfile = filename + ".old";

        pginfo->SetRecordBasename(mybase);
        if (filesize > 0)
            pginfo->SetFilesize(filesize);

        if (rename(filename, oldfile) == -1)
            perror(QString("mythtranscode: Error Renaming '%1' to '%2'")
                   .arg(filename).arg(oldfile).ascii());

        int err;

        QFileInfo finfo(oldfile);
        if ((finfo.isSymLink()) &&
            (err = unlink(finfo.readLink().local8Bit())))
        {
             cerr << "Error deleting link\n";
        }

        if ((err = unlink(oldfile.local8Bit())))
            cerr << "Error deleting old file\n";

        oldfile = filename + ".png";
       myfilename += ".png";

        QFile checkFile(oldfile);
        if ((oldfile != myfilename) && (checkFile.exists()))
            rename(oldfile, myfilename);

        MSqlQuery query(MSqlQuery::InitCon());

        query.prepare("DELETE FROM recordedmarkup "
                      "WHERE chanid = :CHANID "
                      "AND starttime = :STARTTIME ");
        query.bindValue(":CHANID", pginfo->chanid);
        query.bindValue(":STARTTIME", pginfo->recstartts);
        query.exec();

        if (!query.isActive())
            MythContext::DBError("Error in mythtranscode", query);

       query.prepare("DELETE FROM recordedseek "
                      "WHERE chanid = :CHANID "
                      "AND starttime = :STARTTIME ");
        query.bindValue(":CHANID", pginfo->chanid);
        query.bindValue(":STARTTIME", pginfo->recstartts);
        query.exec();

        if (!query.isActive())
            MythContext::DBError("Error in mythtranscode", query);

        query.prepare("UPDATE recorded "
                      "SET cutlist = :CUTLIST, bookmark = :BOOKMARK "
                      "WHERE chanid = :CHANID "
                      "AND starttime = :STARTTIME ;");
        query.bindValue(":CUTLIST", "0");
        query.bindValue(":BOOKMARK", "0");
        query.bindValue(":CHANID", pginfo->chanid);
        query.bindValue(":STARTTIME", pginfo->recstartts);
        query.exec();

        if (!query.isActive())
            MythContext::DBError("Error in mythtranscode", query);

        pginfo->SetCommFlagged(COMM_FLAG_NOT_FLAGGED);

    }
    else
    {
        // Not a successful run, so remove the files we created
        unlink(myfilename);
    }
}

/* vim: set expandtab tabstop=4 shiftwidth=4: */


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 17, 2007 8:25 am 
Offline
Joined: Mon Nov 07, 2005 10:09 am
Posts: 153
Dito
Also interested in a How To for best method to reencode to xvid (preferably without commercials) that will be available in normal "watch recordings" menu.

I think it needs to remain in watch recordings... I would like to wait an entire season to begin watching some B series, but need the disk space management to remain active to avoid overfilling my hard drive. Anyway, I don't think i want to move to archive in an unmanaged space that will get full.

The com flag babysit thing is working great to avoid hickups while watching tv... will the xvid encode be a problem... i don't care if it takes an entire season as long as it doesn't slow down the machine during viewing hours.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 6:01 pm 
Offline
Joined: Sat Dec 24, 2005 11:33 am
Posts: 400
Location: Kitsap Peninsula, Wa., United States
so has anyone figured out the steps to make this work?

I am on R5F27.

Where does it place the output file which it seems is now a .avi?

Is it placed back in the /myth/tv directory and as such replaces the .mpg that is the original file?

Thanks!


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ] 
Go to page 1, 2  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 50 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu