linkedin / LiTr

Lightweight hardware accelerated video/audio transcoder for Android.
BSD 2-Clause "Simplified" License
609 stars 85 forks source link

Mute a part of video and add new audio to video #101

Open pawaom opened 3 years ago

pawaom commented 3 years ago

Mute a part of video and add new audio to video

I was testing this library

these are the various scenarios we are testing

  1. Mute a part of video, For example We have a video of 1 minute, we want to mute from 20th sec. to 40th sec. keeping rest of the audio. i.e from 0 sec. to 20 and from 41 sec to 60 sec

  2. for another video of 2 minutes long we want to add new audio to the original video removing original audio or keeping original audio overlaying new audio over it(both are different scenario)

  3. can we keep original video and revrse audio

how can we do this.

Please create documentation for the different use cases which are present in the demo app and other uses.

izzytwosheds commented 3 years ago

Thank you for using LiTr! Let's go over each scenario:

  1. LiTr does not yet support muting part of audio. You could implement this by developing a custom Renderer for audio which outputs zero filled buffers when silencing part of audio. This should be pretty straightforward - you can take PassthroughSoftwareRenderer as an example and modify it. I will soon enable support for audio filters which should let you do this at a filter level, without needing a custom renderer.
  2. Replacing original audio with a different track is something you can do now. You will have to define two TrackTransforms - one will have a MediaExtractorMediaSource that takes video track only, another will have MediaExtractorMediaSource that takes audio track only from a different file and both tracks will have a common MediaMuxerMediaTarget which will write both tracks into one file. There are examples of using TrackTransform in TransformationPresenter in demo app that should help. Mixing two audio tracks into one - LiTr does not do that yet.
  3. This is not a very straightforward task, LiTr does not support this yet.
Andriy0207 commented 3 years ago

@izzytwosheds: in case 2, I can replace the original audio with a new audio. However, when the audio is shorter than the video, is there a way to keep looping the audio to match the duration of the video?

izzytwosheds commented 3 years ago

LiTr does not yet support looping audio or video frames. I will try to look into this.