• SatyrSack@quokk.au
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 hours ago

    Do GIFs from some site come in AVIF format now? Or did you make this yourself?

    • M.int@lemmy.zipOP
      link
      fedilink
      arrow-up
      1
      ·
      4 hours ago

      I made it myself. Here is the ffmpeg command for anyone interested:

      ffmpeg -ss 00:22:47.700 -to 00:22:51.745 -i  *S05E14*  \
          	-filter_complex "[0:v][0:s:0]overlay" \
          	-an -c:v libsvtav1 -crf 34 -preset 0 -svtav1-params fast-decode=2  \
          	-g 300 -pix_fmt yuv420p -loop 0 \
      	'DS9 Way to the Wormhole (small)'.avif
      
      
      • -filter_complex "[0:v][0:s:0]overlay" hardcodes the dvd subs
      • -an -c:v libsvtav1 -crf 34 -preset 0 -svtav1-params fast-decode=2
        • no audio, svt-av1, fast-decode=2 for better playback (maybe just placebo)
      • -g 300 keyframe interval, should probably be higher since we don’t need any
      • loop 0 loops infinitely; for avif, in contrast to gif, you can actually specify how often it should loop.

      Funny thing, the low-quality webp thumbnail that lemmy generated is nearly twice the size of my encoded avif.
      236KiB webp thumbnail vs. 128KiB avif

      • SatyrSack@quokk.au
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        4 hours ago

        I will try messing with something like that. My method for making AVIF animations is to pipe it to avifenc, because I couldn’t get ffmpeg to do it all:

        ffmpeg -hide_banner -loglevel error -i video.mp4 -pix_fmt yuv420p -f yuv4mpegpipe -fps_mode passthrough -vf "fps=25, scale=-1:480" -quality 80 - | avifenc --stdin image.avif >/dev/null
        

        EDIT: I just tried your ffmpeg-only command, and it worked, it was just a lot slower than my avifenc-piped command. Now that I think about it, I believe I had gotten it to work entirely with ffmpeg before, but decided to stick with my avifenc method simply because it is much more efficient.

        • M.int@lemmy.zipOP
          link
          fedilink
          arrow-up
          1
          ·
          3 hours ago

          Change -preset 0 to a higher value; this is the lowest setting and it should in most cases severely slowdown encoding. A value of -preset 6 should be way faster. According to the ffmpeg wiki you can choose between 0 and 13 (13 only for debugging). Higher value → faster encoding. A lower value should give, in most cases, a smaller file (sometimes not; I had cases where 4 was smaller than 0).
          I only used 0 here since it was such a small clip of low-ish resolution and encoding with -preset 0 and -preset 4 were both nearly instantaneous. (size comparison here -preset 0 128K and preset 4 135K)

          • SatyrSack@quokk.au
            link
            fedilink
            English
            arrow-up
            2
            ·
            3 hours ago

            Nice, changing that to 6 sure made it convert just as quickly as I expect. The resulting image quality seems fine as well, while actually being a slightly smaller file than what I get with my avifenc method.

            Any idea why it dumps out this extra info every time I run it? I specifically use -hide_banner -loglevel error to avoid this type of thing. Even putting >/dev/null at the end of the command doesn’t stop it.

            $ ffmpeg -y -hide_banner -loglevel error -i *.mp4 -an -c:v libsvtav1 -crf 34 -preset 6 -svtav1-params fast-decode=2 -g 300 -pix_fmt yuv420p -vf "fps=25, scale=-1:480" -quality 80 'test3'.avif >/dev/null
            Svt[info]: -------------------------------------------
            Svt[info]: SVT [version]:       SVT-AV1 Encoder Lib v3.1.2
            Svt[info]: SVT [build]  :       GCC 16.0.1 20260115 (Red Hat 16.0.1-0)   64 bit
            Svt[info]: -------------------------------------------
            Svt[info]: Level of Parallelism: 5
            Svt[info]: Number of PPCS 76
            Svt[info]: [asm level on system : up to avx512icl]
            Svt[info]: [asm level selected : up to avx512icl]
            Svt[info]: -------------------------------------------
            Svt[info]: SVT [config]: main profile   tier (auto)     level (auto)
            Svt[info]: SVT [config]: width / height / fps numerator / fps denominator               : 640 / 480 / 25 / 1
            Svt[info]: SVT [config]: bit-depth / color format                                       : 8 / YUV420
            Svt[info]: SVT [config]: preset / tune / pred struct                                    : 6 / PSNR / random access
            Svt[info]: SVT [config]: gop size / mini-gop size / key-frame type                      : 300 / 16 / key frame
            Svt[info]: SVT [config]: BRC mode / rate factor                                         : CRF / 34 
            Svt[info]: SVT [config]: AQ mode / Variance Boost                                       : 2 / 0
            Svt[info]: SVT [config]: sharpness / luminance-based QP bias                            : 0 / 0
            Svt[info]: -------------------------------------------
            
            • M.int@lemmy.zipOP
              link
              fedilink
              arrow-up
              1
              ·
              2 hours ago

              Glad that it worked for you!

              I have no detailed knowledge of how to suppress specific information output of ffmpeg. I actually like that it vomits out so much information; I have my terminal scroll back set to essentially infinite and can so better analyze what went wrong or not quite right.


              Okay, now I know more: svt-av1 apparently pipes all its info as stderr, and that’s why -loglevel error doesn’t suppress it and why >/dev/null also doesn’t suppress it since this only redirects stdout to the void. You could do 2> /dev/null and suppress all stderr, or you could append it to a temp file with 2>> /tmp/ffmpeg-error.txt.

              But I found a better solution in a superuser answer:
              You can use the SVT_LOG environment variable like so:

              SVT_LOG=1 ffmpeg -y -hide_banner -loglevel error -i *.mp4 -an -c:v libsvtav1 -crf 34 -preset 6 -svtav1-params fast-decode=2 -g 300 -pix_fmt yuv420p -vf "fps=25, scale=-1:480" 'test4'.avif
              

              SVT_LOG=1 only gives actual errors, and you can make it permanent by adding export SVT_LOG=1 to your shell profile.


              Another thing: -quality 80 doesn’t do anything, and ffmpeg even gives a warning, which you suppressed. Quality is being controlled by -crf 34, see the wiki.

        • M.int@lemmy.zipOP
          link
          fedilink
          arrow-up
          1
          ·
          3 hours ago

          I messed around a bit with avifenc and it gave me generally larger encodes with worse quality than just svt-av1 and rav1e with just ffmpeg. Also I remember getting numerous errors with ffmpeg complaining about piping this or that format. I wouldn’t even know which commands in my shell history actually worked. I have to try again with avifenc and experiment more with rav1e too both in ffmpeg and avifenc.

    • daggermoon@piefed.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      5 hours ago

      He made it himself. Lemmy rejects every .jxl I try to upload though. Chrome and Firefox support it so why can’t I upload it?

      • SatyrSack@quokk.au
        link
        fedilink
        English
        arrow-up
        3
        ·
        4 hours ago

        My guess is that JXL is just not on the list of image formats that the site recognizes. I assume if you mention that to your instance admin, it would be simple to enable it. They probably need to configure the instance to understand “this is a totally legitimate file format, not random malware you’ve never heard of”.

        • M.int@lemmy.zipOP
          link
          fedilink
          arrow-up
          2
          ·
          3 hours ago

          lemmy-ui doesn’t support JPEG XL; see this Github issue.

          I can upload JPEG XL images to my instance (lemmy.zip), but they get automatically converted to avif.

          example

          JPEG XL converted to avif
          This was originally a JPEG XL image

          I can embed external JPEG XL images from a file host

          JPEG XL external catbox.moe


          Just realized you both aren’t on lemmy but on piefed and pylova respectively. I actually don’t know the support status of JPEG XL with those two and a quick search of their issues on codeberg didn’t reveal anything.

          • SatyrSack@quokk.au
            link
            fedilink
            English
            arrow-up
            3
            ·
            3 hours ago

            Just realized you both aren’t on lemmy but on piefed and pylova respectively. I actually don’t know the support status of JPEG XL with those two and a quick search of their issues on codeberg didn’t reveal anything.

            I made a post on my instance’s meta community about JPEG-XL support. The admin (who is also the dev of PyLova) seemed receptive of the idea, but it didn’t seem to go anywhere.

            https://quokk.au/c/meta/p/1160979/jpeg-xl-support

            But AVIF seems great and better than JPEG-XL anyway. I don’t mind prioritizing that.