Skip to content

Reencoding of clips in batch mode

How to reencode video, audio/video or audio clips

TVideoGrabber makes it possible to:

  1. simply cut video clips, by specifying a start and stop time,
  2. 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

About the start/stop frames and times

Starting the reencoding

To start reencoding a video clip:

Warning

When StartReencoding is invoked, it starts the reencoding process and returns immediately: it does not wait for the reencoding process to complete.

If the component is created programmatically, be sure to wait for the OnReencodingCompleted event before destroying the component, otherwise the reencoding process is 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 = end of the clip. E.g. when setting 500 it will stop when the frame #500 is reached
VideoGrabber1.Reencoding_StartTime = -1; // -1 = beginning 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.

To stop the reencoding process before it ends, 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

To reencode an audio clip, or to extract only the audio to a .WAV or .MP3 audio clip, just specify ".wav" or ".mp3" as the file extension of 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_StartFrame = -1
VideoGrabber.Reencoding_StopFrame = -1
VideoGrabber.Reencoding_StartTime = 20000000
VideoGrabber.Reencoding_StopTime = 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_StartFrame = -1
VideoGrabber.Reencoding_StopFrame = -1
VideoGrabber.Reencoding_StartTime = -1
VideoGrabber.Reencoding_StopTime = -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_StartFrame = -1
VideoGrabber.Reencoding_StopFrame = -1
VideoGrabber.Reencoding_StartTime = -1
VideoGrabber.Reencoding_StopTime = 30000000
VideoGrabber.Reencoding_NewVideoClip = "c:\myfolder\mynewclip.mp3"
VideoGrabber.StartReencoding()

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

The other Reencoding... settings are ignored.

Note

About the reencoding progress with DGIndex.exe: 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 is notified by the OnReencodingCompleted event.