def add_filepaths(parsed_df, input_dir, output_dir):
    """Add the necessary filepaths for saving and later accessing.

    Args:
    ----
        parsed_df: pandas DataFrame
        input_dir: str
        output_dir: str

    Returns:
    -------
        parsed_df: pandas DataFrame
    """

    # The video numbers in the filenames are zero padded on the left.
    parsed_df['vid_num'] = (parsed_df['frame'].astype(str)
                               .apply(lambda frame: frame.zfill(8)))
    parsed_df['filename'] = (parsed_df['filename']
                                .apply(lambda filename:
                                    filename.replace('.ann', '')))

    # Need to replace the filename ext. in the DataFrame with `.jpg` and provide
    # the full relative input and output paths.
    parsed_df['input_filepath'] = (input_dir + parsed_df['directory_path'] +
        '/' + parsed_df['filename'] + '/' + parsed_df['vid_num'] + '.jpg')
    parsed_df['output_filepath'] = (output_dir + parsed_df['filename'] +
        '_' + parsed_df['vid_num'] + '.jpg')
    # To be used as the full path in the image generator.
    parsed_df['jpg_filename'] = (parsed_df['output_filepath']
                                    .apply(lambda filepath:
                                        filepath.split('/')[3]))

    return parsed_df