MLV-App icon indicating copy to clipboard operation
MLV-App copied to clipboard

AVFoundation h.265 export

Open ilia3101 opened this issue 5 years ago • 36 comments

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

ilia3101 avatar Mar 20 '19 19:03 ilia3101

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

masc4ii avatar Mar 20 '19 20:03 masc4ii

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?

ilia3101 avatar Mar 20 '19 20:03 ilia3101

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

dannephoto avatar Mar 20 '19 21:03 dannephoto

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

Just tested, short export- Nice, nice!

dannephoto avatar Mar 20 '19 23:03 dannephoto

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.

dannephoto avatar Mar 22 '19 06:03 dannephoto

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...

masc4ii avatar Mar 22 '19 07:03 masc4ii

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.

bouncyball-git avatar Mar 22 '19 07:03 bouncyball-git

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 avatar Mar 22 '19 08:03 dannephoto

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" :)?

dannephoto avatar Mar 22 '19 15:03 dannephoto

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.

masc4ii avatar Mar 22 '19 17:03 masc4ii

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

dannephoto avatar Mar 22 '19 18:03 dannephoto

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

masc4ii avatar Mar 22 '19 18:03 masc4ii

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 [email protected] 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.

DeafEyeJedi avatar Mar 22 '19 18:03 DeafEyeJedi

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

masc4ii avatar Mar 22 '19 18:03 masc4ii

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

dannephoto avatar Mar 22 '19 20:03 dannephoto

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

masc4ii avatar Mar 22 '19 20:03 masc4ii

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...

dannephoto avatar Mar 24 '19 18:03 dannephoto

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

masc4ii avatar Mar 24 '19 18:03 masc4ii

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

dannephoto avatar Mar 24 '19 18:03 dannephoto

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...

masc4ii avatar Mar 24 '19 19:03 masc4ii

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?

dannephoto avatar Mar 24 '19 19:03 dannephoto

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.

masc4ii avatar Mar 24 '19 19:03 masc4ii

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

dannephoto avatar Mar 24 '19 19:03 dannephoto

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.

bouncyball-git avatar Mar 25 '19 09:03 bouncyball-git

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

masc4ii avatar Mar 25 '19 09:03 masc4ii

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

bouncyball-git avatar Mar 25 '19 09:03 bouncyball-git

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 avatar Mar 25 '19 10:03 dannephoto

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

dannephoto avatar Mar 26 '19 21:03 dannephoto

What settings number for websized do you recommend?

masc4ii avatar Mar 26 '19 21:03 masc4ii

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.

bouncyball-git avatar Mar 27 '19 09:03 bouncyball-git