Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Play .png file with relative path fails #1554

Open
Sidonai-1 opened this issue Sep 4, 2024 · 12 comments
Open

Bug: Play .png file with relative path fails #1554

Sidonai-1 opened this issue Sep 4, 2024 · 12 comments
Labels

Comments

@Sidonai-1
Copy link

Sidonai-1 commented Sep 4, 2024

Observed Behavior

On 2.4.x and 2.5 dev:

This png file with alpha fails to play if you use a relative path.

image

[2024-09-04 17:40:25.221] [info]    Received message from 127.0.0.1: PLAY 1-20 "FALDON_GANA ENERGIA.png" MIX 8 LINEAR RIGHT   \r\n
[2024-09-04 17:40:25.233] [error]   Exception: D:\a\server\server\src\modules\image\util\image_loader.cpp(77): Throw in function class std::shared_ptr<struct FIBITMAP> __cdecl caspar::image::load_image(const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &)
[2024-09-04 17:40:25.233] [error]   Dynamic exception type: class boost::exception_detail::clone_impl<struct caspar::invalid_argument>
[2024-09-04 17:40:25.233] [error]   [struct caspar::tag_msg_info * __ptr64] = Unsupported image format.
[2024-09-04 17:40:25.233] [error]   [struct caspar::tag_stacktrace_info * __ptr64] =  0# 0x00007FF672FF3427 in casparcg
[2024-09-04 17:40:25.233] [error]    1# 0x00007FF67301F7C6 in casparcg
[2024-09-04 17:40:25.233] [error]    2# 0x00007FF67313B656 in casparcg
[2024-09-04 17:40:25.233] [error]    3# 0x00007FF6731331CC in casparcg
[2024-09-04 17:40:25.233] [error]    4# 0x00007FF673133022 in casparcg
[2024-09-04 17:40:25.233] [error]    5# 0x00007FF673132EEF in casparcg
[2024-09-04 17:40:25.233] [error]    6# 0x00007FF673133981 in casparcg
[2024-09-04 17:40:25.233] [error]    7# 0x00007FF673130097 in casparcg
[2024-09-04 17:40:25.233] [error]    8# 0x00007FF673084704 in casparcg
[2024-09-04 17:40:25.233] [error]    9# 0x00007FF673084186 in casparcg
[2024-09-04 17:40:25.233] [error]   10# 0x00007FF673085FAE in casparcg
[2024-09-04 17:40:25.233] [error]   11# 0x00007FF6730855DC in casparcg
[2024-09-04 17:40:25.233] [error]   12# 0x00007FF6731031D9 in casparcg
[2024-09-04 17:40:25.233] [error]   13# 0x00007FF67310ADAD in casparcg
[2024-09-04 17:40:25.233] [error]   14# 0x00007FF6730F50B1 in casparcg
[2024-09-04 17:40:25.233] [error]   15# 0x00007FF6731278A8 in casparcg
[2024-09-04 17:40:25.233] [error]   16# 0x00007FF673127E2E in casparcg
[2024-09-04 17:40:25.233] [error]   17# 0x00007FF6730D59EA in casparcg
[2024-09-04 17:40:25.233] [error]   18# 0x00007FF673125C7C in casparcg
[2024-09-04 17:40:25.233] [error]   19# 0x00007FF6731242E9 in casparcg
[2024-09-04 17:40:25.233] [error]   20# 0x00007FF6731237E4 in casparcg
[2024-09-04 17:40:25.233] [error]   21# 0x00007FF673046CFF in casparcg
[2024-09-04 17:40:25.233] [error]   22# 0x00007FF673086EBE in casparcg
[2024-09-04 17:40:25.233] [error]   23# 0x00007FF673081806 in casparcg
[2024-09-04 17:40:25.233] [error]   24# configthreadlocale in ucrtbase
[2024-09-04 17:40:25.233] [error]   25# BaseThreadInitThunk in KERNEL32
[2024-09-04 17:40:25.233] [error]   26# RtlUserThreadStart in ntdll
[2024-09-04 17:40:25.233] [error]   
[2024-09-04 17:40:25.233] [error]   

[2024-09-04 17:40:25.233] [error]    0# 0x00007FF672FF3427 in casparcg
[2024-09-04 17:40:25.233] [error]    1# 0x00007FF672FF2EAA in casparcg
[2024-09-04 17:40:25.233] [error]    2# 0x00007FF6732B833C in casparcg
[2024-09-04 17:40:25.233] [error]    3# 0x00007FFD2DE31080 in VCRUNTIME140_1
[2024-09-04 17:40:25.233] [error]    4# _NLG_Return2 in VCRUNTIME140_1
[2024-09-04 17:40:25.233] [error]    5# RtlCaptureContext2 in ntdll
[2024-09-04 17:40:25.233] [error]    6# 0x00007FF673084186 in casparcg
[2024-09-04 17:40:25.233] [error]    7# 0x00007FF673085FAE in casparcg
[2024-09-04 17:40:25.233] [error]    8# 0x00007FF6730855DC in casparcg
[2024-09-04 17:40:25.233] [error]    9# 0x00007FF6731031D9 in casparcg
[2024-09-04 17:40:25.233] [error]   10# 0x00007FF67310ADAD in casparcg
[2024-09-04 17:40:25.233] [error]   11# 0x00007FF6730F50B1 in casparcg
[2024-09-04 17:40:25.233] [error]   12# 0x00007FF6731278A8 in casparcg
[2024-09-04 17:40:25.233] [error]   13# 0x00007FF673127E2E in casparcg
[2024-09-04 17:40:25.233] [error]   14# 0x00007FF6730D59EA in casparcg
[2024-09-04 17:40:25.233] [error]   15# 0x00007FF673125C7C in casparcg
[2024-09-04 17:40:25.233] [error]   16# 0x00007FF6731242E9 in casparcg
[2024-09-04 17:40:25.233] [error]   17# 0x00007FF6731237E4 in casparcg
[2024-09-04 17:40:25.233] [error]   18# 0x00007FF673046CFF in casparcg
[2024-09-04 17:40:25.233] [error]   19# 0x00007FF673086EBE in casparcg
[2024-09-04 17:40:25.233] [error]   20# 0x00007FF673081806 in casparcg
[2024-09-04 17:40:25.233] [error]   21# configthreadlocale in ucrtbase
[2024-09-04 17:40:25.233] [error]   22# BaseThreadInitThunk in KERNEL32
[2024-09-04 17:40:25.233] [error]   23# RtlUserThreadStart in ntdll
[2024-09-04 17:40:25.233] [error]   
[2024-09-04 17:40:25.831] [error]    File not found.
[2024-09-04 17:40:25.832] [info]    Sent message to 127.0.0.1:404 PLAY FAILED\r\n

The same file plays normally with a full path, but it shows white background on screen consumer:

[2024-09-04 18:03:58.050] [info]    Received message from 127.0.0.1: PLAY 1-20 "c://users/carlo/desktop/FALDON_GANA ENERGIA.png" MIX 8 LINEAR RIGHT   \r\n
[2024-09-04 18:03:58.051] [info]    Sent message to 127.0.0.1:202 PLAY OK\r\n

Some other png files don't exhibit this behaviour.
This one plays normally in both cases:
image

[2024-09-04 18:08:30.691] [info]    Received message from 127.0.0.1: PLAY 1-20 "CANAL3.png" MIX 8 LINEAR RIGHT   \r\n
[2024-09-04 18:08:30.716] [info]    image_producer[C:\APP_VID\MEDIA\CANAL3.png] Initialized
[2024-09-04 18:08:30.720] [info]    Sent message to 127.0.0.1:202 PLAY OK\r\n
[2024-09-04 18:08:34.751] [info]    Received message from 127.0.0.1: PLAY 1-20 "c://users/carlo/desktop/CANAL3.png" MIX 8 LINEAR RIGHT   \r\n
[2024-09-04 18:08:34.752] [info]    Sent message to 127.0.0.1:202 PLAY OK\r\n

Here goes both examples:

[PNG Fail 2.5.0.zip](https://github.com/user-attachments/files/16873771/PNG.Fail.2.5.0.zip)

Expected behaviour

It plays normally on 2.3.2

Environment

  • Server version: 2.4.x / 2.5.x vs 2.3.2
  • Operating system: Windows 10
@Sidonai-1
Copy link
Author

It probably has to do with the way photoshop handles different 'presets' when creating a new file.

I noticed that if I work in the Photoshop preset "HDTV", pasting the content from the original image yields a much smaller file size when saving it. We're talking 14MB vs 300KB. Funnily enough, MediaInfo doesn't show differences between the files, apart from size.

The smaller size works on versions 2.5.

The bigger size only on older 2.3.x

@Julusian
Copy link
Member

That failing png is strange, according to freeimage (the image loading library we use), it has 0 bytes per pixel. Which we/it doesn't know how to handle, so it gets rejected.
It is also worth noting that the image-viewer and gimp on ubuntu 22.04 both fail to open that png, and claim it is corrupt.

When it plays with the solid background, that is because ffmpeg is able to play it, but it doesn't provide us the alpha channel when it does so. That ffmpeg was given a chance to load this image sounds like a separate bug.

So I am leaning towards saying that this png is 'corrupt' or non-standard, and there isn't anything we can do to make this work. I don't know why it worked on older 2.3, perhaps the freeimage library got more strict and is now rejecting this weird image?

@Sidonai-1
Copy link
Author

Sidonai-1 commented Sep 19, 2024

It's weird because I tried to re-export it several times with different color profiles and got the same result. From the same file and creating a new 'project' as well.

How can it be that Photoshop 2024 is creating corrupt .png files unless you start from a HDTV preset?

Also, it happens with several other files like this, so it's not a one off or just with this combination of pixels.

@Julusian
Copy link
Member

I wonder if photoshop is producing a "PNG 3rd Edition" or similar newer revision of png that freeimage/libpng doesnt know how to decode?
Or could be some other format/data field of a format which the library doenst support?

@dimitry-ishenko
Copy link
Contributor

dimitry-ishenko commented Sep 19, 2024

FWIW this is what I am seeing on Linux with 2.4.0. I did use full path to play it:

play 1 /home/dimitry/tmp/corrupt.png

UPDATE

And, I get the same result if I play it with relative path:

play 1 corrupt

However, if the black areas around the image are supposed to be transparent, then alpha does not work in either case.

Screenshot from 2024-09-19 10-23-11

@Sidonai-1
Copy link
Author

Sidonai-1 commented Sep 19, 2024

Here's another example, in case it helps.

Does the T19 file also fails to open on Ubuntu?

png conexion.zip

Gimp on Windows opens them all no problem, and from those 14MB files it exports a valid 100KB file

I wonder if photoshop is producing a "PNG 3rd Edition" or similar newer revision of png that freeimage/libpng doesnt know how to decode? Or could be some other format/data field of a format which the library doenst support?

Could be, but I cannot find any proof of that change, I am testing with this and some others like it: https://www.nayuki.io/page/png-file-chunk-inspector

This tool told me about the Adobe 1998 color space of one of them, so that was one difference, but changing it to match the correct file didn't fix it.

FWIW this is what I am seeing on Linux with 2.4.0. I did use full path to play it:

@dimitry-ishenko download the .zip from the first post; the image shown was just a screenshot as a visual reference.

@dimitry-ishenko
Copy link
Contributor

@Sidonai-1 LOL then you can probably ignore my comments. I don't see a .zip attached to the first post though...

@Sidonai-1
Copy link
Author

Sidonai-1 commented Sep 19, 2024

@Sidonai-1 LOL then you can probably ignore my comments. I don't see a .zip attached to the first post though...

PNG Fail 2.5.0.zip

I don't know why it was formatted like that at the bottom of the post


Update: Now I managed to get proper (only #KB) .png files starting from a "custom 1920x1080" preset (without the HDTV label) but honestly I don't know how I managed that.
If you open the 14MB files and save them again, they'll still be 'corrupt' for Caspar.

@stevespaw
Copy link

Sorry to jump in - I just find this interesting - Windows 11 paint opens all of these just fine, with alpha, for some reference.
image
image

@Sidonai-1
Copy link
Author

Sorry to jump in - I just find this interesting - Windows 11 paint opens all of these just fine, with alpha, for some reference.
image
image

Yeah Windows seems to have no problem at all with those.

With the exception of VLC, which seems to suffer the same problem as Caspar 🫠

@dimitry-ishenko
Copy link
Contributor

@Sidonai-1 All of them play just fine for me on Ubuntu 24.04 with CasparCG 2.4.0

Screenshot from 2024-09-19 11-40-02

@Julusian
Copy link
Member

Julusian commented Sep 19, 2024

Then perhaps this is a bug in/caused by libpng?
On windows we are using freeimage 3.18.0 which uses libpng 1.6.35
ubuntu 22.04 (my testing) uses ~1.6.37
ubuntu 24.04 uses ~1.6.43

All 3 cases are using freeimage ~3.18.0, so I think it is unlikely to be a bug there

That would explain why gimp and image viewer won't open it for me either, they will all be using the same version of libpng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants