w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.
https://w3c.github.io/webcodecs/
Other
985 stars 136 forks source link

Can't use AVC video codecs on mp4 1920x1080 resolution #715

Closed a-adly closed 1 year ago

a-adly commented 1 year ago

I'm trying to apply AVC codec level 4 for encoding mp4 videos with size 1920x1080

videoEncoder.configure({
      codec: "avc1.640028", // or "avc1.64001E"
      width: 1920,
      height: 1080,
});

but always receive this error

Failed to execute 'encode' on 'VideoEncoder': Cannot call 'encode' on a closed codec.

Is there another avc codec supported or different settings to be able to encode big size video

dalecurtis commented 1 year ago

If this is an issue in Chrome please file a bug at https://crbug.com/new with the details from chrome://gpu -- this succeeds on Chrome desktop for me. If it's Safari you can file an issue at https://bugs.webkit.org/

a-adly commented 1 year ago

OK thanks @dalecurtis, yes in chrome://gpu report it says

Graphics Feature Status Canvas: Hardware accelerated Canvas out-of-process rasterization: Disabled Direct Rendering Display Compositor: Disabled Compositing: Hardware accelerated Multiple Raster Threads: Enabled OpenGL: Enabled Rasterization: Unavailable Raw Draw: Disabled Video Decode: Hardware accelerated Video Encode: Unavailable Vulkan: Disabled WebGL: Hardware accelerated WebGL2: Unavailable WebGPU: Hardware accelerated

but encoding works good for smaller size videos 1280x720

I'll try on different device with recent version of Chrome or fill a bug as you suggested

Djuffin commented 1 year ago

Works fine on my machine. Please file a bug against Chromium with more details.

dalecurtis commented 1 year ago

You'll want to look at the "Video Acceleration Information" section of chrome://gpu to see what the supported resolutions are. If this is Android, resolution supported if very limited.

aboba commented 1 year ago

You can try different bitrates and resolutions here. FWIW, I'm not seeing any errors when encoding 1920 x 1080 resolution with codec string "avc1.640028".

a-adly commented 1 year ago

Tried on a different machine & codec "avc1.640028" worked good

I've tried to encode mp4 videos on this example here taken from a source muxer library repo

You'll want to look at the "Video Acceleration Information" section of chrome://gpu to see what the supported resolutions are. If this is Android, resolution supported if very limited.

yes it was showing empty info on encoding part

You can try different bitrates and resolutions here. FWIW, I'm not seeing any errors when encoding 1920 x 1080 resolution with codec string "avc1.640028".

"avc1.640028" was giving same error on my 1st PC:

DOMException: Encoder initialization error.
Uncaught DOMException: Failed to execute 'encode' on 'VideoEncoder': Cannot call 'encode' on a closed codec.
    at encodeVideoFrame

but worked good on a different machine.

Also codec "avc1.42002A" seems working good on all machines

Thank you all, the issue was coming from the 1st machine I've tried on