fraunhoferhhi / vvenc

VVenC, the Fraunhofer Versatile Video Encoder
https://www.hhi.fraunhofer.de/en/departments/vca/technologies-and-solutions/h266-vvc.html
BSD 3-Clause Clear License
942 stars 170 forks source link

y4m input not working when piped #150

Closed RockPolish closed 2 years ago

RockPolish commented 2 years ago

Hi all, I can't get vvenc to correctly read the input parameters like resolution and framerate when piping y4m input to it, while it does work when reading from a .y4m file. Instead, when piping y4m, it defaults to 1080p 60 FPS. The following script converts the input file (a 1 second 720p30 clip) to y4m in two different ways which produce identical output. It then calls vvenc in three different ways first passing the .y4m file, then piping either from ffmpeg or directly from the .y4m file, in each case decoding the produced output to a new .y4m file.

ffmpeg -i input.mp4 -nostdin -f yuv4mpegpipe -pix_fmt yuv420p - > pipe.y4m
ffmpeg -i input.mp4 -pix_fmt yuv420p notpipe.y4m

# 1
vvencapp -i pipe.y4m -o 1.vvc
vvdecapp -b 1.vvc --y4m -o 1.y4m

# 2
ffmpeg -i input.mp4 -nostdin -f yuv4mpegpipe -pix_fmt yuv420p - | vvencapp -i - -o 2.vvc
vvdecapp -b 2.vvc --y4m -o 2.y4m

# 3
cat pipe.y4m | vvencapp -i - -o 3.vvc
vvdecapp -b 3.vvc --y4m -o 3.y4m

md5sum *.y4m
md5sum *.vvc

The md5 output is as follows:

f2c243637e5085fe5ded265c78074747  1.y4m
cac0b5c6e5248b0d4e8fd2ebf03af0c4  2.y4m
cac0b5c6e5248b0d4e8fd2ebf03af0c4  3.y4m
4c502af9c24dd314c751178efe28d0c5  notpipe.y4m
4c502af9c24dd314c751178efe28d0c5  pipe.y4m
63bd8e9a734b5eb27e46c6420db5da7e  1.vvc
1b3d76be32be4ae6fc0df9f402fb2095  2.vvc
1b3d76be32be4ae6fc0df9f402fb2095  3.vvc

Only 1.vvc & 1.y4m are correct 720p30 video and not the 720p pixels but viewed as a 1080p clip:

> head 1.y4m 2.y4m
==> 1.y4m <==
YUV4MPEG2 W1280 H720 F30:1 Ip C420p10
FRAME ...

=> 2.y4m <==
YUV4MPEG2 W1920 H1080 F60:1 Ip C420p10
FRAME ...

Platform: Ubuntu 18.04 (WSL 2) Version: ver. 1.4.0-rc1

adamjw24 commented 2 years ago

You need to specify that the input pipe is a Y4M, since it cannot be inferred from the file extension (add --y4m 1 to the cmd). See vvencapp --fullhelp for details.

RockPolish commented 2 years ago

Oh I see, I figured it would be derived from the header. Sorry for the inconvenience