NextLevelSessionExporter icon indicating copy to clipboard operation
NextLevelSessionExporter copied to clipboard

Can't set a frame rate for H264 codec - crash when using AverageNonDroppableFrameRate

Open mdmack opened this issue 8 years ago • 2 comments

Hi,

I'm trying to set a frame rate of 24 when using H264 codec and I don't see a way to do it. I tried using AVVideoExpectedSourceFrameRateKey but that doesn't seem to effect final frame rate. I tried setting AverageNonDroppableFrameRate but I'm getting a crash with NSInvalidArgumentException: "Compression property AverageNonDroppableFrameRate is not supported for video codec type avc1"

I see that there's a default value of 30 based on this code: if frameRate == 0 { frameRate = 30 } videoComposition.frameDuration = CMTimeMake(1, Int32(frameRate))

Changing this from 30 to 24 and not setting AverageNonDroppableFrameRate works.

I'm happy to open a pull request with some changes but would like to confirm the direction first. One of the options is just to add a variable to NextLevelSessionExporter that would set the default frame rate - would that work? Also, I might be wrong but it seems like the droppable frame rate and frame duration are not always the same values, might be good to separate those.

A related issue but in another pod if it's of value - https://stackoverflow.com/questions/44001641/using-avassetwriter-to-re-encode-h264-mov-file-how-to-set-frame-rate

Thanks, Mike

mdmack avatar Apr 17 '18 23:04 mdmack

hey @mdmack thanks for the issue and the link. sounds like there's a couple bugs in there, will check it out.

piemonte avatar Apr 19 '18 23:04 piemonte

@mdmack Six years later, I'm facing the same issue...

Compression property AverageNonDroppableFrameRate is not supported for video codec type hvc1

Apparently, HEVC videos will not work with that compression key. As @mdmack mentioned, not setting AverageNonDroppableFrameRate and simply providing a default value seems to work.

262hz avatar Nov 11 '24 11:11 262hz