[mythtv-users] cutlist parsing help needed.
Raymond Wagner
raymond at wagnerrp.com
Sat Nov 27 17:43:01 UTC 2010
On 11/27/2010 10:36, belcampo wrote:
> I have an almost 6 hour Manual recording, several programs, with
> following cutlist.
> 0-14893,50509-63697,131041-142393,226249-238405,276157-287713,364849-375277,393373-532455
>
>
> I would like to have 6 individual recordings of them.
>
> 1st resulting file I should get with:
> ffmpeg -ss (14893*.04) -vframes (50509-14893) -i source.mpg 'several
> options' program1.mp4
>
> 2nd
> ffmpeg -ss (63697*.04) -vframes (131041-63697) -i source.mpg 'several
> options' program2.mp4
For example, a python implementation:
##### starts here #####
from MythTV import Recorded, System, findfile, MythLog
import sys
# pull command line inputs
if len(sys.argv) < 3:
raise Exception('CHANID and STARTTIME must be provided on the
command line')
rec = Recorded(sys.argv[1:3])
MythLog._setlevel('important,general,file')
# estimate framerate
rate = rec.seek[-1].mark/float((rec.endtime-rec.starttime).seconds)
rates = [24000./1001.,25,30000./1001.,50,60000./1001.]
diff = [abs(f-rate) for f in rates]
rate = rates[diff.index(min(diff))]
# start transcoding
sg = findfile(rec.basename,rec.storagegroup)
ffmpeg = System(path='/usr/bin/ffmpeg')
ffmpeg.append('-i', sg.dirname+rec.basename)
ffmpeg.append('#### all your other options here ####')
for start,stop in rec.markup.getcutlist():
ffmpeg.command('-ss',start/rate,
'-vframes',stop-start,
'split_rec.%d.mp4' % start)
if ffmpeg.returncode:
print 'FFMPEG failed with error code: %d' % ffmpeg.returncode
print ffmpeg.stderrr
sys.exit(1)
More information about the mythtv-users
mailing list