Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ A simple encoder and decoder that conforms to the [ISDCF Document on Sign Langua

Note: later versions of FFmpeg are known to not work at this time.

Perl's File::Slurp module is required.

## Synopsis

### Encoding
Expand Down
Empty file modified decode-vp9-wav
100644 → 100755
Empty file.
18 changes: 12 additions & 6 deletions encode-vp9-wav
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use strict;
use warnings;
use File::Temp qw(tempfile tempdir);
use File::Slurp qw(read_dir read_file);
use File::Path qw(rmtree);
use File::Spec qw(join);
use Getopt::Long;
sub which ($) { scalar grep -x, map "$_/$_[0]", split m/:/, $ENV{PATH} }

Expand All @@ -43,8 +45,10 @@ which "ffmpeg" or die "This utility requires ffmpeg v3.2.4 or greater.\n";
which "ffprobe" or die "This utility requires ffprobe v3.2.4 or greater.\n";

my $chunk_duration_s = 2; # default to what is in the spec
my $log_level = "quiet";

GetOptions("chunk-duration|c=i" => \$chunk_duration_s) or die USAGE;
GetOptions("chunk-duration|c=i" => \$chunk_duration_s,
"log-level=s" => \$log_level) or die USAGE;

my $input = shift or die USAGE;

Expand Down Expand Up @@ -80,7 +84,7 @@ EOF

# segfaults, but works
system 'ffmpeg',
'-loglevel', 'quiet',
'-loglevel', $log_level,
'-hide_banner',
'-i', $input,
'-map', '0:0',
Expand Down Expand Up @@ -109,7 +113,8 @@ my ($fh, $vp9_pcm_file) = tempfile;

print "Adding headers and padding each chunk to $chunk_len_bytes bytes.\n";

for my $file (sort { $a cmp $b } read_dir $build_dir, prefix => 1) {
for my $filename (sort { $a cmp $b } read_dir $build_dir, prefix => 1) {
my $file = File::Spec->catfile($build_dir, $filename);
my $vp9_seg = read_file $file or die;

die "$_ too big: @{[ length $vp9_seg ]} > $chunk_len_bytes. Aborting!\n"
Expand All @@ -135,7 +140,7 @@ print "Generating WAV from raw PCM.\n";

# Wrap the PCM in a WAV
system 'ffmpeg',
'-loglevel', 'quiet',
'-loglevel', $log_level,
'-ac', '1',
'-ar', AUDIO_SAMPLE_RATE,
'-y',
Expand All @@ -144,6 +149,7 @@ system 'ffmpeg',
'-i', $vp9_pcm_file,
'-codec:a', 'copy', $final_wav and die "ffmpeg failed!\n";

print "Success! Wrote to:\n\t$final_wav (use this file for the DCP)\n";

unlink $vp9_pcm_file;
rmtree($build_dir);

print "Success! Wrote to:\n\t$final_wav (use this file for the DCP)\n";