lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
555 stars 26 forks source link

Hardware recommendations - Apple Silicon Mac vs AMD Windows Machine #184

Closed maxwilkie closed 1 year ago

maxwilkie commented 1 year ago

Hi there,

Long time video_transcoding user, new-ish to other_video_transcoding. I'm about to start transcoding a bunch of 1080p content and was wondering which of the two hardware platforms I have available will produce the best transcodes.

I can either use my M1 Pro MacBook Pro, or a recent gaming computer I've built, which has an AMD Ryzen 7600 CPU and Radeon RX 6750 XT GPU. I can see from the wiki that nVidia and Intel hardware encoders are recommended but wasn't sure what, if any, performance difference there is between Apple and AMD's options.

Additionally curious to know whether to go with 8-bit HEVC or whether I'd be better off sticking with H.264.

Thanks in advance for any advice!

skj-dev commented 1 year ago

While I don't have one, AMD GPUs don't seem to have a good track record when it comes to hardware transcoding quality.

I have an Apple Silicon Mac (Studio), and find it to be quite speedy when it comes to x264. I haven't used the media encoders much (i.e. hardware accelerated transcoding). I find their quality to be slightly less than the software encoder, though they are faster. Depending on your needs (and patience) they may be perfectly fine.

Another option for x264 encoding is Don's new collection of scripts:

https://github.com/donmelton/more-video-transcoding

Specifically the two-pass-transcode.rb one does x264, and even though it's two-pass, it's quite speedy for software encoding. The more cores the better, of course.

Unless your primary goal is to reduce file size, I suggest sticking with H.264. Especially with the two-pass script, the results are quite good, and the file size reduction respectable.

One more thing to mention, the two-pass script uses HandBrakeCLI instead of ffmpeg.

Hope that helps a bit. :)

lisamelton commented 1 year ago

@maxwilkie Thanks for using my tools. And what @ttyS0 is great advice! 👍 Especially about the new two-pass-transcode.rb script. Using x264, even though it's slower than hardware, really does get the best quality output.

wintervaler commented 1 year ago

I have found the HEVC hardware encoder on my M1 MacBook Air to be very good at reducing color banding, in some cases better than Nvidia's encoder - which is admittedly much better across the board, generally.

The new two-pass software script is hard to pass up quality-wise, but if you really want to go the speedy hardware route (i.e. you need to average 200 fps and ~100 fps with x264 on your AMD machine won't cut it), then I think the VideoToolbox encoder is a decent option. One (other) person's opinion.

lisamelton commented 1 year ago

@wintervaler Thanks for the opinion! 👍 And, yes, 10-bit HEVC is very good at reducing color banding.

maxwilkie commented 1 year ago

@ttyS0 @donmelton @wintervaler Thank you all for the helpful advice! I'll try out each of those options and see what works best.

loshlee commented 1 year ago

You do know how to install a Ruby script manually, right?

Not sure. On a Mac, can you just copy one into the same folder with the rest of the .rb files in gems/video_transcoding-0.25.3/lib/video_transcoding and apply the same permissions as the rest of the items in that folder?

skj-dev commented 1 year ago

@loshlee Not sure where that quote is from, nor how it relates to this issue. However, I think it's important to point out that manually placing Ruby scripts into the directory you've specified is decidedly not a good idea. Don's scripts in particular are stand alone, and a better location to place them is in /usr/local/bin.

loshlee commented 1 year ago

OK, thanks! (quote was from the more-video-transcoding README.md).

loshlee commented 1 year ago

OK, thanks! (quote was from the more-video-transcoding README.md).

(sorry, quote should've just been the first line: "You do know how to install a Ruby script manually, right?". I'm not very good with the Github interface.)

loshlee commented 1 year ago

Oh, btw, I'm using Ventura on an M1, so can I put those ruby scripts in "/opt/Homebrew/bin"?

skj-dev commented 1 year ago

You can, but I wouldn't suggest it. Here's why.

In the previous example, the directory in question was created by Ruby's Gem system, and intended to be used by the things installed via the gem command. Can you drop something else in there, and might it work? Maybe. But it's a bad idea.

In the next example, /opt/Homebrew/bin is created by Homebrew, and intended to be for things installed via the brew command. Can you drop something else in there, and might it work? Maybe. But it's a bad idea.

In general, on UNIX / Linux based systems, /usr/local/bin is considered a place that non-system managed binaries (or scripts) should go.

Also, I want to point out that using the video_transcoding gem directory is not suggested anywhere in the more-video-transcoding README.

loshlee commented 1 year ago

Thanks so much, ttyS0! I'm going to ask one more question in Issues, and I should be on my way to successfully using more-video-transcoding.

lisamelton commented 1 year ago

@maxwilkie Do you have enough information now that we can close this issue?

loshlee commented 1 year ago

One more thing, Don. Just in case anybody wants an easy way to try two-pass-transcode.rb on a Mac, here's an AppleScript to be used as the source of a droplet to convert a handful of files (I've dropped up to 5, I wouldn't want to tie up my Mac for days at a time, so it only works for dropped files, not folders).

It applies the "out of the box" treatment of two-pass-transcode.rb (none of the applications that you so graciously provided me on the more-video-transcoding site ). I will probably post an AppleScript there which does incorporate those options. If @maxwilkie has a Mac and would like to try it, it's used by creating a document in Script Editor and saving as an application, then dropping the source video files onto the new app's icon. If two-pass-transcode.rb, handbrakeCLI, and ffprobe are installed and working, it will create the default .mkv files in the same folder from which the original .m2ts or .ts files are dropped, providing that folder isn't read-only. (Those name extensions aren't the only compatible ones, but in the case of backing up a Blu-ray, they provide familiar examples, I think.)

Don't be concerned about "no such file or directory:" in the Terminal window, it's just a byproduct of an mvcommand, which moves the operative command line script from /tmp to the user's trash. My experience is that "no such file or directory:" gets added if the script takes a certain minimal amount of time to work, which successful transcoding usually does.

The AppleScript follows:

use AppleScript version "2.5"
use scripting additions

property temppath : "/private/tmp/"
property tmpfile : "/tmp/execme.command"

on open the_items
    my handbrake_transcode(the_items)
end open

on handbrake_transcode(the_items)
    set theshellscript to ""
    repeat with the_item in the_items
        set the_item to the_item as alias
        try
            tell application "Finder"
                set sost to (container of the_item) as string
            end tell
            set pos_filepath to POSIX path of sost

        end try
        set this_filepath to (the_item as text)

        if last character of this_filepath is ":" then
            tell me to set it_is_a_folder to true
        else
            set it_is_a_folder to false
        end if
        set thesourcename to (name of (info for the_item))
        set namepart to (name extension of (info for the_item))
        set the_source_file to POSIX path of this_filepath
        set newname to replace_chars(thesourcename, namepart, "mkv")

        try
            set theshellscript to the theshellscript & "cd" & space & pos_filepath & ";two-pass-transcode.rb" & space & (quoted form of the_source_file) & ";/bin/echo'" & space & "

            ==========================

            " & newname & space & "FINISHED!

            ==========================

            ';"

        on error onerr
            activate
            display dialog onerr
        end try
    end repeat
    set theshellscript to theshellscript & "sleep 2;mv" & space & (quoted form of tmpfile) & space & (quoted form of (POSIX path of (path to trash)))
    do shell script "echo " & quoted form of theshellscript & " > " & tmpfile
    repeat
        do shell script "chmod +x " & tmpfile
        do shell script "open -a Terminal.app" & space & tmpfile
        exit repeat
    end repeat
end handbrake_transcode

on replace_chars(this_text, _bad, _good)
    set AppleScript's text item delimiters to the _bad
    set the item_list to every text item of this_text
    set AppleScript's text item delimiters to the _good as text
    set this_text to the item_list as text
    set AppleScript's text item delimiters to ""
    return this_text
end replace_chars

on run
    set the_items to ((choose file) as list)
    handbrake_transcode(the_items)
end run
maxwilkie commented 1 year ago

@donmelton Yes, thank you! Getting great results with the two pass method. Thanks once again!

lisamelton commented 1 year ago

@loshlee That's handy. You should make that a Gist and post it on GitHub. 👍

loshlee commented 1 year ago

Thanks! Yeah, I've been meaning to learn something about GitHub. I've been following you for years, just like @maxwilkie. I tweeted at you once a long time ago to call your attention to the fact that iPad (iOS, before iPadOS) had been updated so that you no longer needed the audio track pair config to play files containing multichannel audio (I'm that guy, throost on Twitter).

lisamelton commented 1 year ago

@loshlee Ha! I remember that. 😀👋

loshlee commented 1 year ago

Public gist created.

lisamelton commented 1 year ago

@loshlee Just saw your mention of me in the Gist comments. Coolio! 👍