将14位TIF图像转换为H264编码帧
背景
我正在尝试将 tiff 图像转换为 h.264 编码帧。我正在使用 FFMPEG 来做到这一点。对于 PNG,我可以使用以下命令进行转换,
./ffmpeg -loglevel error -hide_banner -i /path/to/input.png -c:v libx264 -pix_fmt yuv420p10le /path/to/outputFrame.h264
这效果很好,并给了我一个合适的框架。 PNG 是 16 位灰度。
我尝试使用 14 位灰度 tif 作为输入进行以下操作
./ffmpeg -loglevel error -hide_banner -i /path/to/input.tiff -c:v libx264 -pix_fmt yuv420p10le /path/to/outputFrame.h264
,但出现错误: 不支持此格式(bpp=14,bppcount=1)
我已阅读其他地方
FFmpeg 支持高达 16 bpc RGB TIFF 或 8 位 YUV TIFF 或 16 位 灰度的..
所以使用imagemagick识别功能来验证我的tif 它表示这确实是一个 14 位灰度的灰度图像。
所以我尝试了 10 位版本,这给了我与上面相同的错误,只是现在 bpp=10 而不是 bpp=14。
然后我发现 pix-fmt 已关闭,因此我尝试使用 10 位图像使用 Gray10le,但没有成功。同样的错误。
无论如何,我希望获得图像的完整位深度,因此更喜欢 16 或 14 位解决方案。
我的问题
如何使用 ffmpeg 或 Imagemagick 获取 14 位 TIF 并将其转换为 h264 编码帧,保持 h264 允许的最高位深度?我也不想转换为中间格式。 上运行
我正在 CentOS Linux更新
当我使用 TIF 强制将深度降低到 8 并将其发送到上面的 ffmpeg 命令时,它确实会通过,但是当我在 VLC 中打开框架时,它不会像以前那样出现当我用 16 位灰度 PNG 做同样的事情时......
更新 2 根据评论,我尝试将 tif 强制为 16 位灰度,这与我在以 PNG 为中心的 ffmpeg 命令中使用的原始像素格式兼容。
我仍然很难在 VLC 中显示该帧,但这可能是由于图像的大小所致。它是相当大的。我将尝试平铺它以确保数据完好无损。如果它不完整,问题仍然存在。如果它完好无损,我只会“回答我自己的问题”
Background
I am trying to convert a tiff image to an h.264 encoded frame. I am using FFMPEG to do so. With a PNG, I can convert using the following command
./ffmpeg -loglevel error -hide_banner -i /path/to/input.png -c:v libx264 -pix_fmt yuv420p10le /path/to/outputFrame.h264
This works great and gives me a proper frame.
The PNG is 16 bit greyscale.
I tried the following with a 14bit greyscale tif as an input
./ffmpeg -loglevel error -hide_banner -i /path/to/input.tiff -c:v libx264 -pix_fmt yuv420p10le /path/to/outputFrame.h264
and got an error:This format is not supported (bpp=14, bppcount=1)
I had read elsewhere that
FFmpeg does support upto 16 bpc RGB TIFFs or 8 bit YUV TIFFs or 16 bit
grayscale ones..
So used imagemagick identify function to verify my tif
it stated that it was indeed a 14 bit grayscale gray image.
So I tried a 10bit version, this gave me same error above except it was now bpp=10 instead of bpp=14.
I then figured the pix-fmt was off, so I tried gray10le with the 10bit image with no luck. Same error.
I want to have the full bit depth of the image anyways, so would prefer a 16 or 14 bit solution.
My Question
How can I take a 14 bit TIF and convert it to a h264 encoded frame using ffmpeg or Imagemagick maintaining the highest bit depth that h264 will allow? I also would prefer not to convert to an intermediary format. I am running on CentOS Linux
Update
When I force the depth down to 8 with the TIF and send it into the above ffmpeg command, it does go through but when I go to open the frame in VLC, it does not come up like it does when I do the same thing with a 16 bit greyscale PNG...
Update 2
Per a comment, I tried forcing the tif to 16 bit grayscale and that worked with the original pixel formats I had in the PNG-centered ffmpeg command.
I am still having a hard time displaying the frame in VLC, but it could be due to the size of the image. It is quite large. I will try tiling it to make sure the data is intact. If its not intact, the question still stands. If its intact I will just "answer my own question"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如凯什在评论中提到的:
他是对的,我确保我的 TIFF 是 16 位灰度而不是 14 位,并且它进入 FFMPEG 没有问题。
然后,我平铺数据进行检查,并确保转换为 h264 按计划进行。看起来不错。
TL;DR 回答
如果您希望进入 FFMPEG 的灰度 TIF 正确编码为 h.264,请确保它们是 8 或 16 位(8 的倍数)位深度。
As Kesh mentioned in the comment:
He was right, I made sure my TIFF was 16 bit greyscale instead of 14, and it went into FFMPEG no problem.
I then tiled my data to check it and make sure the conversion to h264 went as planned. It looks good.
TL;DR Answer
Make sure greyscale TIFs going into FFMPEG are 8 or 16 bit (multiples of 8) bit depth if you want them to encode into h.264 properly.