ilia3101 / MLV-App

All in one MLV processing app.
https://mlv.app/
GNU General Public License v3.0
281 stars 29 forks source link

AVFoundation h.265 export #156

Closed ilia3101 closed 8 months ago

ilia3101 commented 5 years ago

I just remembered how the AVFoundation library has h265... maybe we could compile a version on a new macOS machine with that enabled? - can there be a macro like IF MACOS VERSION > 10.11 or something?

I remembver @masc4ii commented it out due to not compiling on old macs.

I think we could a macOS download for new one and the older one?

Also seems like dark mode would be supported this way

masc4ii commented 5 years ago

Could you have a try? Commited... but I am on 10.9 here, so I don't see what happens.

ilia3101 commented 5 years ago

Thanks, but I have lost my wireless mouse so my iMac is useless, can't test today :cry:

Will be able to soon hopefully. Maybe @dannephoto can try?

dannephoto commented 5 years ago

On vacay atm but will try and see if I can get some time to look into this.

dannephoto commented 5 years ago

h.265 working nicely on 10.14! Compressor Name : Lavc57.89.100 libx265

Just tested, short export- Nice, nice!

dannephoto commented 5 years ago

7 second clip. 897kb! Crazy good compression: https://bitbucket.org/Dannephoto/magic-lantern/downloads/h265.mov

Also: https://www.magiclantern.fm/forum/index.php?topic=20025.msg213777#msg213777

Question. What is the h265 setting used? https://trac.ffmpeg.org/wiki/Encode/H.265

We could find sweet spot and get highest quality output. Seems now it is set to lowest? Auto mode? Maybe two options, high quality(lower compression) and auto quality(higher compression)

edit: checking code. AVfoundation preset? One filesize only? Well, let´s just keep it as is then. Good web format.

masc4ii commented 5 years ago

The "new" h.265 added here is AVFoundation, the ffmpeg h.265 presets were added longtime ago. AVFoundation works on MAC only, and you need XCode for 10.13+. That's why I can't test what Ilia and I implemented. Select it with the options comboBox.

The ffmpeg setting used is ...-c:v libx265 -preset medium -crf 24...

bouncyball-git commented 5 years ago

Do not know about Apple but ffmpeg uses open source x265 code and it is far the best encoder for h265 at the moment.

We are using constant rate factor and 24 is the good bet. Can be lowered for even better result.

dannephoto commented 5 years ago

Aha, good, can tweak and test. I also tested h264 encoder and it seems we have more headroom here as well. When set correctly this encoder yields as good if not better end viewing results as prores. I found some good output setting that is used for smooth alisasing filter. Maybe use that one.

EDIT: Guys. We absolutely get super results with: libx265 -preset medium -crf 10 Could this be set as default instead?

While checking this one might as well be changed: libx264 -preset medium -crf 10

EDIT: For some shitty reason I can only preview fisrt frames with h265 encoder set to libx265 -preset medium -crf 10. Then freeze. Sigh. more testing. Looks super though.

h264 works marvellous with libx264 -preset medium -crf 10.

libx265 -preset medium -crf 14 works, go figure!

Conclusion: libx264 -preset medium -crf 10 libx265 -preset medium -crf 14 Both are goooood!

dannephoto commented 5 years ago

Ok, realize I was testing ffmpeg h265 preset along with ffmpeg h264 preset above. The refined settings are valid(and imo needed) to get high quality output with ffmpeg h264 and h265 options.

About avfoundation h265 codec I can´t seem to find it so I don´t think it was compiled or I am doing something wrong. I work in Mojave 10.14 here so op should work. First. Where do I find "comboBox" :)?

masc4ii commented 5 years ago

It should look like this: Bildschirmfoto 2019-03-22 um 18 06 10 But you only see it, if you use a Apple SDK since 10.13. In compiler output you should find, which SDK is used. Here, I see this: .../usr/local/opt/llvm/bin/clang++ -headerpad_max_install_names -stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk... --> to old.

dannephoto commented 5 years ago

I suspected this. Will look into it but every time I fiddle around with sdk versions it's like starting a nuclear melt down...

masc4ii commented 5 years ago

Tried out your ffmpeg setting... h265 shows the first two images only... I think my laptop is too old for such games 😄

DeafEyeJedi commented 5 years ago

Tried playing back Danne’s H.265 on 10.14 which wouldn’t play back because QT isn’t supported. Hmm?

Sent from my iPhone XR

On Mar 22, 2019, at 11:11 AM, masc4ii notifications@github.com wrote:

Tried out your ffmpeg setting... h265 shows the first two images only... I think my laptop is too old for such games 😄

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

masc4ii commented 5 years ago

Hehe... yepp... Quicktime doesn't support this, same problem here. VLC is able to playback (if machine is fast enough).

dannephoto commented 5 years ago

What setting was applied crf 14? I think crf 18 is usable but after this shadows will break too much for both codecs @masc.

masc4ii commented 5 years ago

Yepp. Okay. h265 @crf18 works. h264 @crf14 works too. Will commit.

dannephoto commented 5 years ago

Hm, getting this when compiling:

Project WARNING: Qt has only been tested with version 10.13 of the platform SDK, you're using 10.14.1.
Project WARNING: This is an unsupported configuration. You may experience build issues, and by using
Project WARNING: the 10.14.1 SDK you are opting in to new features that Qt has not been prepared for.
Project WARNING: Please downgrade the SDK you use to build your app to version 10.13, or configure
Project WARNING: with CONFIG+=sdk_no_version_check when running qmake to silence this warning.

ANd seeing this: /usr/local/opt/llvm/bin/clang -c -pipe -fopenmp -O2 -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

Well, good luck on downgrading, sigh...

masc4ii commented 5 years ago

Ups... no fun. 😢 Sorry. But good to know.

dannephoto commented 5 years ago

I tested by copying from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ into /Library/Developer/CommandLineTools/SDKs/ and got 10.13 in there and it compiles without errors now. But no extra h265 setting in the roll down menu, hmmmm

masc4ii commented 5 years ago

Strange. Unfortunately I can't test myself. But I thought that #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 works for this. You cleaned all the project before comiling, I think...

dannephoto commented 5 years ago

Seems I can comment out:

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
        if( index == CODEC_H265 )
        {
            ui->comboBoxOption->addItem( QString( "Apple AVFoundation" ) );
        }
#endif

Into: ui->comboBoxOption->addItem( QString( "Apple AVFoundation" ) ); And it gets me the AV foundation in the combobox. It exports only to mkv but seems to work. Unclear... So somthing not wirking with #if #endif?

masc4ii commented 5 years ago

I don't know if you get what you think you get. This line exists very often in other code files too. Maybe you get an ffmpeg file. MKV don't sounds like AVFoundation.

dannephoto commented 5 years ago

yeah, most likely ffmpeg file. Seems to be same size when comparing to ffmpeg so it´s not getting the av foundation stuff...

bouncyball-git commented 5 years ago

Hey guys!

x265 constant rate lower than 18 is real overkill. This produces huge files with very small almost unnoticeable improvement in quality (bitrate is higher and decoder straggles on lowend CPUs). I really needed to have this option for quick preview clips or for sharing purpose so 18 is the lowest for that matter. Otherwise I would export prores.

@masc: if we really need to go lower than 18, let's make option for selecting the quality. Edit: I think the text field to insert directly rate factor will be the easiest solution. Saving the value into program settings. With default 20.

masc4ii commented 5 years ago

It is at 18 now. If lower I can't playback the files... 😄

bouncyball-git commented 5 years ago

I think the text field to insert directly rate factor will be the easiest solution. Saving the value into program settings. With default 20.

dannephoto commented 5 years ago

Well both h264 and h265 are possible end formats meaning they could end up being used for high quality viewing purposes or as mentioned by bouncyball for fast previewing(low quality). Both should be available if possible.

dannephoto commented 5 years ago

I think there can be two settings for each code: websized highqual Or something similar. No need for manual bitrate selection imo.

masc4ii commented 5 years ago

What settings number for websized do you recommend?

bouncyball-git commented 5 years ago

Or something similar. No need for manual bitrate selection imo.

This is not a bitrate, it's rate (can be interpreted as quality) factor and IS extremely straight forward.

Range is between 0-51. 0 - lossless, 51 - worst quality. The sane range is 18-28.

I think the dumbest user can use this approach without issues :grin:

Edit: can be implemented as quality slider IMO.

dannephoto commented 5 years ago

Well, 24(was that default before?) Is crushing darks but is usable for webviewing and possibly uploading to youtube. Personally I can stick to the high quality sizes since they are still very small in sizes. But I think 24 is good number if we now can choose between high and low res. Slider. Well, if it´s not to much of a hustle, of course a good choice.

masc4ii commented 5 years ago

Imo a slider is overkill... I think it is too difficult for what we get. It is just used for those codecs, otherwise we should hide the slider. Each parameter must be transferred from one class to another. The parameter has to be used in pipe output. ... Normally the user wants maximum quality or preview quality. I think if we add 2 quality options ("high"=10/18 & "medium"=24) this should be enough and we can realize it with just the option combobox, we already have. Is that okay for you?

dannephoto commented 5 years ago

Completely agree

masc4ii commented 5 years ago

https://github.com/ilia3101/MLV-App/commit/77eaf0721b5fede40e8ca0152b66302fd251b405 Please test.

bouncyball-git commented 5 years ago

Great! Like it. 18 and 24. :+1:

dannephoto commented 5 years ago

Yes, good! Difference is noticeable.