Skip to content

Reencoding of clips in batch mode

How to reencode video, audio/video or audio clips

TVideoGrabber makes it possible to reencode clips:

1) it is possible to simply cut video clips by specifying a start and stop time,

2) it is possible to reencode a clip:

  • by specifying a start and/or stop time,

  • by using the current audio and/or video compressor,

  • by applying any of the frame grabber features (text overlay, graphics overlay, video rotation, deinterlacing, etc...).

Reencoding properties

Reencoding_SourceVideoClip: file name of the source video clip

Reencoding_NewVideoClip: file name of the video clip to create

Reencoding_StartTime: start time expressed in 100ns units, (default -1 = beginning),

Reencoding_StartFrame: start frame (default -1 = beginning)

Reencoding_StopTime: stop time expressed in 100ns units, (default -1 = end),

Reencoding_StopFrame: stop frame (default -1 = end of the clip)

Reencoding_IncludeAudioStream: if enabled, the audio stream is included in the new video clip,

Reencoding_IncludeVideoStream: if enabled, the video stream is included in the new video clip,

Reencoding_Method: rm_AVI to record in AVI format, or rm_ASF to record in ASF format,

Reencoding_UseAudioCompressor: if enabled, the current audio compressor is used,

Reencoding_UseVideoCompressor: if enabled, the current video compressor is used,

Reencoding_UseFrameGrabber: if enabled, graphics, text overlays, cropping and rotation will be applied,

Reencoding_WMVOutput: the clip will be created as .WMV

About the start/stop frames and times
- the default -1 value specifies "start from the beginning of the clip" or "stop when the end of the clip is reached".

To start reencoding:
To start reencoding a video clip:

***Important remark: ***

when invoking StartReencoding, the process starts the reencoding and returns immediately, it does not wait for the reencoding process to complete.

If you create the component programmatically, be sure to wait for the OnReencodingCompleted before destroying the component, otherwise the reencoding process would be interrupted before it finishes.

E.g.:

VideoGrabber1.Reencoding_SourceVideoClip = "MyVideoClipToReencode.avi"
VideoGrabber1.Reencoding_NewVideoClip = "MyReencodedVideoClip.wmv"
VideoGrabber1.Reencoding_WMVOutput = true // output clip is wmv
VideoGrabber1.Reencoding_Method = rm_ASF
VideoGrabber1.Reencoding_StartFrame = -1 // -1 = beginning of the clip. E.g. when setting 100 it starts at the frame #100
VideoGrabber1.Reencoding_StopFrame = -1 // -1 = beginning of the clip. E.g. when setting 500 it will stop when the frame #500 is reached
VideoGrabber1.Reencoding_StartTime = -1 // -1 = end of the clip. E.g. when setting 50000000 it will start at 5 seconds
VideoGrabber1.Reencoding_StopTime = -1 // -1 = end of the clip. E.g. when setting 100000000 it will stop at 10 seconds
VideoGrabber1.Reencoding_IncludeAudioStream = true // if audio stream needed in the reencoded clip
VideoGrabber1.Reencoding_IncludeVideoStream = true // if video stream needed in the reencoded clip
VideoGrabber1.Reencoding_UseAudioCompressor = false
VideoGrabber1.Reencoding_UseVideoCompressor = false
VideoGrabber1.Reencoding_UseFrameGrabber = true
VideoGrabber1.StartReencoding // from now the progress will be returned periodically by the OnReencodingProgress event.end;

To stop the reencoding process before it ends, simply invoke StopReencoding.

Reencoding progress

When the reencoding begins, the OnReencodingStarted event occurs.

During the reencoding, the OnReencodingProgress event occurs periodically, reporting the percentage of completion.

When the reencoding ends, the OnReencodingCompleted event occurs.

Reencoding an audio clip / Extracting the audio from a video clip

It is possible to reencode an audio clip, or to extract only the audio to a .WAV or .MP3 audio clip, just by specifying ".wav" or ".mp3" as file extension for the new clip.

Sample code to extract 4 seconds of a WAV audio clip starting at 2 seconds (therefore stop time = 2s + 4s) and save them in MP3:

VideoGrabber.Reencoding_SourceVideoClip = "c:/myfolder/myvideoclip.wav"

VideoGrabber.Reencoding_Start_Frame = -1

VideoGrabber.Reencoding_Stop_Frame = -1

VideoGrabber.Reencoding_Start_Time = 20000000
VideoGrabber.Reencoding_Stop_Time = 60000000
VideoGrabber.Reencoding_NewVideoClip = "c:/myfolder/mynewclip.mp3"

VideoGrabber.StartReencoding()

Sample code to extract the whole audio from a video clip to .WAV format:

VideoGrabber.Reencoding_SourceVideoClip = "c:/myfolder/myvideoclip.avi"
VideoGrabber.Reencoding_Start_Frame = -1
VideoGrabber.Reencoding_Stop_Frame = -1
VideoGrabber.Reencoding_Start_Time = -1
VideoGrabber.Reencoding_Stop_Time = -1
VideoGrabber.Reencoding_NewVideoClip = "c:/myfolder/mynewclip.wav"
VideoGrabber.StartReencoding()

Sample code to extract the first 3 seconds of a video clip to .MP3 format:

VideoGrabber.Reencoding_SourceVideoClip = "c:/myfolder/myvideoclip.avi"

VideoGrabber.Reencoding_Start_Frame = -1

VideoGrabber.Reencoding_Stop_Frame = -1

VideoGrabber.Reencoding_Start_Time = -1

VideoGrabber.Reencoding_Stop_Time = 30000000
VideoGrabber.Reencoding_NewVideoClip = "c:/myfolder/mynewclip.mp3"

VideoGrabber.StartReencoding()

Remark:

when extracting audio, only the following Reencoding... settings are taken into account:

Reencoding_StartTime

Reencoding_StopTime

Reencoding_StartFrame

Reencoding_StopFrame

the other Reencoding... settings are ignored.

Remark about the reencoding progress: the values reported by the OnReencodingProgress event are not meaningful, because it is not possible to predict the time required to perform the reencoding with DGIndex.exe. The end of the reencoding will be notified by the OnReencodingCompleted event.