diff --git a/scanner/CachePath.py b/scanner/CachePath.py index af60d9b..a94364b 100644 --- a/scanner/CachePath.py +++ b/scanner/CachePath.py @@ -44,6 +44,6 @@ def image_cache(path, size, square=False): suffix = str(size) return cache_base(path, True) + "_" + suffix + ".jpg" def video_cache(path): - return cache_base(path, True) + ".webm" + return cache_base(path, True) + ".mp4" def file_mtime(path): return datetime.fromtimestamp(int(os.path.getmtime(path))) diff --git a/scanner/PhotoAlbum.py b/scanner/PhotoAlbum.py index 6370c49..5c20217 100644 --- a/scanner/PhotoAlbum.py +++ b/scanner/PhotoAlbum.py @@ -408,15 +408,34 @@ class Photo(object): transcode_path = os.path.join(transcode_path, video_cache(self._path)) # get number of cores on the system, and use all minus one num_of_cores = os.sysconf('SC_NPROCESSORS_ONLN') - 1 - transcode_cmd = ['-i', original_path, '-c:v', 'libvpx', '-crf', '10', '-b:v', '4M', '-c:a', 'libvorbis', '-f', 'webm', '-threads', str(num_of_cores), '-loglevel', '0', '-y'] + transcode_cmd = [ + '-i', original_path, # original file to be encoded + '-c:v', 'libx264', # set h264 as videocodec + '-preset', 'slow', # set specific preset that provides a certain encoding speed to compression ratio + '-profile:v', 'baseline', # set output to specific h264 profile + '-level', '3.0', # sets highest compatibility with target devices + '-crf', '20', # set quality + '-b:v', '4M', # set videobitrate to 4Mbps + '-strict', 'experimental', # allow native aac codec below + '-c:a', 'aac', # set aac as audiocodec + '-ac', '2', # force two audiochannels + '-ab', '160k', # set audiobitrate to 160Kbps + '-maxrate', '10000000', # limits max rate, will degrade CRF if needed + '-bufsize', '10000000', # define how much the client should buffer + '-f', 'mp4', # fileformat mp4 + '-threads', str(num_of_cores), # number of cores (all minus one) + '-loglevel', '0', # don't display anything + '-y' # don't prompt for overwrite + ] filters = [] - info_string = "%s -> webm" % (os.path.basename(original_path)) + info_string = "%s -> mp4, h264" % (os.path.basename(original_path)) message("transcoding", info_string) if os.path.exists(transcode_path) and file_mtime(transcode_path) >= self._attributes["dateTimeFile"]: self._video_metadata(transcode_path, False) return if "originalSize" in self._attributes and self._attributes["originalSize"][1] > 720: - filters.append("scale='trunc(oh*a/2)*2:min(720\,iw)'") + transcode_cmd.append('-s') + transcode_cmd.append('hd720') if "rotate" in self._attributes: if self._attributes["rotate"] == "90": filters.append('transpose=1') diff --git a/web/js/010-libphotofloat.js b/web/js/010-libphotofloat.js index 14ba0d7..dc72e6e 100644 --- a/web/js/010-libphotofloat.js +++ b/web/js/010-libphotofloat.js @@ -148,7 +148,7 @@ return "cache/" + hash; }; PhotoFloat.videoPath = function(album, video) { - return "cache/" + PhotoFloat.cachePath(PhotoFloat.photoHash(album, video) + ".webm"); + return "cache/" + PhotoFloat.cachePath(PhotoFloat.photoHash(album, video) + ".mp4"); }; PhotoFloat.originalPhotoPath = function(album, photo) { return "albums/" + album.path + "/" + photo.name; diff --git a/web/js/011-display.js b/web/js/011-display.js index 9a36f6f..c9b6c78 100644 --- a/web/js/011-display.js +++ b/web/js/011-display.js @@ -190,8 +190,8 @@ $(document).ready(function() { if (!Modernizr.video) { $('

Sorry, your browser doesn\'t support the HTML5 <video> element!

Here\'s a list of which browsers do.

').appendTo('#video-box-inner'); } - else if (!Modernizr.video.webm) { - $('

Sorry, your browser doesn\'t support the WebM video format!

').appendTo('#video-box-inner'); + else if (!Modernizr.video.h264) { + $('

Sorry, your browser doesn\'t support the H.264 video format!

').appendTo('#video-box-inner'); } else { $(window).unbind("resize", scaleVideo);