wader / static-ffmpeg

Multi-arch docker image with ffmpeg/ffprobe binaries built as hardened static PIE binaries with no external dependencies
https://hub.docker.com/r/mwader/static-ffmpeg/
MIT License
269 stars 65 forks source link

Animated AVIF support - possible to build with libheif ? #530

Closed ghnp5 closed 1 month ago

ghnp5 commented 1 month ago

I'm using this static ffmpeg so that I can have ffmpeg v7 in Alpine docker (musl).

However, when using this, I can no longer convert animated AVIF to MP4. It does convert, but the MP4 doesn't show the animation. Just the first frame or so.

While, with ffmpeg v6 + libheif installed from the Alpine repository, it works well (animation shown perfectly in the MP4 file, and file size bigger than the MP4 file created by the static ffmpeg v7).

Is it possible to compile ffmpeg with libheif, statically?

Many thanks!

wader commented 1 month ago

Hello! strange for what i can see ffmpeg does not support linking with libheif? but maybe it has native support for it, at decode? looking at the alpine build script it seems to not link with libheif either https://git.alpinelinux.org/aports/tree/community/ffmpeg/APKBUILD 🤔

Could there be some regression in ffmpeg v7 that your hitting? it would be good if you could provide full command line, example file if possible and log using -v trace for both when it works and when it does not.

BTW does it work with mwader/static-ffmpeg:6.0 etc?

ghnp5 commented 1 month ago

Hey! Thank you for your reply.

Here is a zip with:

animated-avif.zip

The commands:

/usr/bin/ffmpeg -i /staging/animated-avif.avif -map_metadata -1 -pix_fmt yuv420p -c:v libx264 -crf 24 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' -v trace /staging/animated-avif-ffmpeg-6-apk.mp4 > /staging/animated-avif-ffmpeg-6-apk.log 2>&1

/usr/local/bin/ffmpeg6 -i /staging/animated-avif.avif -map_metadata -1 -pix_fmt yuv420p -c:v libx264 -crf 24 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' -v trace /staging/animated-avif-ffmpeg-6-static.mp4 > /staging/animated-avif-ffmpeg-6-static.log 2>&1

/usr/local/bin/ffmpeg7 -i /staging/animated-avif.avif -map_metadata -1 -pix_fmt yuv420p -c:v libx264 -crf 24 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' -v trace /staging/animated-avif-ffmpeg-7-static.mp4 > /staging/animated-avif-ffmpeg-7-static.log 2>&1
ghnp5 commented 1 month ago

On Windows, with ffmpeg v7 installed with chocolatey, I'm also having the same issue. So, I believe this isn't an issue specifically with the static builds.

I've just reported the bug: https://trac.ffmpeg.org/ticket/11201

wader commented 1 month ago

Thanks. Had a quick look and the biggest difference i can see is that ffmpeg 7 for some reason demuxes the input file into 4 streams (maybe still image?, still image alpha? video? video alpha?) so if you do this it seems to work with ffmpeg 7:

ffmpeg -i animated-avif.avif -map 0:2 animated-avif.avif.mp4

Don't know yet if this is the intended behaviour or not. If so maybe you want to see if there is some stream selector you can use that will select the correct one, -map 0:v:0 seems to still select the first but maybe there is some way.

wader commented 1 month ago

Looks like there was a bunch of heif improvements in 7.0 like https://github.com/FFmpeg/FFmpeg/commit/41e349c24a726d0c3bac5830eec9f6940ea41c63 that probably changed the streams a bit. But i wonder if there is some way of selecting the stream you want using a selector 🤔

ghnp5 commented 1 month ago

Thank you very much!

I passed this feedback to the bug reported in the other link, to see what they say.

Really appreciate your help ✌🏻

wader commented 1 month ago

Close issue? don't think there is any change to be made to static-ffmpeg more than a possible future ffmpeg release with a fix/change?