lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
543 stars 24 forks source link

Question - What the correct parameter for other-transcode on M1 Pro Max Macbook #137

Closed jeffduska closed 2 years ago

jeffduska commented 2 years ago

I'm trying to use my new Macbook Pro M1 MAX with other-transcode, but I'm not having much success.

I've done tests on three machines—an Intel NUC, M1 Mac Mini, and MacBook Pro w/ M1 Max.

The NUC and Mac Mini worked successfully, but each has a limitation. NUC runs successfully but is very slow. The M1 Mac Mini is faster, but I can only create 8-bit files. Running the process on the Macbook makes a file quickly, but it is corrupted. The audio is fine, but the video is either a black screen or a single screen that doesn't change. The time code is also around 99 hours.

The command other-transcode --mp4 --eac3 --hevc <movie name> worked on NUC and the Mac Mini. While processing, the NUC status looks like this.

  frame=19812 fps= 66 q=-0.0 size=  371457kB time=00:13:46.77 bitrate=3680.5kbits/s speed=2.77x

The Mac Mini has a similar status line.

Using the same command on the Macbook Pro, the status looks like this. .

frame=59187 fps=308 q=-0.0 size= 1342721kB time=28:34:00.57 bitrate= 107.0kbits/s speed= 536x

I've tried several different command settings such as using --mp4, adding --vt, and even, I believe, setting the target bitrate with this example,

other-transcode --eac3 --hevc --mp4  --target 1080p=6000 <movie>

I always get something like this.

frame= 4362 fps=302 q=-0.0 Lsize=  142849kB time=02:06:08.31 bitrate= 154.6kbits/s speed= 524x
ffmpeg -loglevel error -stats -i GUARDIANS\ OF\ THE\ GALAXY\ VOL\ 2.mkv -map 0:0 -c:v hevc_videotoolbox -b:v 6000k -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title\= -disposition:v default -tag:v hvc1 -map 0:1 -c:a:0 eac3 -metadata:s:a:0 title\= -disposition:a:0 default -sn -metadata:g title\= -movflags disable_chpl

The FFmpeg command appears correct, so I thought it might be a bug in FFmpeg since -b:v 6000K seems right. I have searched for a bug with FFmpeg, but I haven't seen any discussion of an issue with FFmpeg. I searched the wiki and issues here. I haven't seen anyone mention this problem.

I've tried with different movies. I've uninstalled and re-installed FFmpeg 5.0 using brew. Since no one else appears to be having this problem, I'm assuming I'm doing something wrong.

I'm running other_trasncode 0.10.0 with FFMpeg 5.0.

Does anyone have a suggestion as to what I'm doing wrong?

PS - Sorry this is so long.

Thanks

Jeff

khaosx commented 2 years ago

@jeffduska

Can you attach a log file here while I am running a test on my MBP?

khaosx commented 2 years ago

@donmelton @jeffduska

Ran a quick set of tests on my Macbook Pro, which is also an M1 MAX so our results should be identical. Which, of course, means that I had zero issues. Let's try to troubleshoot this...

  1. How did you install ffmpeg with brew? I did mine a couple of weeks back, and the binaries hadn't been updated. I had to tell brew to install from HEAD. Haven't checked back on that since, so that's one possible difference.
  2. What movie are you using to test? If I have it, I'll rerun against that specifically.
  3. I used other-transcode --hevc --mp4 --eac3 --10-bit. How does that match up with your command?
  4. Please verify that you don't have multiple copies of other-transcode somewhere else in your path by explicitly running it.
  5. Gimme gimme gimme dat log!
lisamelton commented 2 years ago

@jeffduska Yes, please provide a .log file to @khaosx. I asked him to help with this since he actually has a M1 MacBook Pro like you do and I do not.

Thanks!

jeffduska commented 2 years ago

@khaosx Thanks for helping me.

  1. Installed FFmpeg via brew. I couldn't remember if I had tried working with the head branch of FFmpeg, so I did a brew uninstall FFmpeg, then reinstalled FFmpeg using brew install FFmpeg
  2. The movie is Guardians of the Galaxy Vol 2, but I've had the same problems with Wonder Woman and Blade Runner 2040
  3. I was using other-transcode --hevc --mp4 --eac3 and later other-transcode --hevc --mp4 --eac3 --target 1080p=6000
    • I double-checked and I only have the one copy other-transcode that was installed via gem
    • I just tried other-transcode --hevc --mp4 -eac3 10-bit. The same error occurred. I've attached a logfile from

GUARDIANS OF THE GALAXY VOL 2.mp4.log

loshlee commented 2 years ago

I'm also using Ruby, Gem, other-transcode and ffmpeg on an M1 MacBook Pro with success. I had some difficulty with the transition to ARM, but that seems to be resolved now, so I might be able to join in to test what you're trying. I used your command line on a different .mkv with normal results.

The ffmpeg mailing list appears to recommend using the HEAD installation when using Homebrew to install. Because you already ran the uninstall command once, I thought you might be willing to try again, only this time reinstall with:

brew install homebrew-ffmpeg/ffmpeg/ffmpeg --HEAD

Hopefully, that will give you a reliable version. Yours claims to be installed inside /opt/homebrew/Cellar/ffmpeg/5.0 Mine is installed inside /opt/homebrew/Cellar/ffmpeg/HEAD-881b80f_1/

You can update it with:

brew update && brew upgrade homebrew-ffmpeg/ffmpeg/ffmpeg --fetch-HEAD

There's a chance that might get you past some problems, although I'm not really sure, of course. But, you can copy the command line which is specified in your log, and paste it into a Terminal window:

ffmpeg -loglevel error -stats -i "HD/GUARDIANS OF THE GALAXY VOL 2.mkv" -map 0:0 -c:v hevc_videotoolbox -pix_fmt:v p010le -b:v 4000k -profile:v main10 -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v "title=" -disposition:v default -tag:v hvc1 -map 0:1 -c:a:0 eac3 -metadata:s:a:0 "title=" -disposition:a:0 default -sn -metadata:g "title=" -movflags disable_chpl "GUARDIANS OF THE GALAXY VOL 2.mp4"

You might be able to get a smaller chunk of the source .mkv file to transcode while you're troubleshooting with something like:

ffmpeg -i "HD/GUARDIANS OF THE GALAXY VOL 2.mkv" -ss 00:3:00 -t 00:03:00.00 -async 1 -codec copy -map 0 -movflags +faststart "GUARDIANS OF THE GALAXY VOL 2_3_min_CLIP.mp4"

Let us know about your progress.

loshlee commented 2 years ago

I got that excerpt export line wrong, I think. I meant:

ffmpeg -i "HD/GUARDIANS OF THE GALAXY VOL 2.mkv" -ss 00:03:00 -t 00:03:00.00 -async 1 -codec copy -map 0 -movflags +faststart "GUARDIANS OF THE GALAXY VOL 2_3_min_CLIP.mp4"

khaosx commented 2 years ago

@jeffduska

That log file looks clean to me, and now I'm at a loss. I've rerun against my rips of GotG2 and some others for good measure. I am unable to reproduce this problem. I would recommend upgrading ffmpeg using the command that @loshlee posted:

brew update && brew upgrade homebrew-ffmpeg/ffmpeg/ffmpeg --fetch-HEAD

and let's see where we are after that.

loshlee commented 2 years ago

@khaosx

...> * I just tried other-transcode --hevc --mp4 -eac3 10-bit. The same error occurred. I've attached a logfile from ...

Is there a chance that write permissions for the destination are compromised?

jeffduska commented 2 years ago

I tried the reinstall using @loshlee using suggestion. No luck. The same problem. I have compressor. Is there a way we can use it to validate that it isn't a hardware issue? My only other thought is to reinstall Mac OS X

lisamelton commented 2 years ago

@jeffduska Let's try something simple. Let's bypass other-transcode altogether and just use ffmpeg directly to see if it works. Try something like this on your command line:

ffmpeg -i /path/to/input.mkv output.mkv

That's it. Does that work for you? If it does, I can start making the command line more complex until we figure out which component is failing. If it doesn't work, then I have no idea what could be wrong.

klogg416 commented 2 years ago

I know homebrew adds any installed app to the PATH, but I wonder if ffmpeg from homebrew is the first ffmpeg in the PATH. If you type which ffmpeg, which file location is returned? Mine is installed through homebrew and returns /opt/homebrew/bin/ffmpeg

Also, ffmpeg --version should return a version of at least 5.0...

lisamelton commented 2 years ago

@klogg416 Good question! 👍

jeffduska commented 2 years ago

@donmelton Cool. Running ffmpeg -i HD/GUARDIANS\ OF\ THE\ GALAXY\ VOL\ 2.mkv test.mkv I'm seeing bitrate between 3000 to 6000.

jeffduska commented 2 years ago

@klogg416 When I do which it brings up /opt/homebrew/bin/ffmpeg. The version is ffmpeg version N-105688-g0d34e21282

I did find as root. The places I see ffmpeg is within the opt/hombrew folders

/opt/homebrew/bin/ffmpeg
./opt/homebrew/var/homebrew/linked/ffmpeg
./opt/homebrew/opt/ffmpeg
./opt/homebrew/Cellar/ffmpeg
./opt/homebrew/Cellar/ffmpeg/HEAD-0d34e21_1/bin/ffmpeg
./opt/homebrew/Cellar/ffmpeg/HEAD-0d34e21_1/share/ffmpeg
./opt/homebrew/Cellar/ffmpeg@4/4.4.1/bin/ffmpeg
./opt/homebrew/Cellar/ffmpeg@4/4.4.1/share/ffmpeg
./opt/homebrew/share/ffmpeg
lisamelton commented 2 years ago

@jeffduska OK, that's good that it worked. You're likely using libx264 to do the video transcoding. Did you notice that in the console spew?

Let's add this to the command line:

ffmpeg -i /path/to/input.mkv -c:v h264_videotoolbox output.mkv

Does that still work? And is it transcoding much faster now?

loshlee commented 2 years ago

Yeah, but the log showed where the ffmpeg in use was, didn’t it?

On Feb 18, 2022, at 7:04 PM, Don Melton @.***> wrote:

 @klogg416 Good question! 👍

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

lisamelton commented 2 years ago

@loshlee Yes, so that's no longer the issue.

loshlee commented 2 years ago

Right, just making sure. And I guess the write permissions are no longer an issue, either, but I wanted to mention that because I’m pretty sure that I remember from long ago some strangely reported progress by ffmpeg, even when it couldn’t write the output file.

lisamelton commented 2 years ago

@loshlee I'm glad you mentioned both of those things! It's better to be sure. Keep kibitzing here. We need the help. Seriously.

loshlee commented 2 years ago

@loshlee I'm glad you mentioned both of those things! It's better to be sure. Keep kibitzing here. We need the help. Seriously.

Thanks. I guess what I'm getting at is that the PWD for the command you suggested might be different from the output destination specified in the failing command. Could it still be worth checking?

lisamelton commented 2 years ago

@loshlee Possibly, but the output destination with other-transcode is always the current working directory and the sample command I have @jeffduska also outputs to the current working directory. AFAIK, ffmpeg will fail immediately if it can't write its output.

loshlee commented 2 years ago

OK. There’s one other thing that I wanna mention and then I’ll try to let others have a go for a while. That configuration in the log file shows a lot more stuff then what I expect to see when I use that HEAD installation method in Homebrew.

lisamelton commented 2 years ago

@loshlee Hmmmm, there a lot of options but the build on my Windows box is even more complicated. Is there a particular option that stands out?

loshlee commented 2 years ago

@loshlee Hmmmm, there a lot of options but the build on my Windows box is even more complicated. Is there a particular option that stands out?

Disabled:

--disable-libjack --disable-indev=jack

Options missing from my --HEAD (among others):

--enable-version3 --enable-libbluray --enable-librubberband --enable-libtesseract --enable-libvidstab --enable-libwebp --enable-libxml2 --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb

What I have but Jeff doesn't: --enable-demuxer=dash --enable-opencl

lisamelton commented 2 years ago

@loshlee OK, none of those will affect other-transcode or the command I gave him.

loshlee commented 2 years ago

Might as well run the rest by you then:

--enable-pthreads --enable-ffplay --enable-gnutls --enable-librav1e --enable-librist --enable-libsrt --enable-lzma --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg

lisamelton commented 2 years ago

@loshlee Nope. Those don't really matter either.

lisamelton commented 2 years ago

@jeffduska Just in case you missed it in the other chatter, I need you to try this next (see https://github.com/donmelton/other_video_transcoding/issues/137#issuecomment-1045592519):

ffmpeg -i /path/to/input.mkv -c:v h264_videotoolbox output.mkv

Does that still work? And is it transcoding much faster now?

jeffduska commented 2 years ago

When I run this command, I get

 [matroska @ 0x12be04a60] Starting new cluster due to timestamptrate=  26.9kbits/s speed= 492x
    Last message repeated 127 times
[matroska @ 0x12be04a60] Starting new cluster due to timestamptrate=  26.6kbits/s speed= 492x
    Last message repeated 125 times
[matroska @ 0x12be04a60] Starting new cluster due to timestamptrate=  26.5kbits/s speed= 492x

It appears to be running faster, but I'm not certain. I wasn't expecting the new command file up the screen, so I didn't capture the previous command speed.

Thanks for all the help.

lisamelton commented 2 years ago

@jeffduska But it works, right? If that's the case, I want you to try this now:

ffmpeg -i /path/to/input.mkv -c:v hevc_videotoolbox output.mkv

This will change the output from H.264 to HEVC. We need to find out if that works, too.

jeffduska commented 2 years ago

@donmelton, I just found the problem; I didn't have automatic system updates enabled. My laptop needed a Monterey update to 12.2.1 and a Pro Video update. I'm guessing the Pro Video updated fixed things.

Now, when I run

other-transcode --hevc --mp4 --eac3 --10-bit

It works great. I appreciate everyone's help and the time you spent on this.

A question for the other Macbook M1 Max owners, are these the settings you'd recommend?

Again, thank you so much for spending your time helping me with this. I'm sorry I didn't catch this sooner.

lisamelton commented 2 years ago

@jeffduska That's quite all right. Now we know to recommend that system software update to anyone else who runs into the same problem. And now you know to check for system software updates first. :)

I would recommend these video options for you, explicitly selecting the VideoToolbox hardware encoder:

other-transcode --vt --hevc --10-bit

I don't recommend --mp4 because the MP4 format is limited to what types of media it can include. For example, it cannot contain image-based subtitles which are commonly part of DVDs and Blu-ray Discs. However, other-transcode's default Matroska (MKV) format can. But that choice is up to you.

As for audio, --eac with it's DD+ audio output is definitely higher quality than the default, albeit more portable, AC-3 format. But you should also consider the --aac-only option if you want smaller audio tracks.

I'll close this now since it's resolved.