Skip to content

Instantly share code, notes, and snippets.

@jakago
jakago / id3tag.rb
Created July 11, 2011 05:06
Write id3 tag into mp3
#!/usr/bin/env ruby -Ku
require 'nkf'
require 'tempfile'
require 'fileutils'
def encode_size( int32 )
result = String.new()
result << ((int32 & (0x0000007f << 21)) >> 21).chr
result << ((int32 & (0x0000007f << 14)) >> 14).chr
@jakago
jakago / flv2mp3.rb
Created July 11, 2011 02:00
Extract mp3 from flv
#!/usr/bin/env ruby -Ku
FLV_HEADER_SIZE = 9
FLV_TAG_SIZE = 15
FLV_HEADER = Struct.new( :signature, :version, :flags, :offset )
FLV_TAG = Struct.new( :previousTagSize, :type, :bodyLength, :timestamp, :timestampExtended, :streamId )
LastPreviousTagSize = 4
def flv2mp3( flv_path, mp3_path )
result = false