mediainfo-native 0.2.2 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/ext/mediainfo_native/MediaInfoDLL.h +2 -2
- data/ext/mediainfo_native/extconf.rb +22 -14
- data/ext/mediainfo_native/mediainfo_wrapper.cpp +10 -10
- data/ext/mediainfo_native/unicode.cpp +28 -11
- data/ext/mediainfo_native/unicode.h +2 -2
- data/lib/mediainfo-native/attr_readers.rb +9 -16
- data/lib/mediainfo-native/base_stream.rb +1 -1
- data/lib/mediainfo-native/mediainfo.rb +6 -0
- data/lib/mediainfo-native/streams/audio.rb +2 -0
- data/lib/mediainfo-native/streams/general.rb +3 -0
- data/lib/mediainfo-native/streams/other.rb +1 -2
- data/lib/mediainfo-native/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0b3c5ead23b741aff80e2ea9efa6080ac03ddca5f2d26985a09fb229854b2155
|
4
|
+
data.tar.gz: d3671fb23e058d954385fe5293bdf8bd7f4298231a90969139b3a2f9aac7059f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 220538dea36980db4a94406759b257d0381e21a815aa3030b0f9b85b75142fee5559f38d2504a49f40e998f1b02059c63fbc13d9af94c0e5cdb5eb5bf2548b19
|
7
|
+
data.tar.gz: afabd80d260bfa1bf6801c4a6c777619e10f0a3b298118be277a39ac73cdf0fd2ac9f20f98c853a68ab1cbe318c65cf2572c41b15b805f4d2f15decd1141ae30
|
@@ -1,20 +1,28 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
|
4
|
-
abort 'Failed to locate pkg-config file for libmediainfo.'
|
5
|
-
end
|
3
|
+
if (mediainfo_cfg = pkg_config('libmediainfo'))
|
6
4
|
|
7
|
-
unless have_library('mediainfo')
|
8
|
-
|
9
|
-
end
|
5
|
+
unless have_library('mediainfo')
|
6
|
+
abort 'Failed to test-link against libmediainfo.'
|
7
|
+
end
|
10
8
|
|
11
|
-
non_std_location = mediainfo_cfg.detect { |flag| flag =~ /^-L/ }
|
12
|
-
if non_std_location
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
9
|
+
non_std_location = mediainfo_cfg.detect { |flag| flag =~ /^-L/ }
|
10
|
+
if non_std_location
|
11
|
+
non_std_location.gsub!('-L', '')
|
12
|
+
$LDFLAGS << " -Wl,-rpath,#{non_std_location}"
|
13
|
+
message "embedding path to library into libmediainfo.so: #{non_std_location}\n"
|
14
|
+
end
|
17
15
|
|
18
|
-
with_cppflags("#{(mediainfo_cfg.detect { |flag| flag =~ /^-I/ })}") do
|
19
|
-
|
16
|
+
with_cppflags("#{(mediainfo_cfg.detect { |flag| flag =~ /^-I/ })}") do
|
17
|
+
create_makefile('mediainfo_native')
|
18
|
+
end
|
19
|
+
else
|
20
|
+
unless have_library('mediainfo')
|
21
|
+
abort 'Failed to test-link against libmediainfo.'
|
22
|
+
end
|
23
|
+
|
24
|
+
with_cppflags("-lmediainfo") do
|
25
|
+
create_makefile('mediainfo_native')
|
26
|
+
end
|
20
27
|
end
|
28
|
+
|
@@ -68,7 +68,7 @@ extern "C"
|
|
68
68
|
Check_Type(path, T_STRING);
|
69
69
|
GET_WRAPPER(miw);
|
70
70
|
|
71
|
-
OpenParams params = { miw,
|
71
|
+
OpenParams params = { miw, value_to_mediainfo_string(path), 0 };
|
72
72
|
rb_thread_call_without_gvl(miw_open_without_gvl, (void*) ¶ms, NULL, NULL);
|
73
73
|
|
74
74
|
switch(params.result) {
|
@@ -103,7 +103,7 @@ extern "C"
|
|
103
103
|
Check_Type(path, T_STRING);
|
104
104
|
GET_WRAPPER(miw);
|
105
105
|
|
106
|
-
miw->open(
|
106
|
+
miw->open(value_to_mediainfo_string(path));
|
107
107
|
VALUE inform = miw->inform();
|
108
108
|
miw->close();
|
109
109
|
|
@@ -169,9 +169,9 @@ MediaInfoWrapper::MediaInfoWrapper(bool ignore_continuous_file_names)
|
|
169
169
|
: file_opened(false)
|
170
170
|
{
|
171
171
|
mi = new MediaInfoDLL::MediaInfo();
|
172
|
-
mi->Option("Inform", "XML");
|
173
|
-
mi->Option("Complete", "1");
|
174
|
-
mi->Option("File_TestContinuousFileNames", ignore_continuous_file_names ? "0" : "1");
|
172
|
+
mi->Option(L"Inform", L"XML");
|
173
|
+
mi->Option(L"Complete", L"1");
|
174
|
+
mi->Option(L"File_TestContinuousFileNames", ignore_continuous_file_names ? L"0" : L"1");
|
175
175
|
}
|
176
176
|
|
177
177
|
MediaInfoWrapper::~MediaInfoWrapper()
|
@@ -183,7 +183,7 @@ MediaInfoWrapper::~MediaInfoWrapper()
|
|
183
183
|
delete mi;
|
184
184
|
}
|
185
185
|
|
186
|
-
int MediaInfoWrapper::open(
|
186
|
+
int MediaInfoWrapper::open(MediaInfoDLL::String path)
|
187
187
|
{
|
188
188
|
if(file_opened)
|
189
189
|
return 1;
|
@@ -225,20 +225,20 @@ VALUE MediaInfoWrapper::wrapStreams()
|
|
225
225
|
|
226
226
|
VALUE MediaInfoWrapper::get(StreamType type, unsigned int idx, VALUE key) const
|
227
227
|
{
|
228
|
-
MediaInfoDLL::String mi_key(
|
229
|
-
return
|
228
|
+
MediaInfoDLL::String mi_key(value_to_mediainfo_string(key));
|
229
|
+
return mediainfo_string_to_value(mi->Get(convertToMediaInfoStreamType(type), idx, mi_key));
|
230
230
|
}
|
231
231
|
|
232
232
|
VALUE MediaInfoWrapper::inform() const
|
233
233
|
{
|
234
234
|
CHECK_OPEN;
|
235
235
|
|
236
|
-
return
|
236
|
+
return mediainfo_string_to_value(mi->Inform());
|
237
237
|
}
|
238
238
|
|
239
239
|
VALUE MediaInfoWrapper::option() const
|
240
240
|
{
|
241
|
-
return
|
241
|
+
return mediainfo_string_to_value(mi->Option(L"Info_Parameters"));
|
242
242
|
}
|
243
243
|
|
244
244
|
} /* namespace MediaInfoNative */
|
@@ -1,19 +1,36 @@
|
|
1
1
|
#include <ruby.h>
|
2
|
-
#include <
|
2
|
+
#include <cstdlib>
|
3
3
|
#include "unicode.h"
|
4
4
|
|
5
|
-
MediaInfoDLL::String
|
5
|
+
MediaInfoDLL::String value_to_mediainfo_string(VALUE s)
|
6
6
|
{
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
size_t nchars = RSTRING_LEN(s);
|
8
|
+
wchar_t buf[nchars + 1];
|
9
|
+
|
10
|
+
nchars = mbstowcs(buf, StringValueCStr(s), nchars);
|
11
|
+
|
12
|
+
if((size_t) (-1) == nchars)
|
13
|
+
rb_raise(rb_eArgError, "invalid multi-byte sequence in char array");
|
14
|
+
else
|
15
|
+
// According to mbstowcs(3), this is not nul-terminated when max characters
|
16
|
+
// have been written.
|
17
|
+
buf[nchars] = L'\0';
|
18
|
+
|
19
|
+
return MediaInfoDLL::String(buf);
|
10
20
|
}
|
11
21
|
|
12
|
-
VALUE
|
22
|
+
VALUE mediainfo_string_to_value(MediaInfoDLL::String s)
|
13
23
|
{
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
24
|
+
size_t nbytes = s.length() * 2;
|
25
|
+
char buf[nbytes + 1];
|
26
|
+
|
27
|
+
nbytes = wcstombs(buf, s.data(), nbytes);
|
28
|
+
|
29
|
+
if((size_t) (-1) == nbytes)
|
30
|
+
rb_raise(rb_eArgError, "wide-char sequence not representable in char array");
|
31
|
+
else
|
32
|
+
// This should actually always be there, just to make sure.
|
33
|
+
buf[nbytes] = '\0';
|
34
|
+
|
35
|
+
return rb_locale_str_new_cstr(buf);
|
19
36
|
}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
#include <ruby.h>
|
5
5
|
#include "MediaInfoDLL.h"
|
6
6
|
|
7
|
-
MediaInfoDLL::String
|
8
|
-
VALUE
|
7
|
+
MediaInfoDLL::String value_to_mediainfo_string(VALUE s);
|
8
|
+
VALUE mediainfo_string_to_value(MediaInfoDLL::String s);
|
9
9
|
|
10
10
|
#endif /* MEDIAINFO_NATIVE_UNICODE_H */
|
@@ -9,43 +9,36 @@ module MediaInfoNative
|
|
9
9
|
@supported_attributes || []
|
10
10
|
end
|
11
11
|
|
12
|
-
def mediainfo_attr_reader(attribute, mediainfo_key)
|
12
|
+
def mediainfo_attr_reader(attribute, mediainfo_key)
|
13
13
|
attribute_before_type_cast = "#{attribute}_before_type_cast"
|
14
|
-
|
14
|
+
|
15
15
|
define_method attribute_before_type_cast do
|
16
16
|
instance_variable_get("@#{attribute_before_type_cast}") || instance_variable_set("@#{attribute_before_type_cast}", lookup(mediainfo_key))
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
define_method attribute do
|
20
20
|
if v = instance_variable_get("@#{attribute}")
|
21
21
|
v
|
22
22
|
else
|
23
23
|
v = send(attribute_before_type_cast)
|
24
24
|
v = yield v if v and block_given?
|
25
|
-
|
25
|
+
|
26
26
|
instance_variable_set("@#{attribute}", v)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
supported_attribute(attribute)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def mediainfo_duration_reader(*a)
|
34
|
-
mediainfo_attr_reader
|
34
|
+
mediainfo_attr_reader(*a) do |v|
|
35
35
|
case
|
36
|
-
when v.include?(":")
|
37
|
-
# If it is like 00:20:30.600
|
38
|
-
splitted = v.split(/:|\./)
|
39
|
-
(splitted[0].to_i * 60 * 60 * 1000) +
|
40
|
-
(splitted[1].to_i * 60 * 1000) +
|
41
|
-
(splitted[2].to_i * 1000) +
|
42
|
-
(splitted[3].to_i)
|
43
36
|
when v.include?('ms')
|
44
37
|
# If it is like '20mn 30s 600ms'
|
45
38
|
t = 0
|
46
39
|
v.split(/\s+/).each do |tf|
|
47
40
|
case tf
|
48
|
-
# TODO: Haven't actually seen how they represent hours yet
|
41
|
+
# TODO: Haven't actually seen how they represent hours yet
|
49
42
|
# but hopefully this is ok.. :\
|
50
43
|
when /\d+h/ then t += tf.to_i * 60 * 60 * 1000
|
51
44
|
when /\d+mn/ then t += tf.to_i * 60 * 1000
|
@@ -65,7 +58,7 @@ module MediaInfoNative
|
|
65
58
|
end
|
66
59
|
end
|
67
60
|
end
|
68
|
-
|
61
|
+
|
69
62
|
def mediainfo_date_reader(*a)
|
70
63
|
# Mediainfo can return wrong timestamps, so we have to correct them before
|
71
64
|
# we let ruby try to parse.
|
@@ -78,7 +71,7 @@ module MediaInfoNative
|
|
78
71
|
end
|
79
72
|
end
|
80
73
|
end
|
81
|
-
|
74
|
+
|
82
75
|
def mediainfo_int_reader(*a)
|
83
76
|
mediainfo_attr_reader(*a) { |v| v.gsub(/\D+/, "").to_i }
|
84
77
|
end
|
@@ -35,6 +35,8 @@ module MediaInfoNative
|
|
35
35
|
end
|
36
36
|
|
37
37
|
class StreamProxy
|
38
|
+
include Enumerable
|
39
|
+
|
38
40
|
def initialize(streams)
|
39
41
|
@streams = streams
|
40
42
|
end
|
@@ -46,6 +48,10 @@ module MediaInfoNative
|
|
46
48
|
def [](idx); @streams[idx]; end
|
47
49
|
def count; @streams.size; end
|
48
50
|
|
51
|
+
def each(&blk)
|
52
|
+
@streams.each(&blk)
|
53
|
+
end
|
54
|
+
|
49
55
|
def respond_to?(meth, include_all = false)
|
50
56
|
begin
|
51
57
|
case @streams.size
|
@@ -28,6 +28,8 @@ module MediaInfoNative
|
|
28
28
|
mediainfo_attr_reader :codec, 'Codec'
|
29
29
|
mediainfo_attr_reader :codec_id_hint, 'CodecID/Hint'
|
30
30
|
mediainfo_attr_reader :channel_positions, 'ChannelPositions'
|
31
|
+
mediainfo_attr_reader :muxing_mode, 'MuxingMode'
|
32
|
+
mediainfo_attr_reader :muxing_mode_info, 'MuxingMode_MoreInfo'
|
31
33
|
|
32
34
|
mediainfo_int_reader :channels, 'Channel(s)'
|
33
35
|
def stereo?; 2 == channels; end
|
@@ -12,6 +12,9 @@ module MediaInfoNative
|
|
12
12
|
mediainfo_attr_reader :overall_bit_rate, 'OverallBitRate'
|
13
13
|
mediainfo_attr_reader :encoded_application_string, 'Encoded_Application/String'
|
14
14
|
mediainfo_attr_reader :encoded_application, 'Encoded_Application'
|
15
|
+
mediainfo_int_reader :headersize, 'HeaderSize'
|
16
|
+
mediainfo_int_reader :datasize, 'DataSize'
|
17
|
+
mediainfo_int_reader :footersize, 'FooterSize'
|
15
18
|
alias_method :writing_application, :encoded_application_string
|
16
19
|
|
17
20
|
# Since MediaInfo v0.7.76 encoded_application is replaced by
|
@@ -2,7 +2,6 @@ module MediaInfoNative
|
|
2
2
|
class OtherStream < BaseStream
|
3
3
|
mediainfo_attr_reader :stream_id, 'ID'
|
4
4
|
mediainfo_attr_reader :type, 'Type'
|
5
|
-
|
6
|
-
alias_method :timecode, :timestamp_firstframe
|
5
|
+
mediainfo_attr_reader :timecode, 'TimeCode_FirstFrame'
|
7
6
|
end
|
8
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediainfo-native
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Projective Technology GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
41
|
description: Extracts metadata from media files with mediainfo shared library
|
42
|
-
email: technology@
|
42
|
+
email: technology@projective.io
|
43
43
|
executables: []
|
44
44
|
extensions:
|
45
45
|
- ext/mediainfo_native/extconf.rb
|
@@ -66,7 +66,7 @@ files:
|
|
66
66
|
- lib/mediainfo-native/streams/text.rb
|
67
67
|
- lib/mediainfo-native/streams/video.rb
|
68
68
|
- lib/mediainfo-native/version.rb
|
69
|
-
homepage:
|
69
|
+
homepage: https://github.com/projectivetech/mediainfo-native
|
70
70
|
licenses:
|
71
71
|
- MIT
|
72
72
|
metadata: {}
|
@@ -85,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
|
89
|
-
rubygems_version: 2.2.2
|
88
|
+
rubygems_version: 3.2.5
|
90
89
|
signing_key:
|
91
90
|
specification_version: 4
|
92
91
|
summary: Native bindings for mediainfo
|