SCRecorder icon indicating copy to clipboard operation
SCRecorder copied to clipboard

Losing sound on video recording after some time on iPod touch

Open thisdevguy opened this issue 10 years ago • 10 comments

During the video playback using the SCVideoPlayerView, the audio appears to playback fine until you reach the last part of the video (2-3 seconds) then it drops off and the video continues to play.

I am using the audio configuration provided in the ReadMe. Has anyone experience this behavior?

I am using iPod touch 5th generation running iOS 8.1.1

thisdevguy avatar Mar 06 '15 19:03 thisdevguy

Does that happen on every video even a local one that you setup manually? Is the exact same video playing fine on other devices?

I'm trying to know if this is a playback issue or recording issue. You can find that out by playing the recorded video on another device.

rFlex avatar Mar 19 '15 00:03 rFlex

It happens after recording session(s) using SCRecorder. The video plays fine on other devices (iPhone 5, iPhone 5s). It doesn't sound like the audio track is sped up.

thisdevguy avatar Mar 19 '15 15:03 thisdevguy

Same happens on iphone 4 iOS 7.1.2 Audio configuration: Bitrate = 128000; Sample Rate = 0 (default 44100) Channels Count = 2 (or 1) Format = kAudioFormatMPEG4AAC (default)

yarikpwnzer avatar Mar 31 '15 14:03 yarikpwnzer

Same problem on iPhone 6s Plus !

LiweiDong avatar Dec 23 '15 09:12 LiweiDong

Do you have any other solutions ?

LiweiDong avatar Dec 23 '15 09:12 LiweiDong

The solution was provided by someone in issue #249. You need to edit the adjustBuffer method located on line 430 in SCRecorderSession.m:

- (CMSampleBufferRef)adjustBuffer:(CMSampleBufferRef)sample withTimeOffset:(CMTime)offset andDuration:(CMTime)duration {
    CMItemCount count;
    CMSampleBufferGetSampleTimingInfoArray(sample, 0, nil, &count);
    CMSampleTimingInfo *pInfo = malloc(sizeof(CMSampleTimingInfo) * count);
    CMSampleBufferGetSampleTimingInfoArray(sample, count, pInfo, &count);

    for (CMItemCount i = 0; i < count; i++) {
        pInfo[i].decodeTimeStamp = CMTimeSubtract(pInfo[i].decodeTimeStamp, offset);
        pInfo[i].presentationTimeStamp = CMTimeSubtract(pInfo[i].presentationTimeStamp, offset);
        pInfo[i].duration = duration;
    }

    CMSampleBufferRef sout = sample;
//    CMSampleBufferCreateCopyWithNewTiming(nil, sample, count, pInfo, &sout);
    free(pInfo);
    return sout;
}

mitchellporter avatar Dec 31 '15 04:12 mitchellporter

@rFlex Is this line required? We can fill a PR to remove it if it's not required

crsantos avatar Jan 04 '16 14:01 crsantos

@crsantos Looking forward to @rFlex's response. Although removing the line in my comment above fixes the issue, I'm not sure if it will cause problems elsewhere as I haven't been working with SCRecorder long enough.

mitchellporter avatar Jan 05 '16 02:01 mitchellporter

Removing the line also fixed it for me. Just wondering if this line is required for something else or not... If someone has the answer...

fraxool avatar Jan 09 '16 18:01 fraxool

SCRecorder crashes when I remove that line

jamesfzhang avatar Dec 06 '16 19:12 jamesfzhang