Convert to MPEG
MPEG-1/MPEG-2 Video. The API converts 30 formats to MPEG. These are the options, by input format.
curl https://api.switchfile.io/v1/convert \
-H "Authorization: Bearer $SWITCHFILE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/input.3g2","to":"mpeg","options":{"crf":23}}'const res = await fetch("https://api.switchfile.io/v1/convert", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"url":"https://example.com/input.3g2","to":"mpeg","options":{"crf":23}}),
});
console.log(await res.json());From 30 formats
video_codecenumdefault: not setVideo codec. "copy" keeps the video as it is and fails if it does not fit the format.
one of copy, mpeg2
crfintegerdefault: not setConstant Rate Factor: lower values mean higher quality and larger files. 0 to 51 for H.264 and H.265, 0 to 63 for VP9 and AV1.
0 to 31
presetenumdefault: not setEncoding speed against file size. Slower presets make smaller files.
one of ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow
widthintegerdefault: not setWidth of the video in pixels.
1 to 16384 px
heightintegerdefault: not setHeight of the video in pixels.
1 to 16384 px
fitenumdefault: max"max" fits the video inside width and height without enlarging it, "crop" fills and crops, "pad" adds bars, "scale" stretches to the exact size.
one of max, crop, pad, scale
fpsnumberdefault: not setFrame rate of the output.
0.1 to 240 fps
keyframe_intervalintegerdefault: not setLargest number of frames between two keyframes.
aspect_ratiostringdefault: not setDisplay aspect ratio, for example 16:9 or 4:3.
qscaleintegerdefault: not setFixed quality from 1 (best, largest file) to 31 for MPEG-4, MPEG-2 and WMV video.
all_audio_streamsbooleandefault: trueKeep all audio tracks. Set to false to keep only the main audio track.
subtitles_modeenumdefault: copy"copy" keeps the subtitle tracks of the input, "none" leaves them out.
one of none, copy
audio_codecenumdefault: not setAudio codec. "copy" keeps the audio as it is, "none" removes it.
one of copy, none, mp2, ac3
audio_bitrateintegerdefault: not setAudio bitrate in kbit/s. Without a value the encoder picks a quality-based rate.
volumenumberdefault: not setChange the volume: 1.0 keeps it, 1.1 is 10% louder, 0.5 is half as loud. At most 10.
channelsintegerdefault: not setNumber of audio channels, for example 1 for mono or 2 for stereo.
sample_rateintegerdefault: not setSample rate in Hz, for example 44100 or 48000 (8000 to 192000).
trim_startstringdefault: not setStart of the part to keep, in seconds or HH:MM:SS.
trim_endstringdefault: not setEnd of the part to keep, in seconds or HH:MM:SS.