From 97c92555b8a7bf8c53c9f41fd23dcb70b55c7c8a Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Mon, 2 Sep 2013 14:27:24 -0400 Subject: update *encode.sh, add opus support --- aencode.sh | 13 +++--- vencode.sh | 12 ++--- www/js/api.js | 19 +++++++- www/js/play.js | 140 ++++++++++++++++++++++++++++----------------------------- 4 files changed, 101 insertions(+), 83 deletions(-) diff --git a/aencode.sh b/aencode.sh index 63ad918..af101be 100755 --- a/aencode.sh +++ b/aencode.sh @@ -7,16 +7,19 @@ FFMPEG_FLAGS="" set -e -aencode() { +ffmpeg() { set -x - [[ -f $4 ]] || ${FFMPEG} -threads ${THREADS} -i "$1" -c:a "$2" $3 ${FFMPEG_FLAGS} "$4" + command ${FFMPEG} -threads ${THREADS} ${FFMPEG_FLAGS} "$@" + set +x } for d in bgm sfx; do - cd $(dirname $0)/www/dump/${d} + pushd $(dirname $0)/www/dump/${d} for f in *.ogg; do OUT=${f%.ogg} - aencode $f libopus "-b:a 48k -vbr on" ${OUT}.opus - aencode $f libfdk_aac -vbr 2 ${OUT}.m4a + ffmpeg -y -i $f -c:a pcm_s16le ${OUT}.wav + opusenc --bitrate 64 ${OUT}.wav ${OUT}.opus + ffmpeg -n -i ${OUT}.wav -c:a libfdk_aac -vbr 2 ${OUT}.m4a || true done + popd done diff --git a/vencode.sh b/vencode.sh index 517ff8f..472fc06 100755 --- a/vencode.sh +++ b/vencode.sh @@ -9,15 +9,15 @@ set -e cd $(dirname $0)/www/dump/video -vencode() { +ffmpeg() { set -x - ${FFMPEG} -threads ${THREADS} -i "$1" -c:v "$2" $3 ${FFMPEG_FLAGS} "$4" + command ${FFMPEG} -n -threads ${THREADS} ${FFMPEG_FLAGS} "$@" + set +x } for f in *.mkv; do OUT=${f%.mkv} - vencode $f libx264 "-preset slower -tune animation" ${OUT}.mp4 - vencode $f libvpx "-crf 15 -b:v 1M -an -f webm -y" /dev/null - vencode $f libvpx "-crf 15 -b:v 1M -c:a copy" ${OUT}.webm - vencode $f libtheora "-qscale:v 6 -c:a copy" ${OUT}.ogv + ffmpeg -i $f -c:v libx264 -preset slower -tune animation -c:a libfdk_aac ${OUT}.mp4 + ffmpeg -i $f -c:v libvpx -crf 15 -b:v 1M -c:a copy ${OUT}.webm + ffmpeg -i $f -c:v libtheora -qscale:v 6 -c:a copy ${OUT}.ogv done diff --git a/www/js/api.js b/www/js/api.js index 580de6a..ed5b387 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -39,7 +39,20 @@ window.html5ks.api = { audio.loop = true; } html5ks.elements.audio[channel] = audio; - audio.src = "dump/" + (channel === "music" ? "bgm/" + html5ks.data.music[name] + ".ogg" : html5ks.data.sfx[name]); + + var src = "dump/" + channel === "music" ? html5ks.data.music[name] : html5ks.data.sfx[name]; + if (Modernizr.audio.opus) { + audio.src = src + ".opus"; + } else if (Modernizr.audio.ogg) { + audio.src = src + ".ogg"; + } else if (Modernizr.audio.aac) { + audio.src = src + ".m4a"; + } else if (Modernizr.audio.wav) { + audio.src = src + ".wav"; + } else { + console.error("wtf, no audio formats"); + } + audio.load(); var volume = html5ks.persistent[channel + "Volume"]; audio.volume = fade ? 0 : volume; @@ -90,9 +103,11 @@ window.html5ks.api = { if (Modernizr.video.webm) { video.src = src + "webm"; } else if (Modernizr.video.ogg) { - video.src = src + "ogg"; + video.src = src + "ogv"; } else if (Modernizr.video.h264) { video.src = src + "mp4"; + } else { + console.error("wtf is this, no video formats"); } video.load(); diff --git a/www/js/play.js b/www/js/play.js index 2be38ab..0160980 100644 --- a/www/js/play.js +++ b/www/js/play.js @@ -39,74 +39,74 @@ html5ks.data.music = { "music_menus": "Wiosna" }; html5ks.data.sfx = { - sfx_tcard: "sfx/tcard.ogg", - sfx_4lslogo: "sfx/4lsaudiologo.ogg", - sfx_alarmclock: "sfx/alarm.ogg", - sfx_normalbell: "sfx/carillon.ogg", - sfx_warningbell: "sfx/chaimu.ogg", - sfx_crunchydeath: "sfx/crunch.ogg", - sfx_fireworks: "sfx/fireworks.ogg", - sfx_rain: "sfx/rain.ogg", - sfx_rustling: "sfx/rustling.ogg", - sfx_impact: "sfx/wumph.ogg", - sfx_impact2: "sfx/wumph_2.ogg", - sfx_heartfast: "sfx/heart_single_fast.ogg", - sfx_heartslow: "sfx/heart_single_slow.ogg", - sfx_heartstop: "sfx/heart_stop.ogg", - sfx_emijogging: "sfx/emijogging.ogg", - sfx_emirunning: "sfx/emirunning.ogg", - sfx_emipacing: "sfx/emipacing.ogg", - sfx_emisprinting: "sfx/emisprinting.ogg", - sfx_startpistol: "sfx/startpistol.ogg", - sfx_crowd_indoors: "sfx/crowd_indoors.ogg", - sfx_crowd_outdoors: "sfx/crowd_outdoors.ogg", - sfx_crowd_cheer: "sfx/crowd_cheer.ogg", - sfx_doorknock: "sfx/doorknock.ogg", - sfx_doorknock2: "sfx/doorknock2.ogg", - sfx_doorslam: "sfx/doorslam.ogg", - sfx_doorclose: "sfx/doorclose.ogg", - sfx_cicadas: "sfx/cicadas.ogg", - sfx_scratch: "sfx/scratch.ogg", - sfx_traffic: "sfx/traffic.ogg", - sfx_rumble: "sfx/rumble.ogg", - sfx_skid: "sfx/skid2.ogg", - sfx_gymbounce: "sfx/emibounce.ogg", - sfx_hammer: "sfx/hammer.ogg", - sfx_birdstakeoff: "sfx/birdstakeoff.ogg", - sfx_storebell: "sfx/storebell.ogg", - sfx_thunder: "sfx/thunder.ogg", - sfx_slide: "sfx/slide.ogg", - sfx_slide2: "sfx/slide2.ogg", - sfx_draw: "sfx/sword_draw.ogg", - sfx_shower: "sfx/shower.ogg", - sfx_switch: "sfx/switch.ogg", - sfx_pillow: "sfx/pillow.ogg", - sfx_cellphone: "sfx/cellphone.ogg", - sfx_door_creak: "sfx/door_creak.ogg", - sfx_dooropen: "sfx/dooropen.ogg", - sfx_dropglasses: "sfx/dropglasses.ogg", - sfx_can: "sfx/can.ogg", - sfx_stallbuilding: "sfx/stallbuilding.ogg", - sfx_parkambience: "sfx/parkambience.ogg", - sfx_trainint: "sfx/trainint.ogg", - sfx_footsteps_hard: "sfx/footsteps_hard.ogg", - sfx_footsteps_soft: "sfx/footsteps_soft.ogg", - sfx_paper: "sfx/paper.ogg", - sfx_paperruffling: "sfx/paperruffling.ogg", - sfx_rooftop: "sfx/rooftop.ogg", - sfx_lighter: "sfx/lighter.ogg", - sfx_phone: "sfx/phone.ogg", - sfx_hollowclick: "sfx/hollowclick.ogg", - sfx_businterior: "sfx/businterior.ogg", - sfx_teacup: "sfx/teacup.ogg", - sfx_can_clatter: "sfx/can_clatter.ogg", - sfx_snap: "sfx/snap.ogg", - sfx_billiards_break: "sfx/billiards_break.ogg", - sfx_billiards: "sfx/billiards.ogg", - sfx_lock: "sfx/lock.ogg", - sfx_dropstuff: "sfx/dropstuff.ogg", - sfx_camera: "sfx/camera.ogg", - sfx_time: "sfx/time.ogg", - sfx_flash: "sfx/flash.ogg", - sfx_whiteout: "sfx/whiteout.ogg" + sfx_tcard: "tcard", + sfx_4lslogo: "4lsaudiologo", + sfx_alarmclock: "alarm", + sfx_normalbell: "carillon", + sfx_warningbell: "chaimu", + sfx_crunchydeath: "crunch", + sfx_fireworks: "fireworks", + sfx_rain: "rain", + sfx_rustling: "rustling", + sfx_impact: "wumph", + sfx_impact2: "wumph_2", + sfx_heartfast: "heart_single_fast", + sfx_heartslow: "heart_single_slow", + sfx_heartstop: "heart_stop", + sfx_emijogging: "emijogging", + sfx_emirunning: "emirunning", + sfx_emipacing: "emipacing", + sfx_emisprinting: "emisprinting", + sfx_startpistol: "startpistol", + sfx_crowd_indoors: "crowd_indoors", + sfx_crowd_outdoors: "crowd_outdoors", + sfx_crowd_cheer: "crowd_cheer", + sfx_doorknock: "doorknock", + sfx_doorknock2: "doorknock2", + sfx_doorslam: "doorslam", + sfx_doorclose: "doorclose", + sfx_cicadas: "cicadas", + sfx_scratch: "scratch", + sfx_traffic: "traffic", + sfx_rumble: "rumble", + sfx_skid: "skid2", + sfx_gymbounce: "emibounce", + sfx_hammer: "hammer", + sfx_birdstakeoff: "birdstakeoff", + sfx_storebell: "storebell", + sfx_thunder: "thunder", + sfx_slide: "slide", + sfx_slide2: "slide2", + sfx_draw: "sword_draw", + sfx_shower: "shower", + sfx_switch: "switch", + sfx_pillow: "pillow", + sfx_cellphone: "cellphone", + sfx_door_creak: "door_creak", + sfx_dooropen: "dooropen", + sfx_dropglasses: "dropglasses", + sfx_can: "can", + sfx_stallbuilding: "stallbuilding", + sfx_parkambience: "parkambience", + sfx_trainint: "trainint", + sfx_footsteps_hard: "footsteps_hard", + sfx_footsteps_soft: "footsteps_soft", + sfx_paper: "paper", + sfx_paperruffling: "paperruffling", + sfx_rooftop: "rooftop", + sfx_lighter: "lighter", + sfx_phone: "phone", + sfx_hollowclick: "hollowclick", + sfx_businterior: "businterior", + sfx_teacup: "teacup", + sfx_can_clatter: "can_clatter", + sfx_snap: "snap", + sfx_billiards_break: "billiards_break", + sfx_billiards: "billiards", + sfx_lock: "lock", + sfx_dropstuff: "dropstuff", + sfx_camera: "camera", + sfx_time: "time", + sfx_flash: "flash", + sfx_whiteout: "whiteout" }; -- cgit v1.2.3-70-g09d2