ruanjx / VideoLab

High-performance and flexible video editing and effects framework, based on AVFoundation and Metal.
MIT License
845 stars 176 forks source link

Can't add an audio-only layer #4

Closed devoln closed 3 years ago

devoln commented 3 years ago

I have a RenderComposition with a video RenderLayer. I want to mix an audio file with this video. I tried to create another RenderLayer with an AVAsset created from an AAC file and add it to my RenderComposition. After that, I could hear two audio streams from my video and audio files together, but the image disappeared. I got a black screen instead of my video. Also, the length of the resulting video equals the length of the AAC file, even though I set a shorter CMTimeRange.

So, how do I accomplish this? Is this supported by VideoLab? If not, will it be supported and how can I work around this problem now?

devoln commented 3 years ago

I found this problem. It was probably my bug, I had a mismatch in source and layer durations. After I fixed it, everything is working correctly.

Coder-ACJHP commented 2 years ago

Hi @devoln I also facing same issue, I've tried a lot of things but either I got black screen or no audio. How do you add only audio can you share sample code here please? Thanks in advice

devoln commented 2 years ago

Hi @Coder-ACJHP Unfortunately, I don't have simple sample code separate from my project which is NDA.

My issue wasn't related to audio because it reproduced with a video file too.

The bug was fixed when I made all CMTimeRange fields in the layer and its source were set to have the same duration value.

Coder-ACJHP commented 2 years ago

Hi @Coder-ACJHP Unfortunately, I don't have simple sample code separate from my project which is NDA.

My issue wasn't related to audio because it reproduced with a video file too.

The bug was fixed when I made all CMTimeRange fields in the layer and its source were set to have the same duration value.

Thank you for quick reply, i got it 👍🏻