Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Modernize the tool #12

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ OpenH264 is a single-pass encoder used in WebRTC both in Chrome and Firefox.
This adds the `openh264:h264` which runs `h264enc` with settings that are
intended to be close to WebRTC's implementation.

### dav1d

To build dav1d, run:

$ ./setup_dav1d.sh

dav1d is a very fast av1 decoder developed by VideoLAN.

### rav1e

To build rav1e, run:

$ ./setup_rav1e.sh

rav1e is a AV1 Encoder which is intended to cover all use-cases where libaom
is very slow, it is written in rust. Gives near real-time encoding in higher
speed-levels.
To use rav1e use `rav1e-default:rav1e`

## Generating Data

To generate graph data (after building and installing dependencies), see:
Expand Down
39 changes: 36 additions & 3 deletions generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,26 @@ def openh264_command(job, temp_dir):
encoded_files = [{'spatial-layer': 0, 'temporal-layer': 0, 'filename': encoded_filename}]
return ([str(i) for i in command], encoded_files)

def rav1e_command(job, temp_dir):
assert job['num_spatial_layers'] == 1
assert job['num_temporal_layers'] == 1
assert job['codec'] == 'rav1e'
assert job['encoder'] == 'rav1e-default'

(fd, encoded_filename) = tempfile.mkstemp(dir=temp_dir, suffix=".ivf")
os.close(fd)

clip = job['clip']

command = [
'rav1e/target/release/rav1e',
clip['input_file'],
'--tile-rows=2',
'--output=%s' % encoded_filename,
]

encoded_files = [{'spatial-layer': 0, 'temporal-layer': 0, 'filename': encoded_filename}]
return ([str(i) for i in command], encoded_files)

def yami_command(job, temp_dir):
assert job['num_spatial_layers'] == 1
Expand Down Expand Up @@ -263,6 +283,7 @@ def yami_command(job, temp_dir):

encoder_commands = {
'aom-good' : aom_command,
'rav1e-default' : rav1e_command,
'openh264' : openh264_command,
'libvpx-rt' : libvpx_command,
'yami' : yami_command,
Expand Down Expand Up @@ -343,7 +364,7 @@ def prepare_clips(args, temp_dir):
subprocess.check_call(['ffmpeg', '-y', '-i', clip['input_file'], yuv_file], stdout=devnull, stderr=devnull)
clip['yuv_file'] = yuv_file
for clip in clips:
clip['sha1sum'] = subprocess.check_output(['sha1sum', clip['input_file']]).split(' ', 1)[0]
clip['shasum'] = subprocess.check_output(['shasum', clip['input_file']]).split(' ', 1)[0]
if 'yuv_file' not in clip:
clip['yuv_file'] = clip['input_file']
frame_size = 6 * clip['width'] * clip['height'] / 4
Expand All @@ -367,6 +388,8 @@ def prepare_clips(args, temp_dir):
def decode_file(job, temp_dir, encoded_file):
(fd, decoded_file) = tempfile.mkstemp(dir=temp_dir, suffix=".yuv")
os.close(fd)
(fd, decoded_file_rav1e) = tempfile.mkstemp(dir=temp_dir, suffix=".y4m")
os.close(fd)
(fd, framestats_file) = tempfile.mkstemp(dir=temp_dir, suffix=".csv")
os.close(fd)
with open(os.devnull, 'w') as devnull:
Expand All @@ -377,7 +400,15 @@ def decode_file(job, temp_dir, encoded_file):
subprocess.check_call(['openh264/h264dec', encoded_file, decoded_file], stdout=devnull, stderr=devnull)
# TODO(pbos): Generate H264 framestats.
framestats_file = None
return (decoded_file, framestats_file)
elif job['codec'] == 'rav1e':
decoder = 'dav1d/build/tools/dav1d'
subprocess.check_call([decoder,'-i', encoded_file,'-o', decoded_file_rav1e], stdout=devnull, stderr=devnull)
framestats_file = None

if job['codec']=='rav1e':
return (decoded_file_rav1e, framestats_file)
else:
return (decoded_file, framestats_file)


def add_framestats(results_dict, framestats_file, statstype):
Expand Down Expand Up @@ -470,7 +501,7 @@ def run_command(job, (command, encoded_files), job_temp_dir, encoded_file_dir):
for i in range(len(results)):
results_dict = results[i]
results_dict['input-file'] = os.path.basename(clip['input_file'])
results_dict['input-file-sha1sum'] = clip['sha1sum']
results_dict['input-file-shasum'] = clip['shasum']
results_dict['input-total-frames'] = clip['input_total_frames']
results_dict['frame-offset'] = args.frame_offset
results_dict['bitrate-config-kbps'] = job['target_bitrates_kbps']
Expand Down Expand Up @@ -625,6 +656,8 @@ def main():
find_absolute_path(False, 'libvpx/vpxdec')
elif codec == 'av1':
find_absolute_path(False, 'aom/aomdec')
elif codec == 'rav1e':
find_absolute_path(False, 'dav1d/build/tools/dav1d')
elif codec == 'h264':
find_absolute_path(False, 'openh264/h264dec')
if args.enable_vmaf:
Expand Down
4 changes: 2 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ fi
# Check out the pinned libvpx version.
pushd libvpx
git fetch
git checkout --detach e758f9d45704ea0247c1b654f8602c967fa44199
git checkout --detach master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, the previous tagged commit is intentional, that way two checkouts get the same version of the library they're comparing. Unfortunately that hash is ancient since I stopped working on this.

If you want to you can update the hash to the current master (so that you can remove the spatial-svc flag below). You can also add a --revision command-line flag so that you could run ./setup.sh --revision=master.


# Build libvpx
./configure --enable-pic --enable-experimental --enable-spatial-svc --enable-multi-res-encoding
./configure --enable-pic --enable-experimental --enable-multi-res-encoding
make -j32
8 changes: 6 additions & 2 deletions setup_aom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ fi
# Check out the pinned aom version.
pushd aom
git fetch
git checkout --detach 09c0a5bcf57c58963516289ff2173576e3fa8378
git checkout --detach master

# Build aom
./configure --enable-pic
makdir build
cd build
cmake ..
make -j32
cp -rf aomenc ../aomenc
cp -rf aomdec ../aomdec
18 changes: 18 additions & 0 deletions setup_dav1d.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e
set -x

if [ ! -d dav1d ]; then
git clone https://code.videolan.org/videolan/dav1d
fi

# Check out to dav1d
pushd dav1d
git fetch

# Build dav1d
mkdir build
cd build
meson .. --default-library=static
ninja
16 changes: 16 additions & 0 deletions setup_rav1e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e
set -x

# Download rav1e if not available
if [ ! -d rav1e ]; then
git clone http://github.com/xiph/rav1e
fi

# Check out to rav1e
pushd rav1e
git fetch

# Build rav1e
cargo build --release