FallingSnow / h265ize

A node utility utilizing ffmpeg to encode videos with the hevc codec.
MIT License
527 stars 81 forks source link

Make debug actually print the error when ffmpeg crashes, also fix some channel mapping stuff #134

Closed mjc closed 5 years ago

mjc commented 5 years ago

ffmpeg has this open issue about mapping channels correctly with libopus.

[libopus @ 0x56555780a0c0] Invalid channel layout 5.1(side) for specified mapping family -1.
Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

I suspect the correct fix for this is to have our own mappings for these but for now this PR at least let the encode continue and I figured I would open the discussion so I can fix this PR to do whatever is decided on a weekend.

ffmpeg channel maps (from ffmpeg -layouts): mono: FC stereo: FL+FR 2.1: FL+FR+LFE 3.0: FL+FR+FC 3.0(back): FL+FR+BC 4.0: FL+FR+FC+BC quad: FL+FR+BL+BR quad(side): FL+FR+SL+SR 3.1: FL+FR+FC+LFE 5.0: FL+FR+FC+BL+BR 5.0(side): FL+FR+FC+SL+SR 5.1: FL+FR+FC+LFE+BL+BR 5.1(side): FL+FR+FC+LFE+SL+SR 6.0: FL+FR+FC+BC+SL+SR 6.0(front): FL+FR+FLC+FRC+SL+SR hexagonal: FL+FR+FC+BL+BR+BC 6.1: FL+FR+FC+LFE+BC+SL+SR 6.1(back): FL+FR+FC+LFE+BL+BR+BC 6.1(front): FL+FR+LFE+FLC+FRC+SL+SR 7.0: FL+FR+FC+BL+BR+SL+SR 7.0(front): FL+FR+FC+FLC+FRC+SL+SR 7.1: FL+FR+FC+LFE+BL+BR+SL+SR 7.1(wide): FL+FR+FC+LFE+BL+BR+FLC+FRC 7.1(wide-side): FL+FR+FC+LFE+FLC+FRC+SL+SR

opus follows vorbis channel ordering stereo: L+R 3ch: L+C+R 4ch: FL+FR+RL+RR 5ch: FL+C+FR+RL+RR 5.1: FL+C+FR+RL+RR+LFE 6.1: FL+C+FR+SL+SR+RC+LFE 7.1: FL+C+FR+SL+SR+RL+RR+LFE

It looks like just overriding 5.1(side) to 5.1 is fine but I'm not so sure about most of the other cases

FallingSnow commented 5 years ago

Thanks for the pull, poked my to check out the other pull requests.

I think pull #127 by @upekshapriya, specifically https://github.com/FallingSnow/h265ize/pull/127/files#diff-b5aeacf0b0e89c4ad9316070981779a4R819, will fix the problem sufficiently, don't you? Let's see what happens with his pull first.

I will take the debug fix though! Thank you.

mjc commented 5 years ago

It may. I'll make a new PR with just the debug commit.