🎥 Make videos programmatically with React
updated webcodecs page
Jonny Burger88446ea89a06
diff --git a/packages/docs/docs/media-parser/WebCodecsQueueing.tsx b/packages/docs/docs/media-parser/WebCodecsQueueing.tsxnew file mode 100644index 0000000000..fc1817c8c1--- /dev/null+++ b/packages/docs/docs/media-parser/WebCodecsQueueing.tsx@@ -0,0 +1,578 @@+import React from 'react';++export const WebCodecsQueueing = () => {+ return (+ <svg+ style={{width: '100%', height: 'auto'}}+ viewBox="0 0 924 277"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ >+ <g id="WebCodecs Processing">+ <g id="Group 19">+ <g id="Group 1">+ <rect+ id="Rectangle 1"+ x="33"+ y="119"+ width="118"+ height="34"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="Media Parsing"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="52.8314" y="140.572">+ Media Parsing+ </tspan>+ </text>+ </g>+ <g id="Group 5">+ <rect+ id="Rectangle 1_2"+ x="489"+ y="194"+ width="106"+ height="33"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="User processing"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="497.479" y="213.572">+ User processing+ </tspan>+ </text>+ </g>+ <g id="Group 12">+ <rect+ id="Rectangle 1_3"+ x="316"+ y="194"+ width="106"+ height="33"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="Frame sorter"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="333.449" y="215.572">+ Frame sorter+ </tspan>+ </text>+ </g>+ <g id="Group 13">+ <rect+ id="Rectangle 1_4"+ x="182"+ y="194"+ width="106"+ height="33"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="VideoDecoder"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="195.031" y="215.572">+ VideoDecoder+ </tspan>+ </text>+ </g>+ <g id="Group 14">+ <rect+ id="Rectangle 1_5"+ x="182"+ y="45"+ width="106"+ height="33"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="AudioDecoder"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="194.814" y="66.572">+ AudioDecoder+ </tspan>+ </text>+ </g>+ <g id="Group 6">+ <rect+ id="Rectangle 1_6"+ x="678"+ y="194"+ width="106"+ height="34"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="VideoEncoder"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="692.223" y="213.572">+ VideoEncoder+ </tspan>+ </text>+ </g>+ <g id="Group 7">+ <rect+ id="Rectangle 1_7"+ x="785"+ y="119"+ width="106"+ height="34"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="Write to file"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="805.176" y="140.572">+ Write to file+ </tspan>+ </text>+ <g id="Group 18">+ <rect+ id="Rectangle 2"+ x="749"+ y="129"+ width="48"+ height="14"+ rx="5"+ fill="#00C93C"+ />+ <text+ id="Fast"+ fill="white"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="11"+ font-weight="bold"+ letter-spacing="0em"+ >+ <tspan x="762.339" y="139.544">+ Fast+ </tspan>+ </text>+ </g>+ </g>+ <g id="Group 9">+ <rect+ id="Rectangle 1_8"+ x="648"+ y="45"+ width="106"+ height="34"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="AudioEncoder"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="662.006" y="66.1213">+ AudioEncoder+ </tspan>+ </text>+ </g>+ <path+ id="Vector 1"+ d="M838 154L832.226 164H843.774L838 154ZM783 210V211H823V210V209H783V210ZM838 195H839V163H838H837V195H838ZM823 210V211C831.837 211 839 203.837 839 195H838H837C837 202.732 830.732 209 823 209V210Z"+ fill="currentcolor"+ />+ <path+ id="Vector 3"+ d="M89 153.5V196C89 204.284 95.7157 211 104 211H182.5"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector 4"+ d="M89 118L89.0001 76.5C89.0001 68.2157 95.7158 61.5 104 61.5H182.5"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector 2"+ d="M838 118L843.774 108H832.226L838 118ZM755 62V63H823V62V61H755V62ZM838 77H837V109H838H839V77H838ZM823 62V63C830.732 63 837 69.268 837 77H838H839C839 68.1634 831.837 61 823 61V62Z"+ fill="currentcolor"+ />+ <g id="Group 10">+ <rect+ id="Rectangle 2_2"+ x="707"+ y="220"+ width="48"+ height="14"+ rx="5"+ fill="#FFD000"+ />+ <text+ id="Slow"+ fill="white"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="11"+ font-weight="bold"+ letter-spacing="0em"+ >+ <tspan x="718.62" y="230.544">+ Slow+ </tspan>+ </text>+ </g>+ <g id="Group 15">+ <rect+ id="Rectangle 2_3"+ x="211"+ y="220"+ width="48"+ height="14"+ rx="5"+ fill="#FFD000"+ />+ <text+ id="Slow_2"+ fill="white"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="11"+ font-weight="bold"+ letter-spacing="0em"+ >+ <tspan x="222.62" y="230.544">+ Slow+ </tspan>+ </text>+ </g>+ <g id="Group 18_2">+ <rect+ id="Rectangle 2_4"+ x="65"+ y="147"+ width="48"+ height="14"+ rx="5"+ fill="#00C93C"+ />+ <text+ id="Fast_2"+ fill="white"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="11"+ font-weight="bold"+ letter-spacing="0em"+ >+ <tspan x="78.3389" y="157.544">+ Fast+ </tspan>+ </text>+ </g>+ <g id="Group 16">+ <rect+ id="Rectangle 2_5"+ x="494"+ y="220"+ width="95"+ height="14"+ rx="5"+ fill="#D1D1D1"+ />+ <text+ id="Unknown speed"+ fill="white"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="10"+ font-weight="bold"+ letter-spacing="0em"+ >+ <tspan x="503.849" y="230.31">+ Unknown speed+ </tspan>+ </text>+ </g>+ <g id="Group 23">+ <g id="Group 11">+ <rect+ id="Rectangle 1_9"+ x="415"+ y="45"+ width="106"+ height="33"+ rx="5"+ fill="transparent"+ stroke="currentcolor"+ stroke-width="2"+ />+ <text+ id="User processing_2"+ fill="currentcolor"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="12"+ letter-spacing="0em"+ >+ <tspan x="423.479" y="66.572">+ User processing+ </tspan>+ </text>+ <line+ id="Line 1"+ x1="522"+ y1="61"+ x2="647"+ y2="61"+ stroke="currentcolor"+ stroke-width="2"+ />+ </g>+ <g id="Group 17">+ <rect+ id="Rectangle 2_6"+ x="420"+ y="72"+ width="95"+ height="14"+ rx="5"+ fill="#D1D1D1"+ />+ <text+ id="Unknown speed_2"+ fill="white"+ xmlSpace="preserve"+ style={{whiteSpace: 'pre'}}+ font-family="GT Planar"+ font-size="10"+ font-weight="bold"+ letter-spacing="0em"+ >+ <tspan x="429.849" y="82.31">+ Unknown speed+ </tspan>+ </text>+ </g>+ </g>+ <line+ id="Line 1_2"+ x1="596"+ y1="210"+ x2="677"+ y2="210"+ stroke="currentcolor"+ stroke-width="2"+ />+ <line+ id="Line 2"+ x1="423"+ y1="211"+ x2="488"+ y2="211"+ stroke="currentcolor"+ stroke-width="2"+ />+ <line+ id="Line 4"+ x1="289"+ y1="61"+ x2="414"+ y2="61"+ stroke="currentcolor"+ stroke-width="2"+ />+ <line+ id="Line 3"+ x1="289"+ y1="211"+ x2="315"+ y2="211"+ stroke="currentcolor"+ stroke-width="2"+ />+ <g id="Group 21">+ <rect+ id="Rectangle 1_10"+ x="606"+ y="45"+ width="34"+ height="34"+ rx="5"+ fill="var(--background)"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector"+ d="M632.842 68.1232L623.35 72.9257C623.238 72.9747 623.117 73 622.995 73C622.873 73 622.752 72.9747 622.64 72.9257L613.153 68.1232C612.96 68.025 612.96 67.863 613.153 67.7647L615.424 66.6157C615.536 66.5669 615.657 66.5418 615.779 66.5418C615.901 66.5418 616.021 66.5669 616.134 66.6157L622.645 69.9057C622.757 69.955 622.878 69.9805 623 69.9805C623.122 69.9805 623.243 69.955 623.355 69.9057L629.866 66.6157C629.978 66.5666 630.099 66.5414 630.221 66.5414C630.343 66.5414 630.464 66.5666 630.576 66.6157L632.851 67.7647C633.05 67.863 633.05 68.0201 632.851 68.1183L632.842 68.1232ZM632.842 61.4204L630.567 60.2713C630.455 60.2223 630.334 60.197 630.212 60.197C630.09 60.197 629.969 60.2223 629.857 60.2713L623.345 63.5663C623.233 63.615 623.112 63.6402 622.99 63.6402C622.868 63.6402 622.748 63.615 622.635 63.5663L616.134 60.2664C616.021 60.2177 615.901 60.1925 615.779 60.1925C615.657 60.1925 615.536 60.2177 615.424 60.2664L613.149 61.4155C612.955 61.5137 612.955 61.6757 613.149 61.774L622.64 66.5764C622.752 66.6254 622.873 66.6507 622.995 66.6507C623.117 66.6507 623.238 66.6254 623.35 66.5764L632.842 61.774C633.04 61.6757 633.04 61.5137 632.842 61.4155V61.4204ZM613.153 55.8323L622.645 60.2664C622.873 60.3576 623.127 60.3576 623.355 60.2664L632.847 55.8323C633.04 55.739 633.04 55.5917 632.847 55.5033L623.35 51.0691C623.122 50.977 622.868 50.977 622.64 51.0691L613.149 55.5033C612.95 55.5966 612.95 55.7439 613.149 55.8323H613.153Z"+ fill="currentcolor"+ />+ </g>+ <g id="Group 22">+ <rect+ id="Rectangle 1_11"+ x="141"+ y="45"+ width="34"+ height="34"+ rx="5"+ fill="var(--background)"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector_2"+ d="M167.842 68.1232L158.35 72.9257C158.238 72.9747 158.117 73 157.995 73C157.873 73 157.752 72.9747 157.64 72.9257L148.153 68.1232C147.96 68.025 147.96 67.863 148.153 67.7647L150.424 66.6157C150.536 66.5669 150.657 66.5418 150.779 66.5418C150.901 66.5418 151.021 66.5669 151.134 66.6157L157.645 69.9057C157.757 69.955 157.878 69.9805 158 69.9805C158.122 69.9805 158.243 69.955 158.355 69.9057L164.866 66.6157C164.978 66.5666 165.099 66.5414 165.221 66.5414C165.343 66.5414 165.464 66.5666 165.576 66.6157L167.851 67.7647C168.05 67.863 168.05 68.0201 167.851 68.1183L167.842 68.1232ZM167.842 61.4204L165.567 60.2713C165.455 60.2223 165.334 60.197 165.212 60.197C165.09 60.197 164.969 60.2223 164.857 60.2713L158.345 63.5663C158.233 63.615 158.112 63.6402 157.99 63.6402C157.868 63.6402 157.748 63.615 157.635 63.5663L151.134 60.2664C151.021 60.2177 150.901 60.1925 150.779 60.1925C150.657 60.1925 150.536 60.2177 150.424 60.2664L148.149 61.4155C147.955 61.5137 147.955 61.6757 148.149 61.774L157.64 66.5764C157.752 66.6254 157.873 66.6507 157.995 66.6507C158.117 66.6507 158.238 66.6254 158.35 66.5764L167.842 61.774C168.04 61.6757 168.04 61.5137 167.842 61.4155V61.4204ZM148.153 55.8323L157.645 60.2664C157.873 60.3576 158.127 60.3576 158.355 60.2664L167.847 55.8323C168.04 55.739 168.04 55.5917 167.847 55.5033L158.35 51.0691C158.122 50.977 157.868 50.977 157.64 51.0691L148.149 55.5033C147.95 55.5966 147.95 55.7439 148.149 55.8323H148.153Z"+ fill="currentcolor"+ />+ </g>+ <g id="Group 24">+ <rect+ id="Rectangle 1_12"+ x="374"+ y="45"+ width="34"+ height="34"+ rx="5"+ fill="var(--background)"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector_3"+ d="M400.842 68.1232L391.35 72.9257C391.238 72.9747 391.117 73 390.995 73C390.873 73 390.752 72.9747 390.64 72.9257L381.153 68.1232C380.96 68.025 380.96 67.863 381.153 67.7647L383.424 66.6157C383.536 66.5669 383.657 66.5418 383.779 66.5418C383.901 66.5418 384.021 66.5669 384.134 66.6157L390.645 69.9057C390.757 69.955 390.878 69.9805 391 69.9805C391.122 69.9805 391.243 69.955 391.355 69.9057L397.866 66.6157C397.978 66.5666 398.099 66.5414 398.221 66.5414C398.343 66.5414 398.464 66.5666 398.576 66.6157L400.851 67.7647C401.05 67.863 401.05 68.0201 400.851 68.1183L400.842 68.1232ZM400.842 61.4204L398.567 60.2713C398.455 60.2223 398.334 60.197 398.212 60.197C398.09 60.197 397.969 60.2223 397.857 60.2713L391.345 63.5663C391.233 63.615 391.112 63.6402 390.99 63.6402C390.868 63.6402 390.748 63.615 390.635 63.5663L384.134 60.2664C384.021 60.2177 383.901 60.1925 383.779 60.1925C383.657 60.1925 383.536 60.2177 383.424 60.2664L381.149 61.4155C380.955 61.5137 380.955 61.6757 381.149 61.774L390.64 66.5764C390.752 66.6254 390.873 66.6507 390.995 66.6507C391.117 66.6507 391.238 66.6254 391.35 66.5764L400.842 61.774C401.04 61.6757 401.04 61.5137 400.842 61.4155V61.4204ZM381.153 55.8323L390.645 60.2664C390.873 60.3576 391.127 60.3576 391.355 60.2664L400.847 55.8323C401.04 55.739 401.04 55.5917 400.847 55.5033L391.35 51.0691C391.122 50.977 390.868 50.977 390.64 51.0691L381.149 55.5033C380.95 55.5966 380.95 55.7439 381.149 55.8323H381.153Z"+ fill="currentcolor"+ />+ </g>+ </g>+ <g id="Group 20">+ <rect+ id="Rectangle 1_13"+ x="448"+ y="194"+ width="34"+ height="34"+ rx="5"+ fill="var(--background)"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector_4"+ d="M474.842 217.123L465.35 221.926C465.238 221.975 465.117 222 464.995 222C464.873 222 464.752 221.975 464.64 221.926L455.153 217.123C454.96 217.025 454.96 216.863 455.153 216.765L457.424 215.616C457.536 215.567 457.657 215.542 457.779 215.542C457.901 215.542 458.021 215.567 458.134 215.616L464.645 218.906C464.757 218.955 464.878 218.98 465 218.98C465.122 218.98 465.243 218.955 465.355 218.906L471.866 215.616C471.978 215.567 472.099 215.541 472.221 215.541C472.343 215.541 472.464 215.567 472.576 215.616L474.851 216.765C475.05 216.863 475.05 217.02 474.851 217.118L474.842 217.123ZM474.842 210.42L472.567 209.271C472.455 209.222 472.334 209.197 472.212 209.197C472.09 209.197 471.969 209.222 471.857 209.271L465.345 212.566C465.233 212.615 465.112 212.64 464.99 212.64C464.868 212.64 464.748 212.615 464.635 212.566L458.134 209.266C458.021 209.218 457.901 209.193 457.779 209.193C457.657 209.193 457.536 209.218 457.424 209.266L455.149 210.415C454.955 210.514 454.955 210.676 455.149 210.774L464.64 215.576C464.752 215.625 464.873 215.651 464.995 215.651C465.117 215.651 465.238 215.625 465.35 215.576L474.842 210.774C475.04 210.676 475.04 210.514 474.842 210.415V210.42ZM455.153 204.832L464.645 209.266C464.873 209.358 465.127 209.358 465.355 209.266L474.847 204.832C475.04 204.739 475.04 204.592 474.847 204.503L465.35 200.069C465.122 199.977 464.868 199.977 464.64 200.069L455.149 204.503C454.95 204.597 454.95 204.744 455.149 204.832H455.153Z"+ fill="currentcolor"+ />+ </g>+ <g id="Group 22_2">+ <rect+ id="Rectangle 1_14"+ x="141"+ y="194"+ width="34"+ height="34"+ rx="5"+ fill="var(--background)"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector_5"+ d="M167.842 217.123L158.35 221.926C158.238 221.975 158.117 222 157.995 222C157.873 222 157.752 221.975 157.64 221.926L148.153 217.123C147.96 217.025 147.96 216.863 148.153 216.765L150.424 215.616C150.536 215.567 150.657 215.542 150.779 215.542C150.901 215.542 151.021 215.567 151.134 215.616L157.645 218.906C157.757 218.955 157.878 218.98 158 218.98C158.122 218.98 158.243 218.955 158.355 218.906L164.866 215.616C164.978 215.567 165.099 215.541 165.221 215.541C165.343 215.541 165.464 215.567 165.576 215.616L167.851 216.765C168.05 216.863 168.05 217.02 167.851 217.118L167.842 217.123ZM167.842 210.42L165.567 209.271C165.455 209.222 165.334 209.197 165.212 209.197C165.09 209.197 164.969 209.222 164.857 209.271L158.345 212.566C158.233 212.615 158.112 212.64 157.99 212.64C157.868 212.64 157.748 212.615 157.635 212.566L151.134 209.266C151.021 209.218 150.901 209.193 150.779 209.193C150.657 209.193 150.536 209.218 150.424 209.266L148.149 210.415C147.955 210.514 147.955 210.676 148.149 210.774L157.64 215.576C157.752 215.625 157.873 215.651 157.995 215.651C158.117 215.651 158.238 215.625 158.35 215.576L167.842 210.774C168.04 210.676 168.04 210.514 167.842 210.415V210.42ZM148.153 204.832L157.645 209.266C157.873 209.358 158.127 209.358 158.355 209.266L167.847 204.832C168.04 204.739 168.04 204.592 167.847 204.503L158.35 200.069C158.122 199.977 157.868 199.977 157.64 200.069L148.149 204.503C147.95 204.597 147.95 204.744 148.149 204.832H148.153Z"+ fill="currentcolor"+ />+ </g>+ <g id="Group 21_2">+ <rect+ id="Rectangle 1_15"+ x="637"+ y="194"+ width="34"+ height="34"+ rx="5"+ fill="var(--background)"+ stroke="currentcolor"+ stroke-width="2"+ />+ <path+ id="Vector_6"+ d="M663.842 217.123L654.35 221.926C654.238 221.975 654.117 222 653.995 222C653.873 222 653.752 221.975 653.64 221.926L644.153 217.123C643.96 217.025 643.96 216.863 644.153 216.765L646.424 215.616C646.536 215.567 646.657 215.542 646.779 215.542C646.901 215.542 647.021 215.567 647.134 215.616L653.645 218.906C653.757 218.955 653.878 218.98 654 218.98C654.122 218.98 654.243 218.955 654.355 218.906L660.866 215.616C660.978 215.567 661.099 215.541 661.221 215.541C661.343 215.541 661.464 215.567 661.576 215.616L663.851 216.765C664.05 216.863 664.05 217.02 663.851 217.118L663.842 217.123ZM663.842 210.42L661.567 209.271C661.455 209.222 661.334 209.197 661.212 209.197C661.09 209.197 660.969 209.222 660.857 209.271L654.345 212.566C654.233 212.615 654.112 212.64 653.99 212.64C653.868 212.64 653.748 212.615 653.635 212.566L647.134 209.266C647.021 209.218 646.901 209.193 646.779 209.193C646.657 209.193 646.536 209.218 646.424 209.266L644.149 210.415C643.955 210.514 643.955 210.676 644.149 210.774L653.64 215.576C653.752 215.625 653.873 215.651 653.995 215.651C654.117 215.651 654.238 215.625 654.35 215.576L663.842 210.774C664.04 210.676 664.04 210.514 663.842 210.415V210.42ZM644.153 204.832L653.645 209.266C653.873 209.358 654.127 209.358 654.355 209.266L663.847 204.832C664.04 204.739 664.04 204.592 663.847 204.503L654.35 200.069C654.122 199.977 653.868 199.977 653.64 200.069L644.149 204.503C643.95 204.597 643.95 204.744 644.149 204.832H644.153Z"+ fill="currentcolor"+ />+ </g>+ </g>+ </svg>+ );+};diff --git a/packages/docs/docs/media-parser/webcodecs.mdx b/packages/docs/docs/media-parser/webcodecs.mdxindex 83dc032831..030de87f77 100644--- a/packages/docs/docs/media-parser/webcodecs.mdx+++ b/packages/docs/docs/media-parser/webcodecs.mdx@@ -1,86 +1,80 @@---image: /generated/articles-docs-media-parser-webcodecs.pngid: webcodecs-title: Decoding a video with WebCodecs and @remotion/media-parser+title: Processing video with WebCodecs and @remotion/media-parsersidebar_label: WebCodecsslug: /media-parser/webcodecscrumb: '@remotion/media-parser'----[`parseMedia()`](/docs/media-parser/parse-media) is able to extract tracks and samples from audio and video in a format that is suitable for usage with WebCodecs APIs.+[`parseMedia()`](/docs/media-parser/parse-media) is able to extract tracks and samples from audio and video in a format that is suitable for usage with WebCodecs APIs.-## With `@remotion/webcodecs`--[`@remotion/webcodecs`](/docs/webcodecs) is a package that uses `@remotion/media-parser` to provide video processing in the browser.-It handles various browser quirks and hard implementation details for you.--We recommend it if you want to build a solution based on WebCodecs.-It is a higher-level API that is easier to use than `@remotion/media-parser`.-## Using `@remotion/media-parser`+## Minimal example-`@remotion/media-parser` is a lower-level API that allows you to interface with WebCodecs directly.+The following snippet is a basic, non-production ready example of how to use `parseMedia()` with WebCodecs.```tsx twoslash title="Reading video frames"+// ⚠️ Simple, but non-production ready exampleimport {parseMedia, MediaParserOnAudioTrack, MediaParserOnVideoTrack} from '@remotion/media-parser';-const onVideoTrack: MediaParserOnVideoTrack = ({track}) => {- const videoDecoder = new VideoDecoder({- output: console.log,- error: console.error,- });- videoDecoder.configure(track);-- return (sample) => {- videoDecoder.decode(new EncodedVideoChunk(sample));- };-};-const result = await parseMedia({- src: 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',- onVideoTrack,+ src: 'https://parser.media/video.mp4',+ onVideoTrack: ({track}) => {+ const decoder = new VideoDecoder({+ output: console.log,+ error: console.error,+ });++ decoder.configure(track);++ return (sample) => {+ decoder.decode(new EncodedVideoChunk(sample));+ };+ },});```+## The importance of queueing-## Why is this useful?+import {WebCodecsQueueing} from './WebCodecsQueueing';-WebCodecs is the fastest way to decode videos in the browser.-WebAssembly solutions need to strip the CPU-specific optimizations and cannot benefit from hardware acceleration.+Consider the following video processing pipeline, which converts a video, similarly to what [`convertMedia()`](/docs/webcodecs/convert-media) does.-To decode a video using WebCodecs, the binary format of a video needs to be understood and parsed.-This is a meticulous task that requires a lot of domain knowledge.+<WebCodecsQueueing />-Video files usually come in one of two container formats: ISO BMFF (.mp4, .mov) or Matroska (.webm, .mkv).-Libraries like mp4box.js do a good job of parsing these containers, but are scoped to the specific container format, meaning you need to mix multiple libraries.+The pipeline consists of different steps, each of which have different speeds.+For example, the parsing of the media is much faster than the decoding of the video.-[`parseMedia()`](/docs/media-parser/parse-media) allows to to read an arbitrary media file and interface with it regardless of container, video codec and audio codec.+This can lead to a "traffic jam" in front of the video decoder, where many samples are queueing quickly.+Since this will cause memory to build up, it will negatively impact the performance of the page.-It uses modern Web APIs like `fetch()`, `ReadableStream` and resizeable ArrayBuffers, and returns data structures that are designed to be used with WebCodecs APIs.+It makes sense to connect the whole pipeline together and throttle each step to it does not perform faster than the next step.+In the example above, six queues are required to be managed, with each one of them malfunctioning causing memory to run away.-## Practical considerations-If you use `parseMedia()` with codecs, make the following considerations for your implementation.+## How Remotion helps you work with WebCodecs-### Check browser support for `@remotion/media-parser`+Since handling queueing correctly is a challenging task, we offer helpers that help you work with WebCodecs.-Remotion requires the `fetch()` and Resizeable ArrayBuffer APIs to be present.-Check if your runtime supports these APIs before you use `parseMedia()`.+Remotion's primitives are designed to offer you functionality to implement queueing in a sensible way:-```tsx-const canUseMediaParser = typeof fetch === 'function' && typeof new ArrayBuffer().resize === 'function';-```+- In [`parseMedia()`](/docs/media-parser/parse-media), callbacks are asnychronous, and as long as they don't resolve, the parsing process will not continue.+- The helper functions [`createAudioDecoder()`](/docs/webcodecs/create-audio-decoder) and [`createVideoDecoder()`](/docs/webcodecs/create-video-decoder) offer you a helper method `waitForQueueToBeLessThan()` which you can await.+- For processing video and audio frames as well as encoding video and audio, we don't offer helpers yet, but hope to do so soon.-### Check if browser has `VideoDecoder` and `AudioDecoder`-Chrome has both `VideoDecoder` and `AudioDecoder`.-Firefox has support for `VideoDecoder` and `AudioDecoder` only if the `dom.media.webcodecs.enabled` flag is enabled.-Safari has support for `VideoDecoder`, but not `AudioDecoder`. You can decode the video track but not the audio track.-:::note-Please help [improve this page](https://github.com/remotion-dev/remotion/edit/main/packages/docs/docs/media-parser/webcodecs.mdx) if this information is outdated.-:::+## Practical considerations-You can choose to not receive samples if the corresponding decoder is not supported in the browser.+If you use `parseMedia()` with codecs, make the following considerations for your implementation.++### Check if browser has `VideoDecoder` and `AudioDecoder`++As of May 2025, all major browsers support `VideoDecoder` and `AudioDecoder` except Safari, which has support for `VideoDecoder` only.+`AudioDecoder` is supported in Safari Technology Preview, meaning that soon, all major browsers will support WebCodecs fully.++Still, it is a good idea to check if the browser supports the decoders.+You can opt to skip a track by returning `null` from the callback.```tsx twoslash title="Rejecting samples"// @noErrors@@ -154,6 +148,8 @@ const onAudioTrack: MediaParserOnAudioTrack = async ({track}) => {Perform these checks in addition to the previously mentioned ones.:::++### Error handlingIf an error occurs, you get the error in the `error` callback that you passed to the `VideoDecoder` or `AudioDecoder` constructor.@@ -184,85 +180,6 @@ const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {- You should still perform the checks previously mentioned, but they are omitted from this example.:::-### Queuing samples--Extracting samples is the fast part, decoding them is the slow part.-**If too many samples are in the queue, memory will build up and it will negatively impact the performance of the page.**--Fortunately, the parsing process can be temporarily paused while the decoder is busy.-For this, make the sample processing function async. Remotion will await it before processing the file further.--This will make it so that samples that are not yet needed are not kept in memory, keeping the decoding process efficient.--```tsx twoslash title="Only keeping 10 samples in the queue at a time"-import type {MediaParserOnVideoTrack} from '@remotion/media-parser';--const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {- const videoDecoder = new VideoDecoder({- output: console.log,- error: console.error,- });-- return async (sample) => {- if (videoDecoder.decodeQueueSize > 10) {- let resolve = () => {};-- const cb = () => {- resolve();- };-- await new Promise<void>((r) => {- resolve = r;- videoDecoder.addEventListener('dequeue', cb);- });- videoDecoder.removeEventListener('dequeue', cb);- }-- videoDecoder.decode(new EncodedVideoChunk(sample));- };-};-```--:::note--- The same logic goes for `AudioDecoder`.-- You should still perform the checks previously mentioned, but they are omitted from this example.- :::--:::warning-We think that the `dequeue` event does not work properly in Safari. We'll release an abstraction over the VideoDecoder and AudioDecoder APIs that will make it easier to correctly handle the decoding process soon.-:::--### Handling stretched videos--Some videos don't have the same dimensions internally as they are presented.-For example, [this sample video](https://github.com/remotion-dev/remotion/blob/main/packages/example/public/stretched-vp8.webm) has a coded width of 1440, but a presentation width of 1920.--```tsx twoslash title="Handling stretched videos"-import type {MediaParserOnVideoTrack} from '@remotion/media-parser';--const onVideoTrack: MediaParserOnVideoTrack = async ({track}) => {- const videoDecoder = new VideoDecoder({- output: console.log,- error: console.error,- });- videoDecoder.configure(track);-- return async (sample) => {- console.log(sample);- // {- // codedWidth: 1440,- // codedHeight: 1080,- // displayAspectWidth: 1920,- // displayAspectHeight: 1080,- // ...- // }- };-};-```--This means the frame is internally encoded in a 4:3 aspect ratio, but the frame should as a 16:9.-By passing all of `codedWidth`, `codedHeight`, `displayAspectWidth` and `displayAspectHeight` to `new EncodedVideoChunk()`, the decoder should handle the stretching correctly.### Handling rotation@@ -332,9 +249,23 @@ decoder.configure(config); // Unsupported configuration. Check isConfigSupportedConsider this in your implementation.-### Safari performance+## Why WebCodecs?++WebCodecs is the fastest way to decode videos in the browser.+WebAssembly solutions need to strip the CPU-specific optimizations and cannot benefit from hardware acceleration.++Using Remotion Media Parser and WebCodecs is [at least 3 times faster than using WebAssembly solutions](https://github.com/remotion-dev/webcodecs-benchmark) in any scenario we tested.++WebCodecs are built into the browser, meaning decoders and encoders do not need to be loaded.+Later in 2025, WebCodecs will be supported in all major browsers.++## With `@remotion/webcodecs`++[`@remotion/webcodecs`](/docs/webcodecs) is a package that uses `@remotion/media-parser` to provide video processing in the browser.+It handles various browser quirks and hard implementation details for you.-We find that with our reference implementation, Safari chokes on decoding the full Big Buck Bunny video. Tips are welcome, and otherwise we encourage to consider if and which parts of WebCodecs APIs you want to support.+- Convert, rotate and resize videos: [`convertMedia()`](/docs/webcodecs/convert-media)+- Decode media: [`createVideoDecoder()`](/docs/webcodecs/create-video-decoder) and [`createAudioDecoder()`](/docs/webcodecs/create-audio-decoder)## Reference implementation