kopia lustrzana https://github.com/corrscope/corrscope
Fix bug where test_output writes to ./- instead of stdout
Also remove gibberish from test_outputpull/357/head
rodzic
ba17f64618
commit
f917c3bdc6
|
@ -3,7 +3,7 @@ import shlex
|
|||
import subprocess
|
||||
from abc import ABC, abstractmethod
|
||||
from os.path import abspath
|
||||
from typing import TYPE_CHECKING, Type, List, Union
|
||||
from typing import TYPE_CHECKING, Type, List, Union, Optional
|
||||
|
||||
from ovgenpy.config import register_config
|
||||
|
||||
|
@ -124,7 +124,8 @@ class PipeOutput(Output):
|
|||
|
||||
@register_config
|
||||
class FFmpegOutputConfig(IOutputConfig):
|
||||
path: str
|
||||
# path=None writes to stdout.
|
||||
path: Optional[str]
|
||||
args: str = ''
|
||||
|
||||
# Do not use `-movflags faststart`, I get corrupted mp4 files (missing MOOV)
|
||||
|
@ -142,7 +143,13 @@ class FFmpegOutput(PipeOutput):
|
|||
ffmpeg = _FFmpegCommand([FFMPEG, '-y'], ovgen_cfg)
|
||||
ffmpeg.add_output(cfg)
|
||||
ffmpeg.templates.append(cfg.args)
|
||||
self.open(ffmpeg.popen([abspath(cfg.path)], self.bufsize))
|
||||
|
||||
if cfg.path is None:
|
||||
video_path = '-' # Write to stdout
|
||||
else:
|
||||
video_path = abspath(cfg.path)
|
||||
|
||||
self.open(ffmpeg.popen([video_path], self.bufsize))
|
||||
|
||||
|
||||
# FFplayOutput
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
@ -13,14 +14,13 @@ if TYPE_CHECKING:
|
|||
import pytest_mock
|
||||
|
||||
CFG = default_config(render=RendererConfig(WIDTH, HEIGHT))
|
||||
STDOUT_CFG = FFmpegOutputConfig('-', '-f nut')
|
||||
NULL_CFG = FFmpegOutputConfig(None, '-f null')
|
||||
|
||||
|
||||
def test_render_output():
|
||||
""" Ensure rendering to output does not raise exceptions. """
|
||||
renderer = MatplotlibRenderer(CFG.render, CFG.layout, nplots=1)
|
||||
output_cfg = FFmpegOutputConfig('-', '-f nut')
|
||||
out = FFmpegOutput(CFG, output_cfg)
|
||||
out: FFmpegOutput = NULL_CFG(CFG)
|
||||
|
||||
renderer.render_frame([ALL_ZEROS])
|
||||
out.write_frame(renderer.get_frame())
|
||||
|
@ -29,12 +29,14 @@ def test_render_output():
|
|||
|
||||
|
||||
def test_output():
|
||||
out = FFmpegOutput(CFG, STDOUT_CFG)
|
||||
out: FFmpegOutput = NULL_CFG(CFG)
|
||||
|
||||
frame = bytes(WIDTH * HEIGHT * RGB_DEPTH)
|
||||
out.write_frame(frame)
|
||||
|
||||
assert out.close() == 0
|
||||
# Ensure video is written to stdout, and not current directory.
|
||||
assert not Path('-').exists()
|
||||
|
||||
|
||||
# Ensure ovgen terminates FFplay upon exceptions.
|
||||
|
|
Ładowanie…
Reference in New Issue