Skip to main content

No project description provided

Project description

nbmediasplit

nbmediasplit is a script to extract base64 encoded image and audio pcm embedded in .ipynb file and save them into specified directories.

install

pip install nbmediasplit

usage

extract image files from ipynb

nbmediasplit -n input.ipynb -i image_out_dir

or

nbmediasplit --ipynb input.ipynb --imgdir image_out_dir

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

extract audio files from ipynb

nbmediasplit -n input.ipynb -w wav_out_dir

or

nbmediasplit --ipynb input.ipynb --wavdir wav_out_dir

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

extract image and audio files from ipynb

nbmediasplit -n input.ipynb -i image_out_dir -w wav_out_dir

or

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

Above command do 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.

-n or --ipynb specifies input ipynb file. -i or --imgdir specifies directory to store image files. -w or --wavdir specifies directory to store audio files. Filenames of stored image are numbered in a sequential order(0.png, ...). Filenames of stored audio are numbered in a 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 stored image files and audio files directly.

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

or

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

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 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 sanitaization. To trust notebook in jupyterlab, go to command pallet in left sidebar(on osx, type shift+cmd+c) and execute trust notebook, then you'll load audio source if the source path is correct.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbmediasplit-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

nbmediasplit-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file nbmediasplit-0.1.1.tar.gz.

File metadata

  • Download URL: nbmediasplit-0.1.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.6.8 Darwin/19.4.0

File hashes

Hashes for nbmediasplit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4332ae14fb51a9353056ce15dd9fa635d9580b08cea414dc59f03ff52d56271f
MD5 a64ffca76251893f3300dcfdecd5c929
BLAKE2b-256 6c700e7054234bc723ac288fc28f66aec6901d83c0398462d50890aad7c79a48

See more details on using hashes here.

File details

Details for the file nbmediasplit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nbmediasplit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.6.8 Darwin/19.4.0

File hashes

Hashes for nbmediasplit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb8c2853460cde613f383bcbfe7d78b0181af5ac6a028d52bbe22bb812aa01df
MD5 15a88968dcb71851a731bbf785be8fab
BLAKE2b-256 e3a990cd8cea39324cad77f047f1bed3c5d662345a398f144a5288794a4eb750

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page