Skip to content

Saving and restoring compressor settings programmatically

Note

FFDShow references are deprecated.

Saving and restoring compressor settings programmatically The settings of a given compressor can be set by invoking ShowDialog (dlg_VideoCompressor) or ShowDialog (dlg_AudioCompressor)

E.g. to configure the Lame MP3 encoder from Elecard: VideoGrabber.RecordingMethod = rm_AVI VideoGrabber.VideoCompressor = VideoGrabber.VideoCompressorIndex ("Lame Audio Encoder") VideoGrabber.ShowDialog (dlg_AudioCompressor)

These settings are kept in the registry and reused for each MP3 or AVI recording using the Lame Audio Encoder compressor.

It is possible to export these settings either to a string, either to a text file, in order to generate a set of predefined settings that can be reloaded programmatically later without having to invoke the filter dialog.

The current settings can be saved by invoking either SaveCompressorSettingsToDataString or SaveCompressorSettingsToTextFile .

Then they can be reloaded later programmatically by invoking LoadCompressorSettingsFromDataString or LoadCompressorSettingsFromTextFile .

The first parameter of the functions -named IsVideoCompressor- must be set to true for a video compressor and false for an audio compressor.

Note: be sure to always select the RecordingMethod and VideoCompressor (the settings depend on them) before invoking these functions (or AudioCompressor for Audio codecs)(1) in the examples below, replace ("...") by the name of the video compressor as it appears in the "video compressors" listE.g. to save the ffdshow settings to a file for a FLV recording VideoGrabber.RecordingMethod = rm_FLV VideoGrabber.VideoCompressor = VideoGrabber.VideoCompressorIndex ("...") (1) if VideoGrabber.VideoCompressor > -1 then VideoGrabber.ShowDialog (dlg_VideoCompressor) VideoGrabber.SaveCompressorSettingsToTextFile (true, VideoGrabber.VideoCompressor, "myFLVsettings.txt") end if then to reuse them for a recording by restoring programmatically the settings: VideoGrabber.RecordingMethod = rm_FLV VideoGrabber.VideoCompressor = VideoGrabber.VideoCompressorIndex ("...") (1) if VideoGrabber.VideoCompressor > -1 then if VideoGrabber.LoadCompressorSettingsFromTextFile (true, VideoGrabber.VideoCompressor, "myFLVsettings.txt") then VideoGrabber.StartRecording() end if end if E.g. to save the ffdshow settings to a string for a MP4 recording VideoGrabber.RecordingMethod = rm_MP4 VideoGrabber.VideoCompressor = VideoGrabber.VideoCompressorIndex ("...") (1) if VideoGrabber.VideoCompressor > -1 then VideoGrabber.ShowDialog (dlg_VideoCompressor) MyDataString = VideoGrabber.SaveCompressorSettingsToDataString (true, VideoGrabber.VideoCompressor) end if then to reuse them for a recording *MyDataString = ... reload the data string * VideoGrabber.RecordingMethod = rm_MP4 VideoGrabber.VideoCompressor = VideoGrabber.VideoCompressorIndex ("...") (1) if VideoGrabber.VideoCompressor > -1 then if VideoGrabber.LoadCompressorSettingsFromTextFile (true, VideoGrabber.VideoCompressor, MyDataString) then VideoGrabber.StartRecording() end if end if

E.g. to save the LAME MP3 encoder settings to a file for a MP3 recording: VideoGrabber.RecordingMethod = rm_AVI VideoGrabber.AudioCompressor = VideoGrabber.AudioCompressorIndex ("LAME Audio Encoder") if VideoGrabber.AudioCompressor > -1 then VideoGrabber.ShowDialog (dlg_AudioCompressor) VideoGrabber.SaveCompressorSettingsToTextFile (false, VideoGrabber.AudioCompressor, "myMP3settings.txt") end if then to reuse them for a recording VideoGrabber.RecordingMethod = rm_AVI VideoGrabber.AudioCompressor = VideoGrabber.VideoCompressorIndex ("LAME Audio Encoder") if VideoGrabber.AudioCompressor > -1 then if VideoGrabber.LoadCompressorSettingsFromTextFile (false, VideoGrabber.AudioCompressor, "myMP3settings.txt") then VideoGrabber.StartAudioRecording() end if end if