使用FFmpeg将HEIF文件转换为PNG/JPG

13

这个用例非常简单。Imagemagick能够完成转换,但我想使用ffmpeg来完成它。以下是我尝试过的所有命令,但它们都报错“找不到moov原子”。

ffmpeg -i /Users/ajitesh/Downloads/sample1.heif -c:v png -pix_fmt rgb48 /Users/ajitesh/Downloads/sample.png

输出

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f85aa813200] moov atom not found
/Users/ajitesh/Downloads/sample1.heif: Invalid data found when processing input

尝试使用以下命令提取moov原子的位置,似乎moov原子实际上不存在。

Translated text:

通过尝试使用以下命令来提取moov原子位置,看起来moov原子实际上不存在。

ffmpeg -v trace -i /Users/ajitesh/Downloads/sample1.heif 2>&1 | grep -e type:\'mdat\' -e type:\'moov\'

输出

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f824c00f000] type:'mdat' parent:'root' sz: 2503083 420 2503495
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f824c00f000] type:'mdat' parent:'root' sz: 2503083 420 2503495
2个回答

17

截止到2021年1月11日,FFmpeg目前不支持HEIF解码。

请参考错误报告#6521: HEIF支持。由于FFmpeg开发活跃,未来情况可能会有所变化。


对于那些只想要一个转换文件的命令的人,我推荐在MacOS上使用sips。https://apple.stackexchange.com/a/410920 - Barry McNamara

6

哎呀,现在已经是2023年了,ffmpeg仍然不支持heif图像格式。我建议使用heif-convert,它可以通过所有主要的Linux软件包管理器和Homebrew获取。

以下是在主要Linux发行版和macOS上安装和使用heif-convert的说明。它的用法如下:

heif-convert input.[heic|heif] output.[png|jpg]

你可以通过以下方式安装它:

  1. Ubuntu/Debian:
sudo apt-get install libheif1
  1. Fedora:
sudo dnf install libheif
  • RHEL/CentOS:
  • sudo yum install epel-release libheif
    
    1. Arch Linux:
    sudo pacman -S libheif
    
    1. openSUSE:
    sudo zypper install libheif1
    
  • macOS:
  • brew install libheif
    

    网页内容由stack overflow 提供, 点击上面的
    可以查看英文原文,
    原文链接