Reencoding of clips in batch mode
How to reencode video, audio/video or audio clips
TVideoGrabber makes it possible to:
- simply cut video clips, by specifying a start and stop time,
- 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 are applied,
- Reencoding_WMVOutput: the clip is 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".
- The times are specified in 100ns units, e.g. 3 seconds = 30000000.
- If both a Reencoding_StartTime and a Reencoding_StartFrame are specified, Reencoding_StartTime is ignored.
- If both a Reencoding_StopTime and a Reencoding_StopFrame are specified, Reencoding_StopTime is ignored.
Starting the reencoding
To start reencoding a video clip:
- set the "Reencoding_..." properties,
- invoke StartReencoding.
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.