Transcoding/Export userjob script
Moderator: Forum Moderators
Transcoding/Export userjob script
Hello All,
Longtime Myth user, new to the mailing list and forums. I am looking for suggestions for a userjob script to transcode recordings to remove commercials, rename the file to something user friendly, and then either using ffmpeg or handbrake to format the file for mobile devices.
From my extensive Google searching, this site has the best example for what I want to accomplish, http://tech.surveypoint.com/posts/mytht ... handbrake/. I am not dead set on using this specific users script but I cannot get it to work and would appreciate any help to make it work. I am open to any other solutions to accomplish the same end result.
I found a forum post related to this script here:
viewtopic.php?f=36&t=80
My modified script:
http://dpaste.com/146YRSC
Thanks for any help & suggestions.
Longtime Myth user, new to the mailing list and forums. I am looking for suggestions for a userjob script to transcode recordings to remove commercials, rename the file to something user friendly, and then either using ffmpeg or handbrake to format the file for mobile devices.
From my extensive Google searching, this site has the best example for what I want to accomplish, http://tech.surveypoint.com/posts/mytht ... handbrake/. I am not dead set on using this specific users script but I cannot get it to work and would appreciate any help to make it work. I am open to any other solutions to accomplish the same end result.
I found a forum post related to this script here:
viewtopic.php?f=36&t=80
My modified script:
http://dpaste.com/146YRSC
Thanks for any help & suggestions.
Re: Transcoding/Export userjob script
First of all what are your goals. Just making sure. Do you want to keep the original file or delete it. The more you tell me the quicker I can make changes to my current script. The script you have gave me trouble as well so I cobbled this one (from another) and added features I wanted like sending a done message to my GrowlforWindows instance and updating along the way what step the script was at in mythweb status block. You'll see that it also moves the original file to a new group called "Seen", the name can be changed in the script. I do that in-case I need to re-edit it, else on my system it doesn't take long before it gets deleted in the "Deleted" group. As is you'll need to install "mediainfo", but if you cut out the if-then-else statement and make everything down to one specific handbrake profile, you could do away with that.
Link to my current script: http://pastebin.com/Mtru4tPh
I'll check back later if you need any help altering it. I'm off to watch Brooklyn Nine-Nine and the CSI series finale.
Link to my current script: http://pastebin.com/Mtru4tPh
I'll check back later if you need any help altering it. I'm off to watch Brooklyn Nine-Nine and the CSI series finale.
Re: Transcoding/Export userjob script
My goal is pretty much exactly like the Handbrake script I linked to. I don't need it to delete the original recording. Just honor the auto comm flags or the manual edits and then transcode it to a mobile device friendly format in a new folder.
Re: Transcoding/Export userjob script
Ok, I'll try to work on that before I go to sleep tonight.
Re: Transcoding/Export userjob script
FYI,
I don't think I have a need for an autodetect profile as mentioned in line 29. I've been able to manually run the command below:
mythtranscode --chanid 2591 --starttime 20150926000000 -m --honorcutlist -o /media/vol-01/Minority.Report.s01.e01.mpg
And then manually run Handbrake on the file from above with the "Android Tablet" profile with good results.
I don't think I have a need for an autodetect profile as mentioned in line 29. I've been able to manually run the command below:
mythtranscode --chanid 2591 --starttime 20150926000000 -m --honorcutlist -o /media/vol-01/Minority.Report.s01.e01.mpg
And then manually run Handbrake on the file from above with the "Android Tablet" profile with good results.
Re: Transcoding/Export userjob script
Still have a little work to do, tomorrow morning, plus trying a few test runs. Could you tell me which of these two files exist on your system. Will allow me to remove extra code.
Code: Select all
MYTHCONFIGFILE="/etc/mythtv/config.xml"
MYCONFIGFILE="/home/mythtv/.mythtv/config.xml"Re: Transcoding/Export userjob script
They are both present.
Please, don't kill yourself over this, take your time. I really appreciate your help.
Please, don't kill yourself over this, take your time. I really appreciate your help.
Re: Transcoding/Export userjob script
To make all things equal, could you give me the command line you used for HandBrakeCLI that you liked? I have a couple of shows I don't record set to record tonight for testing. It's no problem. Trust me this is way easier now, especially since I over did mine. Figuring out that gencutlist wasn't doing what I thought it was supposed to do, nearly drove me insane. Couldn't figure out why it wasn't using my edits.
Spent several days on that one.
Re: Transcoding/Export userjob script
Here is the line from the original script. It DOES NOT work on 14.04 though. I believe the issue is with the audio portion, specifically the "copy:aac". I believe this has something to do with the state of ffmpeg. Please modify as needed. For my manual testing I mentioned earlier, I was using Handbrake GUI on a different system.
/usr/bin/HandBrakeCLI -i "$OUTDIR/$TVFILENAME.mpg" -o "$OUTDIR/$TVTITLE-$1_$2.m4v" --audio 1 --aencoder copy:aac --audio-fallback faac --audio-copy-mask aac --preset="Universal"
Here is the output from HandbrakeCli:
/usr/bin/HandBrakeCLI -i "Minority.Report.s01.e01.mpg" -o "Minority.Report.s01.e01.m4v" --audio 1 --aencoder copy:aac --audio-fallback faac --audio-copy-mask aac --preset="Universal"
/usr/bin/HandBrakeCLI -i "$OUTDIR/$TVFILENAME.mpg" -o "$OUTDIR/$TVTITLE-$1_$2.m4v" --audio 1 --aencoder copy:aac --audio-fallback faac --audio-copy-mask aac --preset="Universal"
Here is the output from HandbrakeCli:
/usr/bin/HandBrakeCLI -i "Minority.Report.s01.e01.mpg" -o "Minority.Report.s01.e01.m4v" --audio 1 --aencoder copy:aac --audio-fallback faac --audio-copy-mask aac --preset="Universal"
Code: Select all
[07:38:59] hb_init: starting libhb thread
HandBrake rev5474 (2014032499) - Linux x86_64 - http://handbrake.fr
4 CPUs detected
Opening Minority.Report.s01.e01.mpg...
[07:38:59] hb_scan: path=Minority.Report.s01.e01.mpg, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening Minority.Report.s01.e01.mpg/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening Minority.Report.s01.e01.mpg/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(Minority.Report.s01.e01.mpg) failed
[07:38:59] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 4.2.1
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[07:38:59] dvd: not a dvd - trying as a stream/file instead
[07:38:59] file is MPEG Program Stream
[07:39:00] Probing 1 unknown stream
[07:39:00] Probe: Found stream mpeg2video. stream id 0xe0-0x0
[07:39:00] Found the following streams
[07:39:00] Video Streams :
[07:39:00] 0xe0-0x0 type MPEG2 (0x2)
[07:39:00] Audio Streams :
[07:39:00] 0xbd-0x80 type AC3 (0x81)
[07:39:00] 0xbd-0x81 type AC3 (0x81)
[07:39:00] Subtitle Streams :
[07:39:00] Other Streams :
[07:39:00] stream id 0xbd (type 0x81 substream 0x80) audio 0x8000bd
[07:39:00] stream id 0xbd (type 0x81 substream 0x81) audio 0x8100bd
[07:39:01] scan: decoding previews for title 1
[07:39:01] scan: audio 0x8000bd: AC-3, rate=48000Hz, bitrate=448000 Unknown (AC3) (5.1 ch)
[07:39:01] scan: audio 0x8100bd: AC-3, rate=48000Hz, bitrate=192000 Unknown (AC3) (2.0 ch)
Scanning title 1 of 1, preview 7, 70.00 %[07:39:02] scan: 10 previews, 1280x720, 59.940 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[07:39:02] stream: 82 good frames, 0 errors (0%)
[07:39:02] libhb: scan thread found 1 valid title(s)
+ title 1:
+ stream: Minority.Report.s01.e01.mpg
+ duration: 00:43:05
+ size: 1280x720, pixel aspect: 1/1, display aspect: 1.78, 59.940 fps
+ autocrop: 0/0/0/0
+ chapters:
+ 1: cells 0->0, 0 blocks, duration 00:43:05
+ audio tracks:
+ 1, Unknown (AC3) (5.1 ch) (iso639-2: und), 48000Hz, 448000bps
+ 2, Unknown (AC3) (2.0 ch) (iso639-2: und), 48000Hz, 192000bps
+ subtitle tracks:
+ 1, Closed Captions (iso639-2: und) (Text)(CC)
+ Using preset: Universal
AAC Passthru requested and input codec is not AAC for track 1, using AAC encoder
[07:39:02] 1 job(s) to process
[07:39:02] starting job
[07:39:02] sync: expecting 154977 video frames
ERROR: Invalid audio codec: 0x100
[07:39:02] render: 0 frames output, 0 dropped and 0 duped for CFR/PFR
[07:39:02] render: lost time: 0 (0 frames)
[07:39:02] render: gained time: 0 (0 frames) (0 not accounted for)
[07:39:02] libhb: work result = 0
Encode done!
HandBrake has exited.
Re: Transcoding/Export userjob script
It did that to me on 12.04.5 LTS(with HWE for extended support), using the PPA for handbrake. Those options override the profile, so they may not be compatible with the current version. Only using profile "Android Tablet" worked. This should work: http://pastebin.com/zSMzFHBj
It takes the cutlist. Then handbrake converts using the "Android Tablet" profile. Then it deletes the .tmp commercial edit file(you want this as they will just pile up on your disk needlessly), leaving only the original recording/cutlist. All you need to do is setup TV/Movie userjobs using the provided template. Obviously change your storage path in the userjob line
It takes the cutlist. Then handbrake converts using the "Android Tablet" profile. Then it deletes the .tmp commercial edit file(you want this as they will just pile up on your disk needlessly), leaving only the original recording/cutlist. All you need to do is setup TV/Movie userjobs using the provided template. Obviously change your storage path in the userjob line
Re: Transcoding/Export userjob script
I have 2 storage directories for recordings on 2 hard disks, anything special I need to do with the script?
Re: Transcoding/Export userjob script
I'm also on the #mythtv-users IRC channel.
Re: Transcoding/Export userjob script
It doesn't take storage directories into account. I use Kodi, and Filebot to make their names Kodi centric name wise and to organize the TV shows into proper directories and Movies the same. I only use MythTV to record/edit. Which you can see from the "incoming" in the directory name in the example userscript jobs.
Re: Transcoding/Export userjob script
So /media/Store/incoming/TV/%TITLE% in your script is the folder for the finished file?
Re: Transcoding/Export userjob script
Hello All,
Just recently upgraded from .27 to .28 and I noticed my user job transcode script no longer is working. If anyone can point me in the right direction I would appreciate any help.
Userjob cammand:
Transcode script mythexport.sh:
Just recently upgraded from .27 to .28 and I noticed my user job transcode script no longer is working. If anyone can point me in the right direction I would appreciate any help.
Userjob cammand:
Code: Select all
/usr/bin//mythexport.sh "%DIR%/%FILE%" "/media/vol-01/MythExports/%TITLE% - S%SEASON%E%EPISODE% - %SUBTITLE%.m4v" "%CHANID%" "%STARTTIMEUTC%"Code: Select all
#!/bin/bash
# First does a lossless MPEG-2(honorcutlist) transcode removing commericals(cutlist must be manually made before
# hand), then rebuilds the seek table. It then uses handbrakecli to transcode the mpg to a m4a(H264, AAC).
#
# Loosely based on mythtv-transcode-h264 version 0.8 by Defcronyke Webmaster.
#
# Arguments
# $1 must be the directory/file to be transcoded.
# $2 must be the output directory / file name. The directory must be writeable by the mythtv user
# $3 must be chanid
# $4 must be starttime
# the full userjob command in mythtv-setup should look like this:
#
# Format for TV:
# /home/kevin/Dropbox/scripts/mythexport.sh "%DIR%/%FILE%" "/media/vol-01/MythExports/%TITLE% - S%SEASON%E%EPISODE% - %SUBTITLE%.m4v" "%CHANID%" "%STARTTIMEUTC%"
#
# Format for MOVIES:
# /usr/bin/mythtv-transcode-mkv.sh "%DIR%/%FILE%" "/media/Store/incoming/Movies/%TITLE%.m4v" "%CHANID%" "%STARTTIMEUTC%"
#
#
# MythTV Install Prefix (make sure this matches with the directory where MythTV is installed)
#
INSTALLPREFIX="/usr/bin"
# don't change these
#
MYPID=$$
DIRNAME=`dirname "$1"`
DIRNAME2=`dirname "$2"`
BASENAME=`echo "$2" | awk -F/ '{print $NF}' | sed 's/://g' | sed 's/?//g' | sed 's/\?//g' | sed 's/*//g' | sed 's/!//g' | sed s/"'"/""/g`
CHAN="$3"
START="$4"
#Get mythtv database information
#
DBSERVER=""
DBUSER=""
DBNAME=""
DBPASS=""
#Try getting mythtv database information from existent files in the following order
#
MYTHCONFIGFILE="/etc/mythtv/config.xml"
MYCONFIGFILE="/home/mythtv/.mythtv/config.xml"
if [ -f "$MYTHCONFIGFILE" ]; then
DBSERVER="$( grep -E -m 1 -o "<DBHostName>(.*)</DBHostName>" $MYTHCONFIGFILE | sed -e 's,.*<DBHostName>\([^<]*\)</DBHostName>.*,\1,g' )"
DBUSER="$( grep -E -m 1 -o "<DBUserName>(.*)</DBUserName>" $MYTHCONFIGFILE | sed -e 's,.*<DBUserName>\([^<]*\)</DBUserName>.*,\1,g' )"
DBNAME="$( grep -E -m 1 -o "<DBName>(.*)</DBName>" $MYTHCONFIGFILE | sed -e 's,.*<DBName>\([^<]*\)</DBName>.*,\1,g' )"
DBPASS="$( grep -E -m 1 -o "<DBPassword>(.*)</DBPassword>" $MYTHCONFIGFILE | sed -e 's,.*<DBPassword>\([^<]*\)</DBPassword>.*,\1,g' )"
elif [ -f "$MYCONFIGFILE" ]; then
DBSERVER="$( grep -E -m 1 -o "<Host>(.*)</Host>" $MYCONFIGFILE | sed -e 's,.*<Host>\([^<]*\)</Host>.*,\1,g' )"
DBUSER="$( grep -E -m 1 -o "<UserName>(.*)</UserName>" $MYCONFIGFILE | sed -e 's,.*<UserName>\([^<]*\)</UserName>.*,\1,g' )"
DBNAME="$( grep -E -m 1 -o "<DatabaseName>(.*)</DatabaseName>" $MYCONFIGFILE | sed -e 's,.*<DatabaseName>\([^<]*\)</DatabaseName>.*,\1,g' )"
DBPASS="$( grep -E -m 1 -o "<Password>(.*)</Password>" $MYCONFIGFILE | sed -e 's,.*<Password>\([^<]*\)</Password>.*,\1,g' )"
fi
# play nice with other processes
#
renice 19 $MYPID
ionice -c 3 -p $MYPID
# remove commercials and rebuild index
#
$INSTALLPREFIX/mythtranscode --chanid "$3" --starttime "$4" -m --honorcutlist -p autodetect
# Rebuild Index
#
$INSTALLPREFIX/mythcommflag --file "$1" --rebuild
# Handbrake
#
$INSTALLPREFIX/HandBrakeCLI -i "$1".tmp -o "$DIRNAME2/$BASENAME" --preset="Android Tablet"
# Delete the TEMPORARY commercial edited file
cd $DIRNAME
rm "$1".tmp