Revert "Tidy up and increase exception handling in compare_videos"

This reverts commit 1c60ff521eda26c80fa53097d9c614f10200f651.

Reason for revert: Breaks downstream tests:
non-test target compare_videos depends on testonly target frame_analyzer

Original change's description:
> Tidy up and increase exception handling in compare_videos
> 
> Bug: webrtc:9642
> Change-Id: I5c8b252de3b285f81a5437af99d789b5a28ce646
> Reviewed-on: https://webrtc-review.googlesource.com/102880
> Commit-Queue: Paulina Hensman <phensman@webrtc.org>
> Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#24909}

TBR=phoglund@webrtc.org,sakal@webrtc.org,phensman@webrtc.org

Change-Id: I69c94248faf7d448b871b91548336ff681e4d139
No-Try: true
Bug: webrtc:9642
Reviewed-on: https://webrtc-review.googlesource.com/102921
Reviewed-by: Oleh Prypin <oprypin@webrtc.org>
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24911}
This commit is contained in:
Oleh Prypin 2018-10-01 13:19:15 +00:00 committed by Commit Bot
parent 5f45e66518
commit 3d3e08b2b1
3 changed files with 29 additions and 38 deletions

View File

@ -108,7 +108,6 @@ rtc_static_library("video_quality_analysis") {
rtc_executable("frame_analyzer") { rtc_executable("frame_analyzer") {
visibility = [ "*" ] visibility = [ "*" ]
testonly = true
sources = [ sources = [
"frame_analyzer/frame_analyzer.cc", "frame_analyzer/frame_analyzer.cc",
] ]
@ -119,7 +118,6 @@ rtc_executable("frame_analyzer") {
":video_file_writer", ":video_file_writer",
":video_quality_analysis", ":video_quality_analysis",
"../rtc_base:stringutils", "../rtc_base:stringutils",
"../test:fileutils",
"../test:perf_test", "../test:perf_test",
] ]
} }

View File

@ -136,7 +136,7 @@ def DecodeBarcodesInVideo(options, path_to_decoder, video, stat_file):
return 0 return 0
def _RunFrameAnalyzer(options, yuv_directory=None): def _RunFrameAnalyzer(options):
"""Run frame analyzer to compare the videos and print output.""" """Run frame analyzer to compare the videos and print output."""
cmd = [ cmd = [
options.frame_analyzer, options.frame_analyzer,
@ -152,17 +152,15 @@ def _RunFrameAnalyzer(options, yuv_directory=None):
cmd.append('--chartjson_result_file=%s' % options.chartjson_result_file) cmd.append('--chartjson_result_file=%s' % options.chartjson_result_file)
if options.aligned_output_file: if options.aligned_output_file:
cmd.append('--aligned_output_file=%s' % options.aligned_output_file) cmd.append('--aligned_output_file=%s' % options.aligned_output_file)
if yuv_directory: if options.yuv_directory:
cmd.append('--yuv_directory=%s' % yuv_directory) cmd.append('--yuv_directory=%s' % options.yuv_directory)
frame_analyzer = subprocess.Popen(cmd, stdin=_DevNull(), frame_analyzer = subprocess.Popen(cmd, stdin=_DevNull(),
stdout=sys.stdout, stderr=sys.stderr) stdout=sys.stdout, stderr=sys.stderr)
frame_analyzer.wait() frame_analyzer.wait()
if frame_analyzer.returncode != 0:
print 'Failed to run frame analyzer.'
return frame_analyzer.returncode return frame_analyzer.returncode
def _RunVmaf(options, yuv_directory): def _RunVmaf(options):
""" Run VMAF to compare videos and print output. """ Run VMAF to compare videos and print output.
The provided vmaf directory is assumed to contain a c++ wrapper executable The provided vmaf directory is assumed to contain a c++ wrapper executable
@ -176,8 +174,8 @@ def _RunVmaf(options, yuv_directory):
'yuv420p', 'yuv420p',
str(options.yuv_frame_width), str(options.yuv_frame_width),
str(options.yuv_frame_height), str(options.yuv_frame_height),
os.path.join(yuv_directory, "ref.yuv"), os.path.join(options.yuv_directory, "ref.yuv"),
os.path.join(yuv_directory, "test.yuv"), os.path.join(options.yuv_directory, "test.yuv"),
options.vmaf_model, options.vmaf_model,
] ]
if options.vmaf_phone_model: if options.vmaf_phone_model:
@ -191,13 +189,7 @@ def _RunVmaf(options, yuv_directory):
return 1 return 1
output = vmaf.stdout.read() output = vmaf.stdout.read()
# Extract score from VMAF output. # Extract score from VMAF output.
try:
score = float(output.split('\n')[2].split()[3]) score = float(output.split('\n')[2].split()[3])
except (ValueError, IndexError):
print 'Error in VMAF output (expected "VMAF score = [float]" on line 3):'
print output
return 1
print 'RESULT Vmaf: %s= %f' % (options.label, score) print 'RESULT Vmaf: %s= %f' % (options.label, score)
return 0 return 0
@ -234,21 +226,25 @@ def main():
options.test_video, options.stats_file_test) != 0: options.test_video, options.stats_file_test) != 0:
return 1 return 1
if options.vmaf:
try: try:
# Directory to save temporary YUV files for VMAF in frame_analyzer. # Create a directory to save temporary YUV files for VMAF in frame_analyzer.
yuv_directory = tempfile.mkdtemp() options.yuv_directory = None
if options.vmaf:
options.yuv_directory = tempfile.mkdtemp() + '/'
# Run frame analyzer to compare the videos and print output. # Run frame_analyzer to compare the videos and print output.
if _RunFrameAnalyzer(options, yuv_directory=yuv_directory) != 0: if _RunFrameAnalyzer(options) != 0:
print 'Failed to run frame analyzer.'
return 1 return 1
# Run VMAF for further video comparison and print output. # Run VMAF for further video comparison and print output.
return _RunVmaf(options, yuv_directory) if options.vmaf:
return _RunVmaf(options)
finally: finally:
shutil.rmtree(yuv_directory) if options.yuv_directory:
else: shutil.rmtree(options.yuv_directory)
return _RunFrameAnalyzer(options)
return 0 return 0

View File

@ -21,7 +21,6 @@
#include "rtc_tools/simple_command_line_parser.h" #include "rtc_tools/simple_command_line_parser.h"
#include "rtc_tools/video_file_reader.h" #include "rtc_tools/video_file_reader.h"
#include "rtc_tools/video_file_writer.h" #include "rtc_tools/video_file_writer.h"
#include "test/testsupport/fileutils.h"
#include "test/testsupport/perf_test.h" #include "test/testsupport/perf_test.h"
/* /*
@ -148,11 +147,9 @@ int main(int argc, char* argv[]) {
} }
std::string yuv_directory = parser.GetFlag("yuv_directory"); std::string yuv_directory = parser.GetFlag("yuv_directory");
if (!yuv_directory.empty()) { if (!yuv_directory.empty()) {
webrtc::test::WriteVideoToFile( webrtc::test::WriteVideoToFile(reordered_video, yuv_directory + "ref.yuv",
reordered_video, webrtc::test::JoinFilename(yuv_directory, "ref.yuv"),
/*fps=*/30); /*fps=*/30);
webrtc::test::WriteVideoToFile( webrtc::test::WriteVideoToFile(test_video, yuv_directory + "test.yuv",
test_video, webrtc::test::JoinFilename(yuv_directory, "test.yuv"),
/*fps=*/30); /*fps=*/30);
} }