Skip to main content

pytest

nbmediasplit

nbmediasplit is a script to extract base64 encoded image and audio PCM embedded in .ipynb file and save them into specified directories. nbmediasplit also converts ipynb file to a new one which refers to stored image and audio files.

install

pip install nbmediasplit

usage

extract image files from ipynb

nbmediasplit input.ipynb -i image_out_dir

or

nbmediasplit input.ipynb --imgdir image_out_dir

The above command extract image files from input.ipynb and store them to image_out_dir. -i or --imgdir specifies a directory to store image files. Filenames of the stored image are numbered in sequential order(0.png, ...).

extract audio files from ipynb

nbmediasplit input.ipynb -w wav_out_dir

or

nbmediasplit input.ipynb --wavdir wav_out_dir

The above command extract audio files from input.ipynb and store them to wav_out_dir. -w or --wavdir specifies a directory to store audio files. Filenames of the stored audio are numbered in sequential order(0.wav, ...).

extract image and audio files from ipynb

nbmediasplit input.ipynb -i image_out_dir -w wav_out_dir

or

nbmediasplit input.ipynb --imgdir image_out_dir --wavdir wav_out_dir

The above command does below things.

  • extract image files from input.ipynb and store them to image_out_dir
  • extract audio files from input.ipynb and store them to wav_out_dir.

-i or --imgdir specifies a directory to store image files. -w or --wavdir specifies a directory to store audio files. Filenames of the stored image are numbered in sequential order(0.png, ...). Filenames of the stored audio are numbered in sequential order(0.wav, ...).

extract image and audio files from ipynb and convert ipynb

If you use -o or --output option like below command, you can convert input.ipynb to new ipynb file which refers to stored image files and audio files directly.

nbmediasplit input.ipynb -i image_out_dir -w wav_out_dir -o converted.ipynb

or

nbmediasplit input.ipynb --imgdir image_out_dir --wavdir wav_out_dir --output converted.ipynb

The above command extract image files and audio files, and store them to specified directories, and generate new ipynb file converted.ipynb. converted.ipynb includes same content as input.ipynb, but base64 encoded image and audio data are replaced to HTML tag refers to stored files directly like below.

  • image tag
    • <img src="${image_out_dir}/${n}.png" />
  • audio tag
    • <audio controls preload="none"><source src="${wav_out_dir}/${n}.wav" type="audio/wav" /></audio>

Also, you can use --img-prefix and --wav-prefix options. These options can change the path embeded in src attribute of output html like below(actual files are stored image_out_dir and wav_out_dir).

  • image tag
    • <img src="${img-prefix}/${n}.png" />
  • audio tag
    • <audio controls preload="none"><source src="${wav-prefix}/${n}.wav" type="audio/wav" /></audio>

show help

nbmediasplit --help

note

Unless you trust the notebook converted by nbmediasplit in jupyter, you can't load audio source because of html sanitization. To trust notebook in jupyterlab, go to command pallet in the left sidebar(on osx, type shift+cmd+c) and execute trust notebook, then you'll load audio source if the source path is correct.

Metadata

Release files for nbmediasplit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbmediasplit 0.2.0
File Size Uploaded Provenance
nbmediasplit-0.2.0.tar.gz 4.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nbmediasplit 0.2.0
File Interpreter ABI Platform
nbmediasplit-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / nbmediasplit-0.2.0.tar.gz

Download URL nbmediasplit-0.2.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bc2a0964ce8d34eb21fd9c7dcbbf78039d4f7b3a3c1b5b2308ef02fa1326f246
BLAKE2b-256 checksum
How to use checksums
07b9b4bf0ea608da4cc7868875a64af38a2b71f6432c3c2b6351a16de44d41fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.6.8 Darwin/19.4.0

Release files / nbmediasplit-0.2.0-py3-none-any.whl

Download URL nbmediasplit-0.2.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1121ec48246bd00fd7b0a39c1ceb68862eb052c448549bde5fe4ef4994e2ab8d
BLAKE2b-256 checksum
How to use checksums
fde202c36a9c5322bd24b43b3d2abe7b5ea80827e793a6b2f35b9b5460a7b4f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.6.8 Darwin/19.4.0

Security for nbmediasplit 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page