revert to slow preset, add code for cleaning up transcoded files
ltbtranscodedtobedeleted table in mythconverg has been added: CREATE TABLE `ltbtranscodedtobedeleted` ( `basename` varchar(256) NOT NULL, `deleted` tinyint(1) NOT NULL DEFAULT '0', `expirydate` datetime NOT NULL, `updatetimestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8
This commit is contained in:
parent
72a5d896ee
commit
3cb6c612e3
@ -18,7 +18,7 @@
|
||||
(define ffmpeg-bin "/usr/bin/ffmpeg")
|
||||
(define ffprobe-bin "/usr/bin/ffprobe")
|
||||
(define ffprobe-separator #\page) ;;
|
||||
(define ffmpeg-transcoding-options "-c:v libx264 -preset veryfast -crf 21 -c:a ac3 -g 60 -keyint_min 30")
|
||||
(define ffmpeg-transcoding-options "-c:v libx264 -preset slow -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")
|
||||
@ -446,7 +446,6 @@
|
||||
(regexp-substitute/global #f " ltbrecordedmarkup" s 'pre " RECORDEDMARKUP" 'post) 'pre " LTBRECORDEDMARKUP" 'post))))))
|
||||
(mythconverg-update-recordedmarkup-table rec sanitize+continue)))
|
||||
|
||||
|
||||
(define* (mythconverg-update-recorded-table rec tr-rec #:optional (mv? #t))
|
||||
(let* ((chanid (recording-chanid rec))
|
||||
(starttime (recording-starttime rec))
|
||||
@ -459,6 +458,49 @@
|
||||
(if mv? (shell-command-to-string (simple-format #f "touch --reference='~a' '~a' && mv '~a' '~a'" input-file input-tr-file input-tr-file recordings-directory)))
|
||||
(mysql-commit (simple-format #f "update recorded set cutlist=0, commflagged=0, bookmark=0, transcoded=1, filesize=~a, basename=\"~a\" where chanid=~a and starttime=~a;" tr-filesize tr-basename chanid starttime))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;; MYTH-CLEAN-RECORDINGS
|
||||
;;;; - on successful transcode, FFMPEG-MYTH0 calls MYTHCONVERG-UPDATE-LTBTRANSCODEDTOBEDELETED
|
||||
;;;; which adds an entry in the sql table ltbtranscodedtobedeleted for the file that was transcoded.
|
||||
;;;; - MYTH-CLEAN-RECORDING-DIRECTORY queries ltbtranscodedtobedeleted for the list of files with an
|
||||
;;;; expiry date before now+n days; it executes SHELL-CMD on that list; if there are no expired files
|
||||
;;;; it returns an empty list, otherwise the list of files
|
||||
;;;; - MYTHCONVERG-UPDATE-DELETED-LTBTRANSCODEDTOBEDELETED takes the list of files from
|
||||
;;;; MYTH-CLEAN-RECORDING-DIRECTORY and sets the deleted flag on each one in the the ltbtranscodedtobedeleted
|
||||
;;;; table.
|
||||
;;;;
|
||||
;;;; Debug/test: shell-cmd <- echo ; continuation <- (lambda(x) x)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(define* (mythconverg-update-ltbtranscodedtobedeleted rec #:optional (continuation mysql-continue))
|
||||
(let* ((basename (if (recording? rec) (recording-basename rec) rec)))
|
||||
(continuation (simple-format #f "insert into ltbtranscodedtobedeleted (basename,deleted,expirydate) values ('~a',0,NOW() + interval 14 day);" basename))))
|
||||
(define* (myth-clean-recording-directory #:optional (expiration-date 1) (shell-cmd "rm -f"))
|
||||
(let* ((safe-cdr (lambda (x) (if (null? x) x (cdr x))))
|
||||
(expired-recordings (map car (safe-cdr (mythconverg-execute+parse (simple-format #f "select basename from ltbtranscodedtobedeleted where deleted=0 and expirydate <= NOW() + interval ~a day;" expiration-date))))))
|
||||
(cond ((null? expired-recordings)
|
||||
(simple-format #t "myth-clean-recording-directory: no transcoded recordings to remove. Done.\n")
|
||||
'())
|
||||
(#t
|
||||
(simple-format #t "myth-clean-recording-directory: removing transcoded files\n~a\n" (string-join expired-recordings ","))
|
||||
(let ((cmd (simple-format #f "~a ~a" shell-cmd (string-join (map (lambda(s) (string-concatenate (list recordings-directory s))) expired-recordings) " "))))
|
||||
(catch 'error-in-shell-command-to-string
|
||||
;; thunk - return expired-recordings list
|
||||
(lambda ()
|
||||
(shell-command-to-string cmd)
|
||||
expired-recordings)
|
||||
;; handler - return empty list in case of error
|
||||
(lambda (key cmd str)
|
||||
'())))))))
|
||||
(define* (mythconverg-update-deleted-ltbtranscodedtobedeleted bnl #:optional (continuation mythconverg-execute))
|
||||
(let ((sql-cmds (map (lambda(f) (simple-format #f "update ltbtranscodedtobedeleted set deleted=1 where basename='~a';" f)) bnl)))
|
||||
(unless (null? bnl)
|
||||
(mysql-start-transaction (string-join sql-cmds "\n"))
|
||||
(mysql-commit "")
|
||||
(continuation mysql-cmd))))
|
||||
(define* (myth-clean-recordings-update-deleted-ltbtranscodedtobedeleted #:optional (expiration-date 1) (shell-cmd "rm -f") (continuation mythconverg-execute))
|
||||
(mythconverg-update-deleted-ltbtranscodedtobedeleted
|
||||
(myth-clean-recording-directory expiration-date shell-cmd) continuation))
|
||||
|
||||
(define (myth-merge-two-recordings chanid starttime)
|
||||
(let* ((rec1+2 (mythconverg-execute+parse (simple-format #f "select basename,title from recorded where chanid=~a and starttime >= ~a order by starttime limit 2;" chanid starttime)))
|
||||
(bn1 (caadr rec1+2))
|
||||
@ -542,6 +584,7 @@
|
||||
(mysql-start-transaction "")
|
||||
(mythconverg-update-recorded-seek-table tr-rec)
|
||||
(mythconverg-update-recordedmarkup-table tr-rec)
|
||||
(mythconverg-update-ltbtranscodedtobedeleted rec)
|
||||
;; mysql-commit in this step
|
||||
(mythconverg-update-recorded-table rec tr-rec)
|
||||
(mythconverg-execute mysql-cmd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user