Overview

I had an opportunity to convert audio published on the National Diet Library Historical Sound Archive (hereinafter "Rekion") to mp4, so here are my notes.

Format Provided by Rekion

Rekion provides files in m3u8 format.

For example, let's check the following: "Lecture: Union of Morality and Economy (Part 1)."

By checking with developer tools, you can confirm that it is accessible from the following URL.

The IDs that make up this URL can be found in the response from the following API.

Developing an API to Retrieve the Above URL from a PID

By processing the above JSON, the URL of the m3u8 file can be obtained.

I created an API for this part, so please try it out.

The following result is obtained.

{
  "data": {
    "type": "rekion",
    "id": "3574643",
    "attributes": {
      "title": "Lecture: Union of Morality and Economy (Part 1)",
      "url": "https://rekion.dl.ndl.go.jp/pid/3574643",
      "hls": "https://rekion.dl.ndl.go.jp/contents/3574643/83389ec6-2b45-4fdd-88d6-89628841039f/317d6ab4-32ec-4085-88e6-cfe36ffd34c3/317d6ab4-32ec-4085-88e6-cfe36ffd34c3_hls.m3u8"
    }
  }
}

The source code is available here.

https://github.com/nakamura196/iiif-demo-next/blob/main/src/app/api/rekion/[id]/route.ts

Converting to mp4 Using ffmpeg

The m3u8 file was converted to mp4 format using the following command.

ffmpeg -i "https://rekion.dl.ndl.go.jp/contents/3574643/83389ec6-2b45-4fdd-88d6-89628841039f/317d6ab4-32ec-4085-88e6-cfe36ffd34c3/317d6ab4-32ec-4085-88e6-cfe36ffd34c3_hls.m3u8" -c copy 3574643.mp4

Summary

I hope this serves as a helpful reference for working with audio files.