Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example demonstrating media editing scenarios #62

Open
ykh015 opened this issue May 29, 2020 · 11 comments
Open

Add an example demonstrating media editing scenarios #62

ykh015 opened this issue May 29, 2020 · 11 comments
Labels

Comments

@ykh015
Copy link

ykh015 commented May 29, 2020

One of the key use cases mentioned in the explainer is
Non-realtime encoding/decoding/transcoding, such as for local file editing

Can we add an example demonstrating basic media editing operations like trim and concatenation ?

We are trying to understand on how to use WebCodecs to achieve the same functionality as MediaBlob to ensure that it meets developer needs.

@tlecoz
Copy link

tlecoz commented Oct 6, 2020

Yes please ! Add a working example about it !
I'm trying to get it working for days and can't figure out how to save a canvas-animated-content as a mp4 file. I'm sure it's very simple, please show us a basic runnable demo.

@chcunningham
Copy link
Collaborator

We now have a few samples here
https://w3c.github.io/webcodecs/samples/

Including one that creates a webm file after using WebCodecs to encode the camera stream
https://w3c.github.io/webcodecs/samples/capture-to-file/capture-to-file.html

Closing, as I think the path to basic trim / concatenate functions is probably clear from the above. Roughly:

  • if all you need is to concatenate two files, you don't need webcodecs at all. you can do that with a JS muxer like in the demo above.
  • if you want to trim in the middle of a GOP and then concatenate, you may want to use WebCodecs to create a new GOP (starting with a new I-Frame) from the trimmed GOP. To do this, you would
    • decode the original gop,
    • discard (close()) the VideoFrames that are outside the trim window
    • start encoding frames that are within the trim window
    • add those encoded frames (chunks) at the concatenation boundary
    • append the other (untrimmed) gops after that (no need to transcode).

Please reopen if more to discuss.

@tlecoz
Copy link

tlecoz commented May 12, 2021

Hello !
Thank you for the link to the samples :)

My message has been written in october 2020 and at this time there was almost no information at all. My project almost work now but thanks anyway :)

Actually, there is still a problem, I searched a lot but didn't find a way to demux webm files that use alpha channel as I reported here but got no help at all... Any idea ?

jscodec/jswebm#18

Also, there is no example at all showing how to do the opposite : mux the EncodedVideoChunk into a mp4 file.
I know how to do it using ffmpeg but I have no idea how to do it in pure javascript and there is no example at all.
I'm sorry to ask some help but most of webdevelopers (including myself) are not very familiar with mux / demux task .

Same thing for AudioEncoder / AudioDecoder : no example at all yet.
In my project, I'm forced to convert my mp3 into mp4 in order to use mp4box to demux my audio track. I'm sure it's doable using a mp3 demuxer but it's not easy to get into it from a classical webdeveloper point of view.
I also have no idea how to mux the EncodedAudioChunk into a mp3 file in pure javascript.

It's not as obvious as you may think it is (when I ask my question in october 2020 I didnt even know what could be a muxer / demuxer and I'm sure that 99% of webdevelopers never heard about that - now I know, but it was not obvious - )

@chcunningham chcunningham reopened this May 12, 2021
@henrywong
Copy link

@tlecoz I totally agree with you!

@henrywong
Copy link

@chcunningham Can you please provide an example showing how to do the opposite : mux the EncodedVideoChunk into a mp4 file. I'm stuck with this problem now.

@tlecoz
Copy link

tlecoz commented Aug 4, 2021 via email

@dalecurtis
Copy link
Contributor

You'll need to use something like https://github.com/videojs/mux.js or https://github.com/gpac/mp4box.js/ they both have code in their repositories showing how to generate an mp4 file. mux.js also offers a Slack channel for assistance: https://github.com/videojs/mux.js#talk-to-us

We'll try to put one together in the future, but it's not a priority at the moment.

@tlecoz
Copy link

tlecoz commented Aug 4, 2021 via email

@tlecoz
Copy link

tlecoz commented Aug 4, 2021 via email

@tlecoz
Copy link

tlecoz commented Aug 27, 2021

Hello !

I tryed to create a mp4 using mp4box. It almost work but there is a problem.
(i was in holidays, that's why I didn't try before)

gpac/mp4box.js#243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants