diff --git a/inc/common/common.h b/inc/common/common.h
index 3831a0780de73d7f158de416c8cbec2efe00c101..faf50a377f20c390952afe7294d52e3ede268505 100644
--- a/inc/common/common.h
+++ b/inc/common/common.h
@@ -33,8 +33,12 @@ uint32_t be_uint32_t(const uint8_t bytes[], size_t n);
 uint64_t be_uint64_t(const uint8_t bytes[], size_t n);
 
 /* Same as `be_uint64_t` but for Big-endian doubles.
-   Restriction: n <= 8 */
-double be_double_t(const uint8_t bytes[], size_t n);
+   Restriction: bytes must be of length 8. */
+double be_double_t(const uint8_t bytes[]);
+
+/* Same as `be_double_t` but for floats. Restriction: bytes must
+   be of length 4. */
+float be_float_t(const uint8_t bytes[]);
 
 /* Trim the string `str` of the char `c` from the right and the left.
    The string may not be null terminated.
diff --git a/src/common.c b/src/common.c
index 36486e0c6aed3629de0b9dfa77c791518e4fd66a..59f748dae69d3226254c97030fceda7375a45fba 100644
--- a/src/common.c
+++ b/src/common.c
@@ -33,16 +33,15 @@ be_uint32_t(const uint8_t bytes[], size_t n)
     return res;
 }
 
-double
-be_double_t(const uint8_t bytes[], size_t n)
+float
+be_float_t(const uint8_t bytes[])
 {
     union {
-        uint8_t _bytes[8];
-        double _double;
-    } res;
-    for (size_t i = 0; i < n; ++i)
-        res._bytes[i] = bytes[n - i - 1] & 0xff;
-    return res._double;
+        uint32_t _uint;
+        float _float;
+    } ret;
+    ret._uint = be_uint32_t(bytes, 4);
+    return ret._float;
 }
 
 uint64_t
@@ -54,6 +53,17 @@ be_uint64_t(const uint8_t bytes[], size_t n)
     return res;
 }
 
+double
+be_double_t(const uint8_t bytes[])
+{
+    union {
+        uint64_t _uint;
+        double _double;
+    } ret;
+    ret._uint = be_uint64_t(bytes, 8);
+    return ret._double;
+}
+
 char *
 trim(char *str, size_t len, char c)
 {
diff --git a/src/mkv/mkv.c b/src/mkv/mkv.c
index c6ce2ee73e8b0dc92ef778e88b1d8b38a836dec4..c202b6610aafc772687365984e9b1cf4676da91c 100644
--- a/src/mkv/mkv.c
+++ b/src/mkv/mkv.c
@@ -150,7 +150,12 @@ mkv_read_float(struct bufferfd *bf, double *res)
         if (bufferfd_bytes(bf, data_len, data) < 0)
             return -1;
 
-        *res = be_double_t(data, data_len);
+        if (data_len == 8)
+            *res = be_double_t(data);
+        else if (data_len == 4)
+            *res = (double) be_float_t(data);
+        else
+            return -1;
     }
 
     return n + (ssize_t) data_len;
@@ -545,6 +550,7 @@ kara_read_segment_info(struct bufferfd *bf, double *len)
         if (eid == EBML_MKV_SEG_DURATION) {
             if ((n = mkv_read_float(bf, len)) < 0)
                 return -1;
+            printf("%ld\n", n);
         }
 
         else if (eid == EBML_MKV_SEG_TS_SCALE) {