diff --git a/webif/html/browse/audio/execute.jim b/webif/html/browse/audio/execute.jim
index 77cbbdd..d219700 100755
--- a/webif/html/browse/audio/execute.jim
+++ b/webif/html/browse/audio/execute.jim
@@ -18,27 +18,12 @@ set base [file rootname $rfile]
set shname [file tail $base]
puts "Processing $shname"
-set cmd [list ffmpeg -y -benchmark -v 0 -i "$rfile" -f mp3 -vn]
+set slow [[settings] audiomp3]
-if {![[settings] audiomp3]} {
- lappend cmd -acodec copy
-}
-lappend cmd "${base}.mp3"
-
-#puts "$cmd"
set token [system startop -multiple mp3 $rfile]
-puts [exec {*}$cmd]
+puts [$ts mkmp3 $slow]
system endop $token
-if {[system pkginst id3v2]} {
- puts [exec /mod/bin/id3v2 \
- --song "[$ts get title]" \
- --comment "[$ts get synopsis]" \
- --album "[$ts get channel_name]" \
- --year "[clock format [$ts get start] -format {%Y}]" \
- "${base}.mp3"]
-}
-
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
puts "Time taken: $xtime"
diff --git a/webif/html/browse/ffmpeg.jim b/webif/html/browse/ffmpeg.jim
index 0d59f2d..f9f2ae3 100755
--- a/webif/html/browse/ffmpeg.jim
+++ b/webif/html/browse/ffmpeg.jim
@@ -5,10 +5,6 @@ source /mod/webif/lib/setup
httpheader
-if {[file exists /mod/bin/ffmpeg]} {
- set file [cgi_get file]
- puts [exec /mod/webif/lib/bin/ffmpeg -i $file]
-} else {
- puts "Install ffmpeg package for more information..."
-}
+set file [cgi_get file]
+puts [exec /mod/bin/ffprobe -hide_banner $file]
diff --git a/webif/html/browse/mp3.jim b/webif/html/browse/mp3.jim
index aadb43b..4b15926 100755
--- a/webif/html/browse/mp3.jim
+++ b/webif/html/browse/mp3.jim
@@ -13,7 +13,8 @@ foreach file [readdir $dir] {
if {[file extension $file] ne ".mp3"} continue
if {[catch {
- set lines [exec ffprobe -v error -show_streams "$dir/$file"]
+ set lines [exec ffprobe -hide_banner -v error \
+ -show_streams "$dir/$file"]
}]} continue
foreach line $lines {
diff --git a/webif/html/browse/mpg/execute.jim b/webif/html/browse/mpg/execute.jim
index 3eef8df..3b6bc6e 100755
--- a/webif/html/browse/mpg/execute.jim
+++ b/webif/html/browse/mpg/execute.jim
@@ -14,15 +14,8 @@ set len [$ts duration 1]
set xstart [clock milliseconds]
-set base [file rootname $rfile]
-set shname [file tail $base]
-puts "Processing $shname"
-
set token [system startop -multiple mpg $rfile]
-puts [exec /mod/bin/ffmpeg -y -benchmark -v 0 \
- -i $rfile \
- -map 0:0 -map 0:1 \
- -vcodec copy -acodec copy "${base}.mpg"]
+$ts mkmpg
system endop $token
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
diff --git a/webif/lib/auto/plugin/mp3/queue.hook b/webif/lib/auto/plugin/mp3/queue.hook
index 701f465..47d6499 100644
--- a/webif/lib/auto/plugin/mp3/queue.hook
+++ b/webif/lib/auto/plugin/mp3/queue.hook
@@ -17,11 +17,6 @@ proc ::mp3::dequeue {q ts} {
return {"DEFER" "Not decrypted"}
}
- if {[$ts get definition] eq "HD"} {
- # Cannot extract a useful MP3 from a HD recording.
- return {"FAILED" "Cannot process high-definition recording"}
- }
-
if {[::auto::inuse $ts]} {
return {"DEFER" "Recording in use"}
}
@@ -38,34 +33,16 @@ proc ::mp3::dequeue {q ts} {
log " MP3: $file" 0
log " Converting... [$::auto::settings \
audiomp3descr $mp3mode]" 0
- if {[catch {
- set cmd [list nice -n 19 \
- /mod/bin/ffmpeg -y -benchmark -v 0 -i "$file.ts" \
- -f mp3 -vn]
- if {!$mp3mode} { lappend cmd -acodec copy }
- lappend cmd "$tmp/mp3.mp3"
- foreach line [split [exec {*}$cmd] "\n"] {
- log [string trim $line] 0
- }
- } msg]} {
+ if {[catch {set msg [$ts mkmp3 $mp3mode "$tmp/mp3"]} msg]} {
system notify "$file - auto-mp3 - error $msg."
system endop mp3
return [list "FAILED" $msg]
}
- if {[system pkginst id3v2]} {
- catch {
- log [exec /mod/bin/id3v2 \
- --song "[$ts get title]" \
- --comment "[$ts get synopsis]" \
- --album "[$ts get channel_name]" \
- --year "[clock format [$ts get start] -format {%Y}]" \
- "$tmp/mp3.mp3"] 0
- }
+ foreach line [split $msg "\n"] {
+ log [string trim $line] 0
}
- # Move the MP3 into the local directory
- file rename $tmp/mp3.mp3 $file.mp3
set summary [::auto::endclock [$ts size]]
system endop mp3
diff --git a/webif/lib/auto/plugin/mpg/queue.hook b/webif/lib/auto/plugin/mpg/queue.hook
index db9bce2..d360423 100644
--- a/webif/lib/auto/plugin/mpg/queue.hook
+++ b/webif/lib/auto/plugin/mpg/queue.hook
@@ -30,22 +30,17 @@ proc ::mpg::dequeue {q ts} {
log " MPG: $file" 0
log " Converting..." 0
- if {[catch {
- foreach line [split \
- [exec nice -n 19 /mod/bin/ffmpeg -y -benchmark -v 0 \
- -i $file.ts \
- -map 0:0 -map 0:1 \
- -vcodec copy -acodec copy $tmp/mpg.mpg] "\n"] {
- log $line 0
- }
- } msg]} {
- system notify "$file - auto-mpg - error $msg."
- system endop mpg
- return [list "FAILED" $msg]
- }
- # Move the MPG into the local directory
- file rename $tmp/mpg.mpg $file.mpg
+ if {[catch {set msg [$ts mkmpg "$tmp/mpg"]} msg]} {
+ system notify "$file - auto-mpg - error $msg."
+ system endop mpg
+ return [list "FAILED" $msg]
+ }
+
+ foreach line [split $msg "\n"] {
+ log [string trim $line] 0
+ }
+
set summary [::auto::endclock [$ts size]]
system endop mpg
diff --git a/webif/lib/bin/ffmpeg b/webif/lib/bin/ffmpeg
deleted file mode 100755
index 934cbe3..0000000
--- a/webif/lib/bin/ffmpeg
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-if [ -x /mod/bin/ffprobe ]; then
- /mod/bin/ffprobe "$@" 2>&1 | sed '
- 1,10d
- '
-else
- /mod/bin/ffmpeg "$@" 2>&1 | sed '
- 1,8d
- $d
- '
-fi
-exit 0
-
diff --git a/webif/lib/ts.class b/webif/lib/ts.class
index ce166e8..a012fe6 100644
--- a/webif/lib/ts.class
+++ b/webif/lib/ts.class
@@ -364,9 +364,82 @@ ts method mkthm {{offset 0}} {
exec /bin/echo -n " " >> $bfile.thm~
file rename -force $bfile.thm~ $bfile.thm
file tdelete $bfile.bmp
+ $self setflag thumbnail
return 1
}
+# From MontysEvilTwin
+# - https://hummy.tv/forum/threads/7787/page-2#post-106826
+# ffmpeg -i "File 1.ts" -c:a mp3 -b:a 128k "File 1.mp3"
+# ffmpeg -i "File 1.ts" -c:a copy "File 1.mp2"
+# ffmpeg -i "File 1.ts" -c:a copy "File 1.loas"
+ts method mkmp3 {{slow false} {tmp ""} {v 0} {br 128}} {
+ set rfile [file rootname $file]
+
+ if {$slow} {
+ set opts [list -c:a mp3 -b:a ${br}k]
+ set ext mp3
+ } else {
+ set opts [list -c:a copy]
+ if {$definition eq "HD"} {
+ set ext loas
+ } else {
+ set ext mp2
+ }
+ }
+ set cmd [list /mod/bin/ffmpeg \
+ -y -benchmark -vn -v $v \
+ -i $file {*}$opts \
+ ]
+
+ if {$tmp eq ""} {
+ lappend cmd "${rfile}.$ext"
+ } else {
+ lappend cmd "$tmp.$ext"
+ }
+
+ set output [exec {*}$cmd]
+
+ if {$tmp ne ""} {
+ file rename "$tmp.$ext" "${rfile}.mp3"
+ } elseif {$ext ne "mp3"} {
+ file rename "${rfile}.$ext" "${rfile}.mp3"
+ }
+
+ exec /mod/bin/id3v2 \
+ --song $title \
+ --comment $synopsis \
+ --album $channel_name \
+ --year "[clock format $start -format {%Y}]" \
+ "${rfile}.mp3"
+
+ return $output
+}
+
+ts method mkmpg {{tmp ""}} {
+ set rfile [file rootname $file]
+
+ set cmd [list /mod/bin/ffmpeg \
+ -y -benchmark -v 0 \
+ -i $file \
+ -map 0:0 -map 0:1 \
+ -vcodec copy -acodec copy]
+
+ if {$tmp eq ""} {
+ lappend cmd "${rfile}.mpg"
+ } else {
+ lappend cmd "$tmp.mpg"
+ }
+
+ set output [exec {*}$cmd]
+
+ if {$tmp ne ""} {
+ file rename "$tmp.mpg" "${rfile}.mpg"
+ }
+
+ return $output
+}
+
proc {ts renamegroup} {from to} {
global tsgroup