On Guix, sound is only one frame

Similar issue to what’s reported here:

[solved] Sound is only one frame

except the solution (to convert mp3 to wav) doesn’t work for me. Imported WAV files and MP3 files all result in a single sound layer frame, with no audio being played.

Despite the fact that audio does not play from within pencil2d, when I go to export the movie, I hear the audio played as expected.

I suspect that that pencil2d is unable to find ffmpeg libraries.

I have tested with pencil2d 0.6.6 which is packaged with guix, and I have also tested with pencil 0.7.2, which I compiled myself according to the following package definition:

(define-module (gnu packages animation)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system meson)
  #:use-module (gnu packages)
  #:use-module (gnu packages algebra)
  #:use-module (gnu packages assembly)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages dejagnu)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages graphics)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages image)
  #:use-module (gnu packages imagemagick)
  #:use-module (gnu packages jemalloc)
  #:use-module (gnu packages mp3)
  #:use-module (gnu packages networking)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages pulseaudio)
  #:use-module (gnu packages python)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages video)
  #:use-module (gnu packages xiph))

(define-public pencil2d
  (package
    (name "pencil2d")
    (version "0.7.2")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/pencil2d/pencil")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1g56f1ng6v0z9f7hj9hl358p189j1my092472pravpn9z9669gvp"))))
    (build-system gnu-build-system)
    (inputs
     (list bash-minimal
           qtbase-5
           qtxmlpatterns-5
           qtmultimedia-5
           qtsvg-5
           qtwayland-5
           ;; Added myself
           ffmpeg
           qttools))
    ;; Added myself
    (native-inputs
     (list ffmpeg))
    (arguments
     (list
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'fix-tests
            (lambda _
              ;; Its bundled catch2-2.5.0 fails to build with glibc-2.35.
              (copy-file #$(file-append catch2 "/include/catch2/catch.hpp")
                         "tests/src/catch.hpp")))
          (replace 'configure
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (invoke "qmake" (string-append "PREFIX=" out)))))


          (add-after 'install 'wrap-executable
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out"))
                    (plugin-path (getenv "QT_PLUGIN_PATH")))
                (wrap-program (string-append out "/bin/pencil2d")
                  `("QT_PLUGIN_PATH" ":" prefix (,plugin-path))))))

          ;; Added myself
          (add-after 'install 'wrap-qt6-env
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
                     ;; Qt6 plugin directory (CRITICAL DIFFERENCE)
                     (plugins (string-append out "/lib/qt6/plugins")))
                (wrap-program (string-append out "/bin/pencil2d")
                  `("QT_PLUGIN_PATH" ":" prefix (,plugins))
                  `("QT_QPA_PLATFORM_PLUGIN_PATH" ":" prefix
                    (,(string-append plugins "/platforms"))))))))))
    (home-page "https://www.pencil2d.org")
    (synopsis "Make 2D hand-drawn animations")
    (description
     "Pencil2D is an easy-to-use and intuitive animation and drawing tool.  It
lets you create traditional hand-drawn animations (cartoons) using both bitmap
and vector graphics.")
    (license license:gpl2)))

pencil2d

Here is the audio file that I am testing with:

Any advice would be greatly appreciated!

Resolved with the following package definition:

(define-public pencil2d
  (package
    (name "pencil2d")
    (version "0.7.2")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/pencil2d/pencil")
                     (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1g56f1ng6v0z9f7hj9hl358p189j1my092472pravpn9z9669gvp"))))
    (build-system gnu-build-system)
    (inputs
     (list bash-minimal
           qtbase-5
           qtxmlpatterns-5
           qtmultimedia-5
           qtsvg-5
           qtwayland-5
           qttools))
    (propagated-inputs
     ;; Necessary for audio import
     (list gstreamer
           gst-plugins-base
           gst-plugins-good
           gst-plugins-bad
           gst-libav))
    (arguments
     (list
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'fix-tests
            (lambda _
              ;; Its bundled catch2-2.5.0 fails to build with glibc-2.35.
              (copy-file #$(file-append catch2 "/include/catch2/catch.hpp")
                         "tests/src/catch.hpp")))
          (replace 'configure
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (invoke "qmake" (string-append "PREFIX=" out)))))


          (add-after 'install 'wrap-executable
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out"))
                    (plugin-path (getenv "QT_PLUGIN_PATH")))
                (wrap-program (string-append out "/bin/pencil2d")
                  `("QT_PLUGIN_PATH" ":" prefix (,plugin-path)))))))))
    (home-page "https://www.pencil2d.org")
    (synopsis "Make 2D hand-drawn animations")
    (description
     "Pencil2D is an easy-to-use and intuitive animation and drawing tool.  It
lets you create traditional hand-drawn animations (cartoons) using both bitmap
and vector graphics.")
    (license license:gpl2)))