summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode27
1 files changed, 23 insertions, 4 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 4cc654e..8f43b52 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -21,6 +21,7 @@
# http://diveintohtml5.org/video.html
# http://camendesign.com/code/video_for_everybody
# http://www.streaminglearningcenter.com/articles/so-you-want-to-get-to-know-h264.html
+# http://www.penguinproducer.com/2012/01/ladspa-noise-removal/
#
# Possible flashplayers:
# http://www.internetmarketingnotes.com/2010/07/free-embeddable-flash-video-flv-players-for-commercial-use/
@@ -63,7 +64,11 @@ html favoring open formats with optional non-JavaScript Flash fallback.
(default: medium)
--webmpreset WebM target preset: 360p 720p 720p50_60 etc.
(default: profile-related or none)
- --audio Audio style: music speech silence
+ --audio Audio style:
+ channels compress normalize limit
+ music max 2 X X
+ speech 1 X X X
+ silence 0
(default: none - use input channel count)
--stem Stem of output filenames, optionally with path
(default: basename of last input file)
@@ -247,11 +252,17 @@ bitrate_aac=96
case "$audio" in
music)
channels=2
+ # limit (i.e. avoid peaks "clipping")
+ _melt_audio_filters="-filter ladspa.1077"
;;
speech)
channels=1
bitrate_vorbis=48
bitrate_aac=64
+ # expand and compress (i.e. lower volume on silent and loud passages)
+ _melt_audio_filters_early="-filter ladspa.1075 -filter ladspa.1073"
+ # limit (i.e. avoid peaks "clipping")
+ _melt_audio_filters="-filter ladspa.1077"
;;
silence)
channels=0
@@ -277,12 +288,20 @@ _melt_audio="${channels:+ac=$channels}"
_melt_vorbis="$_melt_audio acodec=libvorbis ab=$(($channels*$bitrate_vorbis))k"
_melt_aac="$_melt_audio acodec=aac ab=$(($channels*$bitrate_aac))k"
+# resolve EBU R128 audio normalizing
+# TODO: normalize each infile separately when xml fed as infile keeps sync
+if [ -n "$melt_recent" ] && [ -n "$channels" ]; then
+ $melt -group $_melt_in $infiles -group $_melt_audio_filters_early -filter loudness -consumer xml:$stem.xml $_melt_audio video_off=1 all=1
+ _melt_loudness="$(perl -ne 'm!<property name="results">([^<]+)</property>! and print $1' $stem.xml)"
+ rm $stem.xml
+fi
+
## Theora/Vorbis/Ogg
-$melt -group $_melt_in $infiles -group $filters -consumer avformat:"$stem.ogv" $_melt_ogg $_melt_vorbis $_melt_out
+$melt -group $_melt_in $infiles -group ${channels:+$_melt_audio_filters_early${_melt_loudness:+ -filter loudness results="$_melt_loudness"} $_melt_audio_filters }$filters -consumer avformat:"$stem.ogv" $_melt_ogg $_melt_vorbis $_melt_out
## H.264/AAC/MP4
[ -z "$bitrate" ] || $melt -group $_melt_in $infiles -group $filters -consumer avformat:/dev/null properties=x264-medium-pass1 $_melt_h264 $_melt_out
-$melt -group $_melt_in $infiles -group $filters -consumer avformat:"$stem.mp4" ${bitrate:+pass=2} $_melt_h264 $_melt_aac $_melt_out
+$melt -group $_melt_in $infiles -group ${channels:+$_melt_audio_filters_early${_melt_loudness:+ -filter loudness results="$_melt_loudness"} $_melt_audio_filters }$filters -consumer avformat:"$stem.mp4" ${bitrate:+pass=2} $_melt_h264 $_melt_aac $_melt_out
if [ -z "$melt_recent" ]; then
mv "$stem.mp4" "$stem.mp4"~
qt-faststart "$stem.mp4"~ "$stem.mp4"
@@ -291,7 +310,7 @@ fi
## VP8/Vorbis/WebM
# TODO: use two-pass when supported by melt
-$melt -group $_melt_in $infiles -group $filters -consumer avformat:"$stem.webm" properties=webm $_melt_webm $_melt_vorbis $_melt_out
+$melt -group $_melt_in $infiles -group ${channels:+$_melt_audio_filters_early${_melt_loudness:+ -filter loudness results="$_melt_loudness"} $_melt_audio_filters }$filters -consumer avformat:"$stem.webm" properties=webm $_melt_webm $_melt_vorbis $_melt_out
## JPEG preview
ffmpegthumbnailer -s0 -i "$stem.mp4" -o "$stem.jpg"