Permlink Replies: 21 - Pages: 2 [ 1 2 | Next ] - Last Post: 22 Jan 25, 22:12 Last Post By: davidekholm Threads: [ Previous | Next ]
davidekholm

Posts: 3,626
Registered: 18-Oct-2002
Faster video processing
Posted: 20 Jan 25, 17:25
  Click to reply to this thread Reply
jAlbum uses the "ffmpeg" processor to process videos. Video processing is a very CPU and time consuming activity. Did you know that you can speed up video processing by delegating the video encoding to your GPU (graphics card)?

See here for details: https://trac.ffmpeg.org/wiki/HWAccelIntro
On my Mac (M4), I now enjoy 10x faster video encoding. I simply added this parameter to the video processor under Settings->Videos->Advanced:
-c:v	h264_videotoolbox
(add this parameter just before the last $outputPath parameter)

I now not only have significantly faster video processing. My CPU is no longer under heavy load during video processing.

I want to encourage you to see if you can get hardware acceleration on your machines as well. Please report what settings you've successfully used and what speed improvement you see. You may want to get the latest version of ffmpeg for your computer first. Get it from ffmpeg.org and put it inside the "bin" folder of jAlbum's config folder (see Tools->Open directories->Config directory)

If you wish to play directly with ffmpeg from your command line, set jAlbum to "FINER" debug level under Preferences. This will print the command line jAlbum uses to invoke ffmpeg to the system console.
RobM

Posts: 4,008
Registered: 4-Aug-2006
Re: Faster video processing
Posted: 20 Jan 25, 19:59   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
davidekholm wrote:
jAlbum uses the "ffmpeg" processor to process videos. Video processing is a very CPU and time consuming activity. Did you know that you can speed up video processing by delegating the video encoding to your GPU (graphics card)?

See here for details: https://trac.ffmpeg.org/wiki/HWAccelIntro
On my Mac (M4), I now enjoy 10x faster video encoding. I simply added this parameter to the video processor under Settings->Videos->Advanced:

-c:v	h264_videotoolbox
(add this parameter just before the last $outputPath parameter)

I now not only have significantly faster video processing. My CPU is no longer under heavy load during video processing.

I want to encourage you to see if you can get hardware acceleration on your machines as well. Please report what settings you've successfully used and what speed improvement you see. You may want to get the latest version of ffmpeg for your computer first. Get it from ffmpeg.org and put it inside the "bin" folder of jAlbum's config folder (see Tools->Open directories->Config directory)

If you wish to play directly with ffmpeg from your command line, set jAlbum to "FINER" debug level under Preferences. This will print the command line jAlbum uses to invoke ffmpeg to the system console.

I made the change in October last year ;)
Wiki video settings, custom settings updated then:
‘ Apple Silicon (M series)
FFMPEG are currently not providing binaries fro Apple Silicon (M series) ARM chips. You can get FFMPEG compiled for M series chips from http://osxexperts.net which will let you use hardware acceleration by changing the video codec from, typically, libx264 to h264_videotoolbox

To check hardware acceleration is enabled in your ffmpeg open a terminal window and execute

/Users/username/Library/JAlbum/bin/ffmpeg -version and look for 'arch=arm64' in the resultant text.’
RobM

Posts: 4,008
Registered: 4-Aug-2006
Re: Faster video processing
Posted: 20 Jan 25, 20:52   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Using FFMPEG 7.1 with videos of various formats, all timings for new album output.
MacBook Air M2

Default method (libx264)
Making "Video formats for testing" (Changes)
"Video formats for testing" made in 1m 29.117s

(easier edit to the advanced settings)
-vcodec h264_videotoolbox
Making "Video formats for testing" (Changes)
"Video formats for testing" made in 58.631s

Settings changed to add -c:v h264_videotoolbox before $outputPath
Making "Video formats for testing" (Changes)
"Video formats for testing" made in 58.204s

Edited by: RobM on 20 Jan 2025, 19:53
davidekholm

Posts: 3,626
Registered: 18-Oct-2002
Re: Faster video processing
Posted: 20 Jan 25, 23:37   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Thanks Rob. I notice huge speed differences, but only if the input video is of type .mov.
RobM

Posts: 4,008
Registered: 4-Aug-2006
Re: Faster video processing
Posted: 21 Jan 25, 00:21   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Ironic, I had mp4, ogg, webm, wav and 3gp.

The 3gp format though does not play in jAlbum, I get a red X across the thumbnail. Try the attached sample
JeffTucker

Posts: 8,438
Registered: 31-Jan-2006
Re: Faster video processing
Posted: 21 Jan 25, 00:24   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
RobM wrote:
The 3gp format though does not play in jAlbum, I get a red X across the thumbnail. Try the attached sample

Works fine with the standard distributed ffmpeg.

ETA: But that format is a relic, designed for delivering video over 3G cellular networks. AFAIK, they're almost nonexistent.
RobM

Posts: 4,008
Registered: 4-Aug-2006
Re: Faster video processing
Posted: 21 Jan 25, 00:34   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
JeffTucker wrote:
RobM wrote:
The 3gp format though does not play in jAlbum, I get a red X across the thumbnail. Try the attached sample

Works fine with the standard distributed ffmpeg.

ETA: But that format is a relic, designed for delivering video over 3G cellular networks. AFAIK, they're almost nonexistent.

Still supported by jAlbum. But the bundled ffmpeg is
ffmpeg version N-108709-g3bd0bf76fb-tessus Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)

The version I'm using is the current version of ffmpeg
ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
RobM

Posts: 4,008
Registered: 4-Aug-2006
Re: Faster video processing
Posted: 21 Jan 25, 00:37   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Maybe it is the h264_videotoolbox that is the problem? Can't try tonight, time for bed.

Edited by: RobM on 20 Jan 2025, 23:37
Forgot, I downloaded the jAlbum bundled ffmpeg and it fails too
JeffTucker

Posts: 8,438
Registered: 31-Jan-2006
Re: Faster video processing
Posted: 21 Jan 25, 00:39   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Looks like ffmpeg has dumped 3gp. Not surprising.

I have no problem telling users that obsolete formats are no longer supported, and sending them off to some online site to convert things to MP4 before using them in jAlbum. One of my favorites is https://convertio.co/. I swear, they seem to be able to handle just about anything.
JeffTucker

Posts: 8,438
Registered: 31-Jan-2006
Re: Faster video processing
Posted: 21 Jan 25, 00:57   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Let me take that all back. The settings recommended by David result in a failure to create the album, even when given an MP4. The video encoder is unknown.

David, you shouldn't be sending users down this kind of rabbit hole. :(
Laza

Posts: 1,964
Registered: 6-Sep-2005
Re: Faster video processing
Posted: 21 Jan 25, 11:42   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Using the H264 AMF codec (on Ryzen 5700G) slightly improves the generation speed (25.8s vs. 29s), but the file sizes are significantly larger (230MB vs. 7.3MB), as if no compression was applied.
RobM

Posts: 4,008
Registered: 4-Aug-2006
Re: Faster video processing
Posted: 21 Jan 25, 12:48   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
JeffTucker wrote:
Let me take that all back. The settings recommended by David result in a failure to create the album, even when given an MP4. The video encoder is unknown.

David, you shouldn't be sending users down this kind of rabbit hole. :(

ffmpeg is supposed to fallback to software encoding if the hardware is not found. Which hardware encoder did you try, and was it Windows or Mac?
JeffTucker

Posts: 8,438
Registered: 31-Jan-2006
Re: Faster video processing
Posted: 21 Jan 25, 12:56   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
RobM wrote:
ffmpeg is supposed to fallback to software encoding if the hardware is not found. Which hardware encoder did you try, and was it Windows or Mac?

Sorry, I just don't have time to tinker with this any more at the moment.

But my point is that jAlbum should not be steering people into making changes that are specific not only to the platform, but to the hardware they have. This is the kind of stuff that scares users away. "Oh, this app is just too technical for me. I need to find something simpler, like Piwigo." Bad for the brand, and we shouldn't be doing it. :(
davidekholm

Posts: 3,626
Registered: 18-Oct-2002
Re: Faster video processing
Posted: 21 Jan 25, 18:10   in response to: JeffTucker in response to: JeffTucker
  Click to reply to this thread Reply
We're testing here in order to figure out how much to push for this feature. I get excellent results with the h264_videotoolbox flag on my Mac M4. Here's an example gallery: https://testing.jalbum.net/Video%20encoding%20test/

Original video: Original.mov 131 MB (1280x720)
Software encoded: Software.mp4 66.4MB in 35s (18,65s with AppleSilicon compiled version of ffmpeg)
Hardware encoded: Hardware.mp4 (h264_videotoolbox). 84.1MB in 6.9s

I admit the quality of the software encoded version is a bit better (see the sky), and it makes a smaller file as well. Still, I think the hardware encoder is interesting.
davidekholm

Posts: 3,626
Registered: 18-Oct-2002
Re: Faster video processing
Posted: 21 Jan 25, 18:33   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Here's another test. This time with a larger (1920x1080) and mp4 encoded source video. Now the encoding speed gain is less dramatic with hardware scaling (6s vs 9.4s). The most speed gain is gained from updating ffmpeg to AppleSilicon binary. With the Intel binary we still use, it takes 15s

https://testing.jalbum.net/Autumn%20surfing/

I'll make it my next move to ensure that we have modern and CPU architecture specific versions of ffmpeg for download.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums