Reencoding of clips in batch mode
How to reencode video, audio/video or audio clips.
Description
How to reencode video audio/video or audio clips
TVideoGrabber lets you reencode clips:
1) you can simply cut video clips by specifying a start and stop time,
2) you can reencode a clip:
- by specifying a start and or stop time,
- by using the current audio and/or video compressor,
- by appling 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".
- the times are specified in 100ns units, e.g. 3 seconds = 30000000
- if you specify a Reencoding_StartTime AND a Reencoding_StartFrame, the Reencoding_StartTime will be ignored.
- if you specify a Reencoding_StopTime AND a Reencoding_StopFrame, the Reencoding_StopTime will be ignored.
To start reencoding:
To start reencoding a video clip:
- set the "Reencoding_..." properties,
- invoke StartReencoding
Important remark:
when invoking StartReencoding, the process starts the reencoding and returns immediatly, it does not wait for the reencoding process to complete.
If you are creating the component programmatically, be sure to wait for the OnReencodingCompleted before destroying the component, otherwise the reencoding process would be interrupted before finished.
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. if you set 100 it starts at the frame #100
VideoGrabber1.Reencoding_StopFrame = -1 // -1 = beginning of the clip. E.g. if you set 500 it will stop when the frame #500 is reached
VideoGrabber1.Reencoding_StartTime = -1 // -1 = end of the clip. E.g. if you set 50000000 it will start at 5 seconds
VideoGrabber1.Reencoding_StopTime = -1 // -1 = end of the clip. E.g. if you set 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.
To extract in MP3, first download and register (with regsvr32.exe) the LAME Audio Encoder (freeware) that you can download here (the direct download link is here)
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 exact the whole audio from a video clip to a .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 exact the first 3 seconds of a video clip to a .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 in account:
Reencoding_StartTime
Reencoding_StopTime
Reencoding_StartFrame
Reencoding_StopFrame
the other Reencoding... settings are ignored.
Converting a DVD to a M2V file
You can reencode a DVD into a M2V format through DGMPGDec as follows:
- download the DGMPGDec executables from http://neuron2.net/dgmpgdec/dgmpgdec.html, unzip in the folder of your choice
- use the following reencoding commands:
E.g. let's suppose:
- you have unzipped DGMPGDec into c:/myDGfolder
- your DVD is placed in the "D:" drive
- you want to generate the M2V to c:/myOutputFolder/myOutputVideo.m2v
VideoGrabber.Reencoding_SourceVideoClip = "c:/myDGfolder/DGIndex.exe D:/VIDEO_TS"
VideoGrabber.Reencoding_NewVideoClip "c:/myOutputFolder/myOutputVideo.m2v"
VideoGrabber.StartReencoding()
Remark about the reencoding progress: the values reported by the OnReencodingProgress event are not significant, 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.
See Also
OnReencodingCompleted OnReencodingProgress OnReencodingStarted Reencoding_IncludeAudioStream Reencoding_IncludeVideoStream Reencoding_Method Reencoding_NewVideoClip Reencoding_SourceVideoClip Reencoding_StartFrame Reencoding_StartTime Reencoding_StopFrame Reencoding_StopTime Reencoding_UseAudioCompressor Reencoding_UseFrameGrabber Reencoding_UseVideoCompressor Reencoding_WMVOutput StartReencoding StopReencoding
Created with the Personal Edition of HelpNDoc: Maximize Your Productivity with HelpNDoc's CHM Help File Creation Features