This is a basic notebook that demonstrates how to play with .ldf files in a notebook.

In [5]:
# All the imports, etc.... this would be a good one to fold up, if I knew how...

%load_ext autoreload
%autoreload 2

from base64 import b64encode
import copy
from datetime import datetime
import getopt
import os
import sys

# standard numeric/scientific libraries
import numpy as np
import pandas as pd
import scipy as sp
import scipy.signal as sps
import scipy.fftpack as fftpack 

# plotting
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt

    # I use dark mode in my notebooks, this makes the plots match :)
    from jupyterthemes import jtplot'monokai', context='notebook', ticks=True, grid=False)    

# image display
from PIL import Image
import IPython.display 
from IPython.display import HTML

# Add lddecode core modules to path
module_path = os.path.abspath(os.path.join('../lddecode'))
if module_path not in sys.path:

module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:

from lddecode.utils import *
from lddecode.plot_utils import *
import lddecode.core as core

The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

In [6]:
# This needs to be done after the first block for some reason?
matplotlib.rc('figure', figsize=(20, 12))

In [7]:
# Would move this to uitls, but needs to run core.LDdecode

def rundecode(filename, outname, firstframe, numframes, system='NTSC', extra_options = {}):
    """ Helper function for notebooks, returns main ldd object and all fields """
    loader = make_loader(filename)

    ldd = core.LDdecode(filename, outname, loader, system=system)
    ldd.roughseek(firstframe * 2)
    ldd.blackIRE = 7.5

    fields = []
    for i in range(0, numframes * 2):

    write_json(ldd, outname)
    return ldd, fields

In [8]:
filename = '/home/cpage/ld-decode-testdata/'
outname = 'devbook'
system = 'NTSC'

ldd, fields = rundecode(filename, outname, 0, 3, system)

file frame 0 CAV frame 47748
file frame 1 CAV frame 47749
file frame 2 CAV frame 47750

In [9]:
# Displays field


In [10]:
# Now run ld-chroma-decoder on the above output, which allows us to display lines and the decoded picture
rgb = RGBoutput(outname)

In [11]:


In [12]:
#matplotlib.rc('figure', figsize=(20, 12))
rgb.plotline(0, 240)