abema / go-mp4

Go library for reading and writing MP4 file
https://dev.to/sunfishshogi/go-mp4-golang-library-and-cli-tool-for-mp4-52o1
MIT License
464 stars 30 forks source link

Add an audio track to a video #131

Closed LazarenkoA closed 1 year ago

LazarenkoA commented 1 year ago

Hi, is it possible to add an audio track to an mp4 file (in which there is no sound) using your project?

sunfish-shogi commented 1 year ago

It is depend on your use case.

If you want feature which merge mp4 files by only one function call, the answer is No. Because this library has only low layer implementation for MP4.

This library targets users which understands ISO/IEC 14496-12.

LazarenkoA commented 1 year ago

if I'm still going to do this, as I understand it, the task comes down to the fact that you need to add a block with a track type, taking into account nested blocks like mdia, mdhd ....? Can this be done within your project?

sunfish-shogi commented 1 year ago

You should insert at least audio's "trak" box, its inner boxes, and "mdat" box. However, sometimes you should add or change other boxes. It is depend on type of MP4 (standard, fast-start, or fragmented).

go-mp4 support most of box types you need, however it only support MP4 box structure management. So, you should calculate many fields value in your own implementation.

I don't suggest to use this library for complicated implementation.

LazarenkoA commented 1 year ago

thanks for the answer