[FFmpeg-user] How to pipe png output from FFmpeg into cavif.
bat guano
batguano999 at hotmail.com
Mon Mar 15 17:17:44 EET 2021
Hi
FFmpeg doesn't have ability to create avif image files (yet).
I have used FFmpeg to re-size png files then convert them with cavif program.
(Releases of cavif are here ---> https://github.com/kornelski/cavif-rs/releases)
Like this...
ffmpeg -i infile.png -vf scale="424:-1" temp.png; cavif --output outfile.avif temp.png
$ ffmpeg -i infile.png -vf scale="424:-1" temp.png; cavif --output outfile.avif temp.png
ffmpeg version N-101507-gb2d0826 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
configuration: --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libmp3lame --enable-libvorbis --enable-libwebp --enable-libx264
libavutil 56. 68.100 / 56. 68.100
libavcodec 58.131.100 / 58.131.100
libavformat 58. 73.100 / 58. 73.100
libavdevice 58. 12.100 / 58. 12.100
libavfilter 7.109.100 / 7.109.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Input #0, png_pipe, from 'infile.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 800x505 [SAR 2835:2835 DAR 160:101], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'temp.png':
Metadata:
encoder : Lavf58.73.100
Stream #0:0: Video: png, rgba(pc, progressive), 424x268 [SAR 5360:5353 DAR 160:101], q=2-31, 200 kb/s, 25 fps, 25 tbn
Metadata:
encoder : Lavc58.131.100 png
frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=1.07x
video:65kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
outfile.avif: 17KB (16668B color, 0B alpha, 188B HEIF)
=======================================================================================
But cavif has an option to accept input from stdin.
$ ./cavif --version
cavif-rs 0.6.6
$ ./cavif --help
cavif-rs 0.6.6
Kornel Lesiński <kornel at imageoptim.com>
Convert JPEG/PNG images to AVIF image format (based on AV1/rav1e)
USAGE:
cavif [OPTIONS] [IMAGES]...
OPTIONS:
-Q, --quality <n> Quality from 1 (worst) to 100 (best) [default: 80]
-s, --speed <n> Encoding speed from 1 (best) to 10 (fast but ugly)
[default: 1]
-f, --overwrite Replace files if there's .avif already
-o, --output <path> Write output to this path instead of same_file.avif.
It may be a file or a directory.
-q, --quiet Don't print anything
--dirty-alpha Keep RGB data of fully-transparent pixels (makes
larger, lower quality files)
--color <color> Internal AVIF color space [default: ycbcr] [possible
values: ycbcr, rgb]
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<IMAGES>... One or more JPEG or PNG files to convert. "-" is
interpreted as stdin/stdout.
======================================================================================
How do I make FFmpeg send it's png output to stdout?
With a command like this...
ffmpeg -i infile.png -vf scale="424:-1" -; cavif --output outfile.avif -
I think I need to define a format for FFmpeg with "-f whatever"
What format would be needed?
$ ffmpeg -i infile.png -vf scale="424:-1" -; cavif --output outfile.avif -
ffmpeg version N-101507-gb2d0826 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
configuration: --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libmp3lame --enable-libvorbis --enable-libwebp --enable-libx264
libavutil 56. 68.100 / 56. 68.100
libavcodec 58.131.100 / 58.131.100
libavformat 58. 73.100 / 58. 73.100
libavdevice 58. 12.100 / 58. 12.100
libavfilter 7.109.100 / 7.109.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Input #0, png_pipe, from 'infile.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 800x505 [SAR 2835:2835 DAR 160:101], 25 fps, 25 tbr, 25 tbn, 25 tbc
[NULL @ 0x3f96480] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argument
======================================================================================
More information about the ffmpeg-user
mailing list