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).”

https://rekion.dl.ndl.go.jp/pid/3574643

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

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 IDs that make up this URL can be found in the response from the following API.

https://rekion.dl.ndl.go.jp/api/item/search/info:ndljp/pid/3574643

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.

https://iiif-demo-next.vercel.app/api/rekion/3574643

The following result is obtained.

{}"}da"""}ttiaaydt""""p"ttuh:e:rirl"itls{:"bl""3ue::"5t"r7e:""e4shhk6""tti4:Ltto3eppn"{css",t::,u/r/err:eekkUiinooinno..nddllo..fnnddMllo..rggaool..ijjtppy//pcaiondnd/t3eE5nc7to4sn6/o43m35y"7,4(6P4a3r/t8313)8"9,ec6-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"-ccopy3574643.mp4

Summary

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