View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 4 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Thu Feb 26, 2009 8:51 pm 
Offline
Joined: Thu Dec 15, 2005 8:15 pm
Posts: 46
Location: Michigan
I've been wracking my brain over this... any means of doing the following? I don't mind doing the work, but a starting point would be good!

Goal: transcode recorded programs into mp4, delete the original mpg2, and have the item remain in the database?

The reasons are many, but mostly I want to save space on the stuff my wife doesn't get to watching for a while, while avoiding nuv's (our front ends are all XBox xbmc's with crappy support for nuv's, such as no seeking).

Here are a couple of approaches I've consider:

#1: Use nuvexport via a script run as a user job, which will put the new file in the same tv directory, then erase the original file. But then how do I update the database to point to the new file? How do I communicate from the user job which is the correct record to update?

#2: Same as number one, but use any other encoder I want to, but the same problem remains: updating the table to point to the new file.

Any ideas? I don't mind rolling my own, and I feel competent to do it, except for identifying the correct table records. Any pointers?

THANKS!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 11:54 pm 
Offline
Joined: Fri Sep 15, 2006 12:16 pm
Posts: 292
You might try this for a test:
Run nuvexport and produce an avi with the same base name as the mpg.
Move the mpg out of the tv directory, move the avi(/mp4/etc) into it and
try to play it. If it doesn't work, just put the mpg back and delete the avi.
If it does work, you will need to play with mythcommflag to get it to redo
the seek table for each file you replace this way.

Another possiblity: Nuvexport them into the /myth/video directory and
watch them as videos. Your front ends will need to mount the back end's
/myth directory to their own /myth directory to be able to watch videos
(using mythvideo) that are actually stored on the back end. This works,
all my systems are set up that way. Sub-option: use a different "explorer
like" tool on the frontends to browse the /myth/video directory and avoid
running a frontend on them?

Final possiblilty: scripting sql commands isn't that bad if you are
conforable with writing scripts. I think that mysql is the command you
are after, but I don't know which table the data is in or the syntax to use
(database is probably mythconverg). I don't know if the standard
recording player can even handle an avi as it normally just handles mpg
or nuv files.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 9:16 am 
Offline
Joined: Mon Feb 16, 2004 7:06 pm
Posts: 309
Location: Toronto
Here is a couple of scripts I have to remove commercials and export to avi as user jobs, they shouldn't be too hard to combine and modify for your purpose
Code:
#!/bin/bash

VIDEOIN=$1
FILENAME=$2
QUERY=/tmp/$FILENAME.sql

# Check to see if there is a cutlist
echo "select cutlist from recorded  WHERE basename = '$FILENAME'" > $QUERY
CUTLISTEXIST=$(mysql -u mythtv -pmythtv -h mb01 mythconverg < $QUERY |grep -e 1 -e 0)

# If no cutlist exist exit,
if [ $CUTLISTEXIST = 0 ]
then
        echo "No Cutlist" >> /var/log/mythtv/mythbackend.log
else
        # Exporting video minus the data in the cutlist
        CUTLIST=$(mythcommflag --getcutlist -f $VIDEOIN | tail -n 1 | awk '{print $2}' | sed 's/,/ /g')
        if [ $? -ne 0 ]; then
                echo "Copying cutlist failed for ${FILENAME} ($VIDEOIN) with error $?"
        exit $?
        fi

        mythtranscode -m -i $VIDEOIN --honorcutlist "$CUTLIST" --showprogress -o "$VIDEOIN.tmp"
        if [ $? -ne 0 ]; then
                echo "Transcoding failed for ($VIDEOIN) with error $?"
        exit $?
        fi

        rm -f "$VIDEOIN"
        rm -f "$VIDEOIN.tmp.map"
        mv "$VIDEOIN.tmp" "$VIDEOIN"
        mythcommflag -f $VIDEOIN --rebuild

        # Removing the cutlist from recording (but leaving commercial flags)
        mythcommflag --clearcutlist -f $VIDEOIN
        ERROR=$?
        if [ $ERROR -eq 0 ]; then
                # Fix the database entry for the file
                echo "UPDATE recorded SET cutlist = 0, commflagged = 0,  filesize = $(ls -l $VIDEOIN | awk '{print $5}') WHERE basename = '$FILENAME';" > $Q$
                mysql mythconverg -h mb01 -u mythtv -pmythtv < $QUERY

        fi
fi

rm -f $QUERY

Code:
#!/bin/bash

VIDEOIN=$1
FILENAME=$2

# Variable used to get name of file on filesystem
FSNAME=$3        #$(echo $VIDEOIN |gawk -F'/' '{ print $4 }')

# Check to see if there is a cutlist
echo "select cutlist from recorded  WHERE basename = '$FSNAME'" > /tmp/query
CUTLISTEXIST=$(mysql -u mythtv -pmythtv -h mb01 mythconverg </tmp/query |grep -e 1 -e 0)
echo "$VIDEOIN ---- $FILENAME ---- $FSNAME ---- $CUTLISTEXIST" > /tmp/variables1
OUTDIR="/myth/video/videos"

# Sanity checking, to make sure everything is in order.
if [ -z "$VIDEOIN" -o -z "$FILENAME.avi" ]; then
        echo "Usage: $0 <PathToVideoFileName> <OutFile> <OutDirectory>"
        exit 5
fi
if [ ! -f "$VIDEOIN" ]; then
        echo "File does not exist: $VIDEOIN" >> /tmp/exportlog 2>&1
        exit 6
fi

# If no culist exist, export to avi directly else cut out commercials then export
if [ $CUTLISTEXIST = 0 ]
then
        ffmpeg -i "$VIDEOIN" -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k "$OUTDIR/$FILENAME.avi" -deinterlace

else
        # Exporting video minus the data in the cutlist
        CUTLIST=$(mythcommflag --getcutlist -f $VIDEOIN | tail -n 1 | awk '{print $2}' | sed 's/,/ /g')
        if [ $? -ne 0 ]; then
                echo "Copying cutlist failed for ${FILENAME} ($VIDEOIN) with error $?" >> /tmp/exportlog 2>&1
        exit $?
        fi

        mythtranscode -m -i $VIDEOIN --honorcutlist "$CUTLIST" --showprogress -o "$OUTDIR/$FILENAME.tmp" >> /tmp/exportlog 2>&1
        if [ $? -ne 0 ]; then
                echo "Transcoding failed for ${FILENAME} ($VIDEOIN) with error $?" >> /tmp/exportlog 2>&1
        exit $?
        fi

        # Now we'll convert the new temp file to avi using ffmpeg
        ffmpeg -i "$OUTDIR/$FILENAME.tmp" -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k "$OUTDIR/$FILENAME.avi" -deinterlace >> /tmp$
        if [ $? -ne 0 ]; then
                echo "Could not covert file to avi. Aborted with error $?" >> /tmp/exportlog 2>&1
        fi
        # Now, regardless of an ffmpeg error we'll remove the interim files
        rm -f "$OUTDIR/$FILENAME.tmp" "$OUTDIR/$FILENAME.tmp.map" >> /tmp/exportlog 2>&1
fi

_________________
KnoppMyth Folding@home
How to setup F@H
F@H Stats Page


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 3:23 pm 
Offline
Joined: Thu Feb 12, 2004 2:54 pm
Posts: 392
Location: Beaumont, CA
You can also do the export to ipod script after each recording. You also need to either modify it or add a new one that moves that new ipod video and overwrites the one in /myth/tv, renaming the new ipod.mp4 file to the 1008_20393939.mpg or whatever. Linux/Mplayer doesn't care about the extension.
Once in a while when my Irblaster doesn't change or it records it off a different card and I have to get a missed show from "other sources", I just rename it (it's normally an avi) to the filename in /myth/tv like 1008_2093903.mpg and it works great. So I know this method will work.

_________________
ASUS A7N266 Micro-ATX Motherboard
Athlon 2200 processor
512K Kingston PC2100 Memory
MicroAtx Case
2 PVR250's w/remote
eVGA e-GeForce mx4000 (64 Ram with Tv/Out (Svideo))
Lite-on DVD cd-rw combo
120 GB Western Digital


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 26 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:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu