i have a custom audio and custom video

initially i tried to mux it in a avi mux .it wasnt able to do it "it gave an error saying that graph cannot cahnge state "

then i muxed it in mkv mux .it was able to mux but the sync was lost the video is being played at faster rate

how do rectify it