This repository was archived by the owner on Jul 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTranscodeSintelToDASHAndHLS.rb
More file actions
73 lines (61 loc) · 2.45 KB
/
Copy pathTranscodeSintelToDASHAndHLS.rb
File metadata and controls
73 lines (61 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib")
require 'bitcodin'
require 'json'
class TranscodeSintelToDASHAndHLS
@apiKey = "YOUR_API_KEY"
# INPUT
# create bitcodinAPI
@bitAPI = Bitcodin::BitcodinAPI.new(@apiKey)
@httpConfig = Bitcodin::HTTPInputConfig.new('http://eu-storage.bitcodin.com/inputs/Sintel.2010.720p.mkv')
begin
response = @bitAPI.createInput(@httpConfig)
responseData = JSON.parse(response)
@inputId = responseData['inputId']
rescue Exception => e
puts "Could not create Input."
puts e.message
puts e.backtrace.inspect
return nil
end
puts "Created input with ID: #{@inputId}."
# ENCODING PROFILE
@bitAPI = Bitcodin::BitcodinAPI.new(@apiKey)
# create encoding profile
videoStreamConfig1 = Bitcodin::VideoStreamConfig.new(0, 4800000, Bitcodin::Profile::MAIN, Bitcodin::Preset::PREMIUM, 1080, 1920)
videoStreamConfig2 = Bitcodin::VideoStreamConfig.new(0, 2400000, Bitcodin::Profile::MAIN, Bitcodin::Preset::PREMIUM, 720, 1280)
videoStreamConfig3 = Bitcodin::VideoStreamConfig.new(0, 1200000, Bitcodin::Profile::MAIN, Bitcodin::Preset::PREMIUM, 480, 856)
videoStreamConfigs = [videoStreamConfig1, videoStreamConfig2, videoStreamConfig3]
audioStreamConfig1 = Bitcodin::AudioStreamConfig.new(0, 128000)
audioStreamConfigs = [audioStreamConfig1]
encodingProfile = Bitcodin::EncodingProfile.new('Sample Sintel Transcode Profile (Ruby)', videoStreamConfigs, audioStreamConfigs)
# parse response to get encoding profile ID
begin
response = @bitAPI.createEncodingProfile(encodingProfile)
responseData = JSON.parse(response)
@encodingProfileId = responseData['encodingProfileId']
rescue Exception => e
puts "Could not create Encoding Profile."
puts e.message
puts e.backtrace.inspect
return nil
end
puts "Created encoding profile with ID: #{@encodingProfileId}."
# JOB
@bitAPI = Bitcodin::BitcodinAPI.new(@apiKey)
# create job config
manifestTypes = []
manifestTypes.push(Bitcodin::ManifestType::MPEG_DASH_MPD)
manifestTypes.push(Bitcodin::ManifestType::HLS_M3U8)
@job = Bitcodin::Job.new(@inputId, @encodingProfileId, manifestTypes)
begin
response = @bitAPI.createJob(@job)
responseData = JSON.parse(response)
@jobId = responseData['jobId']
rescue Exception => e
puts "Could not create Job."
puts e.message
puts e.backtrace.inspect
return nil
end
puts "Created job with ID: #{@jobId}."
end