===== Avidemux Class ===== Assuming you created an instance with //adm=Avidemux()// ==== Loading and saving file ===== __adm.loadVideo('fileName')__ Load the video given as parameter __adm.appendVideo('fileName')__ Append the video given as parameter __adm.save('fileName')__ Save the video with given name __adm.saveAudio(int track,'fileName')__ Save track 'track' as 'fileName'. If an audio codec has been selected for that track, it will used when saving. __adm.audioAddExternal('fileName')__ Add fileName to the audioTrack pool. It will take the next number. That track is in the pool of available tracks, not in the active track. Use audioAddTrack() to add it. __adm.setContainer(container, params)__ Set the output container with params as parameters (optionnal). Example : adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280") ==== Getting Video info about loaded file(s) ===== __adm.getWidth()__ Return the width of loaded videos __adm.getHeight()__ Return the height of loaded videos __adm.getFps1000()__ Return average frame par second multiplied by 1000 So a 25 fps video will return 25000 __adm.getVideoCodec()__ Return the video codec as a string, for example 'DX50' ==== Getting Audio info about loaded file(s) ===== __adm.audioTracksCount()__ Return the number of active tracks. That include tracks from the video and added external tracks. __adm.audioEncoding(int track)__ Return the audio encoding, as an integer for track track. Common value are 85 for MP3 and 0x2000 for AC3. __adm.audioFrequency(int track)__ Return the sampling rate of track track. For example 48000 for a 48 Khz track __adm.audioChannels(int track)__ Return the sampling rate of track track. For example 48000 for a 48 Khz track __adm.audioBitrate(int track)__ Return the bitrate in kilobits of the given track. For example a bitrate of 64000 bits/s will return 64. ==== Editing ==== __adm.clearSegments()__ Purge previously loaded editing __adm.addSegments(ref,start,duration)__ Add a chunk of video from video ref, starting at 'start' micro seconds and for a 'duration' duration. For example : adm.addSegment(0, 0, 191668) Means add the chunk from video 0(the first video) starting from the beginning with a duration of 191 seconds (3mn11) If you dont call clearSegments or addSegments, by default, when adding a video a segment of the whole video is automatically appended. __adm.markerA and adm.markerB__ Set/get the marker position. They are in microseconds ==== Video Codec ==== __adm.setVideoCodec(codecName, params)__ Select codec codecName and set params as params. For example adm.videoCodec("ffMpeg4", "params=2PASSBITRATE=500", "lavcSettings=:version=2:") Params are a list of key/value pairs. The params will be checked and must be complete, i.e. include ALL parameters. __adm.videoCodecSetProfile(codecName, profileName)__ Load the profile "profileName" for the given codec. That also selects the codec. adm.videoCodecSetProfile("x264","PSP") __adm.changeVideoParam:videoCodecChangeParam(codecName, params)__ Change only one or several parameters for codecName. For example, you set all parameters using setVideoCodec and afterward only change bitrate ==== Video Filters ==== __adm.clearVideoFilters()__ Delete the filter chain. All filters are removed. __adm.addVideoFilter(filter, couples)__ Add the video filter named filter with couples as parameters. These parameters are key/value pair. Example : adm.addVideoFilter("swscale", "width=640", "height=352", "algo=2", "sourceAR=2", "targetAR=0") The list of parameters must be complete, it will be rejected otherwise. ==== Audio Filters ==== __adm.audioResetFilter(int track)__ Remove all the filters on track 'track'. __adm.audioSetMiset(track,mixer)__ Remix track "track" with mixer. Mixer can be "MONO","STEREO","3F_2R_LFE" (for 5.1), "DOLBY_PROLOGIC" and "DOLBY_PROLOGIC2". __adm.audioSetResample(track,frequency)__ Resample track "track" to frequency "frequency". Setting frequency to 0 disables resampling. __adm.audioSetPal2Film(track,onoff)__ Enable or disable pal2film audio filter on track "track". __adm.audioSetFilm2Pal(track,onoff)__ Enable or disable film2pal audio filter on track "track". __adm.audioSetNormalize(track,mode,gain)__ Enable or disable normalize audio filter on track "track". Mode is 0 for none, 1 for automatic and 2 for manual. The gain is 10* the real gain in db. i.e set 30 to get a +3 dB boost ==== Example ==== Here is the typical beginning of an avidemux tinyPy project adm = Avidemux() adm.loadVideo("/work/samples/avi/ac3_5channel.avi") adm.clearSegments() adm.addSegment(0, 0, 33400000) adm.markerA = 0 adm.markerB = 33400000 ==== Example 2 ==== adm = Avidemux() adm.loadVideo("/work/samples/avi/2mn.avi") adm.clearSegments() adm.addSegment(0, 0, 191524668) adm.markerA = 0 adm.markerB = 191524668 adm.videoCodec("ffMpeg4", "params=2PASSBITRATE=500") # truncated line adm.audioClearTracks() adm.audioAddTrack(0) adm.audioCodec(0, "Aften"); adm.audioSetDrc(0, 0) adm.audioSetShift(0, 0,0) adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280") ==== Traps and pitfall ==== Take care that a single line must not exceed ~ 256 chars. So instead of doing function("blah blah foobar") do function("blah blah" "foobar") ---- [[using:tinypy|Go back to tinypy]]