Skip to content

Instantly share code, notes, and snippets.

@jimkang
jimkang / mediasource-mime-codecs.md
Last active October 16, 2023 13:00
How to get the video codec the MIME types that MediaSource SourceBuffers require

When you call addSourceBuffer on a MediaSource, you need to pass in a string that is the MIME type for the codec. If this isn't correct, the video won't play. (You can also pass this to the MediaSource's isTypeSupported function, though there seems to be a gap between what it thinks it can play and what it will play.)

The string looks like this:

video/mp4; codecs="avc1.42E01E, mp4a.40.2"

The values required in that string can be obtained by running the mp4file tool from mp4v2 on a video file, like so:

 mp4file --dump movie.mp4
@shilov
shilov / redis_json_marshal_eval_benchmarks.rb
Created January 27, 2012 23:01
Ruby Redis benchmarks for JSON vs Marshal vs String
# http://forrst.com/posts/JSON_vs_Marshal_vs_eval_Which_is_the_fastest_fo-6Qy
require 'benchmark'
require 'json'
require 'redis'
# -----------------
puts "Initialize variables.."