diff --git a/Dockerfile b/Dockerfile
index 1362e6153f2313012dc315390d278b25dde5288e..01cc4375a4d2c72844b0b78cfaf622fbc2dfd7a9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,4 +5,5 @@ RUN apt-get install -y libpq-dev  \
     && docker-php-ext-install pdo pdo_pgsql
 RUN a2enmod rewrite \
     && service apache2 restart
+RUN apt install -y ffmpeg
 #COPY src/web .htaccess /var/www/html/
\ No newline at end of file
diff --git a/src/web/music/music.php b/src/web/music/music.php
index 3e9ada1e5e143fae1016f059b718e5d38fe94846..b4888f9e1c8a2d512e4a29c2262813feee38537b 100644
--- a/src/web/music/music.php
+++ b/src/web/music/music.php
@@ -1,5 +1,12 @@
 <?php
 
+function getDuration($filename): int {
+    $dur = shell_exec("ffmpeg -i $filename 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//");
+    $dur = explode(':', $dur);
+
+    return (int) $dur[0] * 3600 + (int) $dur[1] * 60 + (int) $dur[2];
+}
+
 function addMusic(string $accountId, string $title, string $genre, string $year, string $albumId): int {
     $fileName = $_FILES['file']['name'];
     $fileName = str_replace(' ', '', $fileName);
@@ -30,12 +37,15 @@ function addMusic(string $accountId, string $title, string $genre, string $year,
     $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     curl_reset($curl);
 
+    $duration = getDuration($_FILES['file']['tmp_name']);
+
     if ($http_code == 200) {
-        $query = 'INSERT INTO music (title, album_id, genre, year, owner_account_id, music_filename) 
-                    VALUES(:title, :albumId, :genre, :year, :accountId, :fileName)';
+        $query = 'INSERT INTO music (title, album_id, genre, year, duration, owner_account_id, music_filename) 
+                    VALUES(:title, :albumId, :genre, :year, :duration, :accountId, :fileName)';
         $params = [
             'title' => $title,
             'year' => $year,
+            'duration' => $duration,
             'albumId' => $albumId,
             'genre' => $genre,
             'fileName' => $fileName,