How to split file when either transcoding or recording?

Started by renzska,

renzska

I'm wondering what the best way is to split one file into smaller files during transcoding and during recording.  I need both methods because my software allows both methods.

For the recording, I can do the split by starting a new recording at the specified interval, but I was wondering if there was a better way to do it post recording?

Is it possible to do this when transcoding and if so, how?

Thanks,

John

Ian @ un4seen

You could use BASS_SYNC_POS syncs to achieve what you want, eg. set a sync at a point that you want to split the encoding, and then in your callback function, stop the old encoder and start a new one. That can be applied to both recording and transcoding. It could look something like this...

QWORD syncbyte=BASS_ChannelSeconds2Bytes(handle, synctime); // byte position to sync/split at
BASS_ChannelSetSync(handle, BASS_SYNC_POS|BASS_SYNC_MIXTIME, syncbyte, SplitSyncProc, NULL); // set a mix-time POS sync there

...

void CALLBACK SplitSyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
BASS_Encode_Stop(channel); // stop the old encoder
BASS_Encode_Start(channel, ...); // start a new one
}

Couin

Hi Ian,

Google gave me this topic for my "split record file un4seen" search.
Will stopping and starting a new recording, make some little missing (not recorded, between stop first and start second) part of audio ?

Thanks :)

Ian @ un4seen

If you want the file splits to be seamless (so they sound perfect when rejoined) then you should only restart the encoder, not the recording. You could do that using BASS_SYNC_POS syncs (like in the post above) if you need the splits at exact intervals, or otherwise you could use BASS_ChannelLock to lock the recording while restarting the encoder. To minimize the lock time, you could start the new encoder in a paused state first:

newencoder = BASS_Encode_Start(recording, cmdline, BASS_ENCODE_PAUSE, NULL, NULL); // start the new encoder in paused state
BASS_ChannelLock(recording, true); // lock the recording
BASS_Encode_Stop(oldencoder); // stop the old encoder
BASS_Encode_SetPaused(newencoder, false); // unpause the new encoder
BASS_ChannelLock(recording, false); // unlock the recording

BASS_Encode_Start can be replaced with one of the format-specific variants, eg. BASS_Encode_StartPCM or BASS_Encode_OGG_Start.