Example #1
0
 def _get_missing_subformats(subformats, ar, w, h):
     """Return missing and transcodable subformats."""
     dones = [
         subformat['tags']['preset_quality'] for subformat in subformats
     ]
     missing = set(get_all_distinct_qualities()) - set(dones)
     transcodables = list(
         filter(lambda q: can_be_transcoded(q, ar, w, h), missing))
     return transcodables
Example #2
0
def test_can_be_transcoded(app):
    """Test `test_can_be_transcoded` function."""
    # standard case
    result = can_be_transcoded('360p', '16:9')
    assert result['quality'] == '360p'
    assert result['aspect_ratio'] == '16:9'
    assert result['width'] == 640
    assert result['height'] == 360

    # aspect ratio fallback
    result = can_be_transcoded('720p', '5:4', 1024, 768)
    assert result['quality'] == '720p'
    assert result['aspect_ratio'] == '4:3'
    assert result['width'] == 960
    assert result['height'] == 720

    # no transcoding
    assert not can_be_transcoded('720p', '5:4')
    assert not can_be_transcoded('720p', '5:4', 480, 360)
Example #3
0
def create_subformat(id_type, id_value, quality):
    """Recreate a given subformat."""
    _validate(id_type=id_type, quality=quality)

    video_deposit, dep_uuid = _resolve_deposit(id_type, id_value)
    master, ar, w, h = _get_master_video(video_deposit)

    subformat = can_be_transcoded(quality, ar, w, h)
    if subformat:
        MaintenanceTranscodeVideoTask().s(version_id=master['version_id'],
                                          preset_quality=subformat['quality'],
                                          deposit_id=dep_uuid).apply_async()

        return subformat
Example #4
0
def create_all_subformats(id_type, id_value):
    """Recreate all subformats."""
    _validate(id_type=id_type)

    video_deposit, dep_uuid = _resolve_deposit(id_type, id_value)
    master, ar, w, h = _get_master_video(video_deposit)

    transcodables = list(
        filter(lambda q: can_be_transcoded(q, ar, w, h),
               get_all_distinct_qualities()))

    # sequential (and immutable) transcoding to avoid MergeConflicts on bucket
    if transcodables:
        chain([
            MaintenanceTranscodeVideoTask().si(version_id=master['version_id'],
                                               preset_quality=quality,
                                               deposit_id=dep_uuid)
            for quality in transcodables
        ]).apply_async()

    return transcodables
Example #5
0
def create_all_missing_subformats(id_type, id_value):
    """Create all missing subformats."""
    _validate(id_type=id_type)

    video_deposit, dep_uuid = _resolve_deposit(id_type, id_value)
    master, ar, w, h = _get_master_video(video_deposit)
    subformats = CDSVideosFilesIterator.get_video_subformats(master)

    dones = [subformat['tags']['preset_quality'] for subformat in subformats]
    missing = set(get_all_distinct_qualities()) - set(dones)
    transcodables = list(
        filter(lambda q: can_be_transcoded(q, ar, w, h), missing))

    # sequential (and immutable) transcoding to avoid MergeConflicts on bucket
    if transcodables:
        chain([
            MaintenanceTranscodeVideoTask().si(version_id=master['version_id'],
                                               preset_quality=quality,
                                               deposit_id=dep_uuid)
            for quality in transcodables
        ]).apply_async()

    return transcodables