change csv-parser to ffprobe-out-parser

use #\page as the separator for ffprobe 'csv' output
This commit is contained in:
Leo Butler 2020-07-12 15:59:48 -05:00 committed by Leo Butler
parent f37ec47ee1
commit 0839a6be14
1 changed files with 7 additions and 7 deletions

View File

@ -17,6 +17,7 @@
(define mysql-col-sep #\tab)
(define ffmpeg-bin "/usr/local/bin/ffmpeg")
(define ffprobe-bin "/usr/local/bin/ffprobe")
(define ffprobe-separator #\page) ;;
(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))
@ -97,9 +98,8 @@
(map (lambda(x) (dsv-splitter x d)) s))
(error "dsv-splitter" "encountered a not list/string"))))
(define* (csv-parser s #:optional (r #f))
(let ((l (dsv-splitter (delete "" (dsv-splitter s #\newline)) #\page))) ;; #\page =
(if r (read-from-string l) l)))
(define* (ffprobe-out-parser s)
(dsv-splitter (delete "" (dsv-splitter s #\newline)) ffprobe-separator))
(define (k-v-parser s)
(read-from-string (dsv-splitter s #\=)))
(define (make-dotted-alist s)
@ -130,15 +130,15 @@
(define (ffprobe-video-packets file filter-rule)
(let ((frame-info (csv-parser
(shell-command-to-string (simple-format #f "~a -v error -select_streams v:0 -show_entries frame=pkt_pts_time,pkt_pos,pict_type,coded_picture_number,interlaced_frame:side_data=nil -print_format csv=nokey=1:print_section=0:s=' ' -i '~a'" ffprobe-bin file)))))
(let ((frame-info (ffprobe-out-parser
(shell-command-to-string (simple-format #f "~a -v error -select_streams v:0 -show_entries frame=pkt_pts_time,pkt_pos,pict_type,coded_picture_number,interlaced_frame:side_data=nil -print_format csv=nokey=1:print_section=0:s='~a' -i '~a'" ffprobe-bin ffprobe-separator file)))))
(read-from-string (filter filter-rule frame-info))))
(define (ffprobe-i-frames file)
(ffprobe-video-packets file (lambda(l) (string=? "I" (third l)))))
(define (ffprobe-stream-info file)
(let* ((stream-info (shell-command-to-string (simple-format #f "~a -v error -show_streams -print_format csv=nokey=0:s=' ' -i '~a'" ffprobe-bin file))))
(map make-dotted-alist (k-v-parser (csv-parser stream-info)))))
(let* ((stream-info (shell-command-to-string (simple-format #f "~a -v error -show_streams -print_format csv=nokey=0:s='~a' -i '~a'" ffprobe-bin ffprobe-separator file))))
(map make-dotted-alist (k-v-parser (ffprobe-out-parser stream-info)))))
;; (define (mythutil-get-cut/skip-list chanid starttime cut-or-skip)
;; (let ((drop (if (eq? cut-or-skip 'skip) 22 9))