diff --git a/ffmpeg-myth.scm b/ffmpeg-myth.scm index 62aa054..e6e13b5 100755 --- a/ffmpeg-myth.scm +++ b/ffmpeg-myth.scm @@ -18,7 +18,8 @@ (define ffmpeg-bin "/usr/bin/ffmpeg") (define ffprobe-bin "/usr/bin/ffprobe") (define ffprobe-separator #\page) ;; -(define ffmpeg-transcoding-options "-preset slow -crf 21 -c:a ac3 -g 60 -keyint_min 30") +(define ffmpeg-transcoding-options "-c:v libx264 -preset veryfast -crf 21 -c:a ac3 -g 60 -keyint_min 30") +(define ffmpeg-transcoded-file-muxer 'mpegts) ;; 'matroska (define recordings-directory "/var/lib/mythtv/recordings") (define working-directory "/mnt/lvraid5/ffmpeg-cut-list.d") (define mythtv-recorded-table->metadata-list '(chanid starttime endtime title subtitle description season episode recordid seriesid programid inetref previouslyshown originalairdate)) @@ -389,20 +390,22 @@ (lambda(x) (set! i (+ 1 i)) (string-join (map (lambda(f) (simple-format #f f i)) concat-template) " ")) output-template))) -(define* (ffmpeg-split+transcode-recording rec #:optional (max-streams 4)) +(define* (ffmpeg-split+transcode-recording rec #:optional (max-streams 4) + (transcoded-file-ending transcoded-file-ending) + (ffmpeg-transcoded-file-muxer ffmpeg-transcoded-file-muxer)) (let* ((basename (recording-basename rec)) (rootname+ext (string-split basename #\.)) - (rootname (car rootname+ext)) (ext (cadr rootname+ext)) + (rootname (car rootname+ext)) (in-file (simple-format #f "~a/~a" recordings-directory basename)) (out-file (simple-format #f "~a/~a.~a" working-directory rootname transcoded-file-ending)) - (m-d (mythtv-recorded-table->metadata rec)) + (m-d (if (eq? ffmpeg-transcoded-file-muxer 'matroska) (mythtv-recorded-table->metadata rec) "")) (cut-times (myth-convert-i-frame-indices-to-times (recording-retain-list rec) (recording-i-frame-info rec))) (seek-fn (lambda(c) (simple-format #f " -ss ~a -t ~a -i '~a'" (car c) (- (cdr c) (car c)) in-file))) (concat-info (ffmpeg-outstreams-templates rec max-streams)) (instreams (string-join (map (car concat-info) cut-times) " ")) (outstreams (cdr concat-info)) (mappings (map (lambda (x) (simple-format #f " -map '~a'" x)) outstreams)) - (cmd (simple-format #f "~a -y ~a -filter_complex '~a concat=n=~a:v=1:a=~a ~a' -preset slow -crf 21 -c:a ac3 -g 60 -keyint_min 30 ~a ~a ~a" ffmpeg-bin (string-join (map seek-fn cut-times)) instreams (length cut-times) (- (length outstreams) 1) (string-join outstreams) (string-join mappings) m-d out-file))) + (cmd (simple-format #f "~a -y ~a -filter_complex '~a concat=n=~a:v=1:a=~a ~a' ~a ~a ~a -f ~a ~a" ffmpeg-bin (string-join (map seek-fn cut-times)) instreams (length cut-times) (- (length outstreams) 1) (string-join outstreams) ffmpeg-transcoding-options (string-join mappings) m-d ffmpeg-transcoded-file-muxer out-file))) (shell-command-to-string cmd) cmd))