deft

Audio and video examples

43 tasks from the deft benchmark. Each shows the task, the deft command, the input and the output, made by running that command. Subtitle tracks that can be switched off need a player such as VLC or QuickTime.

audio

Reduce background noise Checks passed

Reduce the background noise in example.ogg and save it as clean.mp3.

deft audio denoise example.ogg -o clean.mp3

Input

example.ogg 102 KB · vorbis, 6.1s

Output

clean.mp3 96 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "format"; file = "clean.mp3"; format = "mp3"

Codex with deft: not run. Without deft: not run.

Lower the bitrate Checks passed

Re-encode music.mp3 at 64 kbps as small.mp3.

deft audio compress music.mp3 --bitrate 64 -o small.mp3

Input

music.mp3 96 KB · mp3, 6.1s

Output

small.mp3 48 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "max_bytes"; file = "small.mp3"; bytes = 70000
  • type = "media"; file = "small.mp3"; audio_codec = "mp3"

Codex with deft: passed. Without deft: passed.

Fade out a track Checks passed

Add a 2 second fade out to the end of music.mp3 and save it as faded.mp3.

deft audio fade music.mp3 --fade-out 2 -o faded.mp3

Input

music.mp3 96 KB · mp3, 6.1s

Output

faded.mp3 96 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "format"; file = "faded.mp3"; format = "mp3"

Codex with deft: not run. Without deft: not run.

Listen faster Checks passed

Make speech.mp3 1.5 times faster without changing the pitch. Save it as fast.mp3.

deft audio speed speech.mp3 --factor 1.5 -o fast.mp3

Input

speech.mp3 13 KB · mp3, 3.3s

Output

fast.mp3 9 KB · mp3, 2.2s
Automatic checks, and Codex
  • type = "python"; code = "import subprocess; d = lambda f: float(subprocess.check_output(['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of', 'csv=p=0', f])); assert abs(d('fast.mp3') * 1.5 - d('speech.mp3')) < 0.5"

Codex with deft: not run. Without deft: not run.

Answer a question about audio Checks passed

What is the duration of example.ogg in seconds? Write the number to duration.txt.

deft audio info example.ogg > duration.txt

Input

example.ogg 102 KB · vorbis, 6.1s

Output

duration.txt 0 KB
ok audio.info example.ogg  0:06.104, vorbis
duration=6.104036 codec=vorbis sample_rate=44100 channels=2 bitrate=137342
Automatic checks, and Codex
  • type = "text"; file = "duration.txt"; contains = ["6."]

Codex with deft: passed. Without deft: passed.

Join audio files Checks passed

Join music.mp3 and tone.mp3, in that order, into both.mp3.

deft audio merge music.mp3 tone.mp3 -o both.mp3

Input

music.mp3 96 KB · mp3, 6.1s
tone.mp3 24 KB · mp3, 3.0s

Output

both.mp3 143 KB · mp3, 9.1s
Automatic checks, and Codex
  • type = "media"; file = "both.mp3"; duration = 9.2; tolerance = 0.4

Codex with deft: passed. Without deft: passed.

Mix two tracks Checks passed

Mix music.mp3 and speech.mp3 together into mixed.mp3.

deft audio mix music.mp3 speech.mp3 -o mixed.mp3

Input

music.mp3 96 KB · mp3, 6.1s
speech.mp3 13 KB · mp3, 3.3s

Output

mixed.mp3 96 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "format"; file = "mixed.mp3"; format = "mp3"

Codex with deft: not run. Without deft: not run.

Even out loudness Checks passed

Normalize the loudness of music.mp3 to about -16 LUFS and save it as level.mp3.

deft audio normalize music.mp3 -o level.mp3

Input

music.mp3 96 KB · mp3, 6.1s

Output

level.mp3 96 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "media"; file = "level.mp3"; duration = 6.1; tolerance = 0.5

Codex with deft: passed. Without deft: passed.

Convert audio Checks passed

Convert example.ogg to example.mp3.

deft audio convert example.ogg -o example.mp3

Input

example.ogg 102 KB · vorbis, 6.1s

Output

example.mp3 96 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "media"; file = "example.mp3"; audio_codec = "mp3"; duration = 6.1; tolerance = 0.3

Codex with deft: passed. Without deft: passed.

Lower the volume Checks passed

Lower music.mp3 by 6 dB and save it as quiet.mp3.

deft audio volume music.mp3 --gain -6 -o quiet.mp3

Input

music.mp3 96 KB · mp3, 6.1s

Output

quiet.mp3 96 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "format"; file = "quiet.mp3"; format = "mp3"

Codex with deft: not run. Without deft: not run.

Set the tags Checks passed

Set the title of music.mp3 to Morning and the artist to Ada, and save it as tagged.mp3.

deft audio tag music.mp3 --title Morning --artist Ada -o tagged.mp3

Input

music.mp3 96 KB · mp3, 6.1s

Output

tagged.mp3 96 KB · mp3, 6.1s
Automatic checks, and Codex
  • type = "python"; code = "import json, subprocess; t = json.loads(subprocess.check_output(['ffprobe', '-v', 'error', '-print_format', 'json', '-show_format', 'tagged.mp3']))['format']['tags']; assert t['title'] == 'Morning' and t['artist'] == 'Ada', t"

Codex with deft: not run. Without deft: not run.

Remove the silences Checks passed

Remove the long silent parts from pauses.mp3 and save it as tight.mp3.

deft audio remove-silence pauses.mp3 --min-silence 1 -o tight.mp3

Input

pauses.mp3 62 KB · mp3, 15.7s

Output

tight.mp3 45 KB · mp3, 11.6s
Automatic checks, and Codex
  • type = "format"; file = "tight.mp3"; format = "mp3"

Codex with deft: not run. Without deft: not run.

Keep the first seconds Checks passed

Keep only the first 3 seconds of music.mp3, as intro.mp3.

deft audio split music.mp3 --to-time 3 -o intro.mp3

Input

music.mp3 96 KB · mp3, 6.1s

Output

intro.mp3 48 KB · mp3, 3.0s
Automatic checks, and Codex
  • type = "media"; file = "intro.mp3"; duration = 3; tolerance = 0.2

Codex with deft: passed. Without deft: passed.

subtitle

Pull subtitles out of a video Checks passed

movie-subs.mp4 has a subtitle track. Save it as subs.srt.

deft subtitle from-video movie-subs.mp4 -o subs.srt

Input

movie-subs.mp4 947 KB · h264 1280x720, mov_text, 10.0s

Output

subs.srt 0 KB
1
00:00:00,500 --> 00:00:03,000
A quiet morning in the forest

2
00:00:03,500 --> 00:00:06,000
The big bunny wakes up

3
00:00:06,500 --> 00:00:09,500
Something is about to happen

Automatic checks, and Codex
  • type = "text"; file = "subs.srt"; contains = ["The big bunny wakes up", "-->"]

Codex with deft: passed. Without deft: passed.

Fix subtitles that are out of sync Checks passed

The subtitles in talk.srt appear 2 seconds too early. Save a fixed copy as fixed.srt.

deft subtitle shift talk.srt --by 2 -o fixed.srt

Input

talk.srt 0 KB
1
00:00:00,500 --> 00:00:03,000
A quiet morning in the forest

2
00:00:03,500 --> 00:00:06,000
The big bunny wakes up

3
00:00:06,500 --> 00:00:09,500
Something is about to happen

Output

fixed.srt 0 KB
1
00:00:02,500 --> 00:00:05,000
A quiet morning in the forest

2
00:00:05,500 --> 00:00:08,000
The big bunny wakes up

3
00:00:08,500 --> 00:00:11,500
Something is about to happen

Automatic checks, and Codex
  • type = "text"; file = "fixed.srt"; contains = ["00:00:02,500 --> 00:00:05,000", "00:00:08,500 --> 00:00:11,500"]

Codex with deft: passed. Without deft: passed.

Convert subtitles for the web Checks passed

Convert talk.srt to WebVTT as talk.vtt.

deft subtitle convert talk.srt -o talk.vtt

Input

talk.srt 0 KB
1
00:00:00,500 --> 00:00:03,000
A quiet morning in the forest

2
00:00:03,500 --> 00:00:06,000
The big bunny wakes up

3
00:00:06,500 --> 00:00:09,500
Something is about to happen

Output

talk.vtt 0 KB
WEBVTT

00:00:00.500 --> 00:00:03.000
A quiet morning in the forest

00:00:03.500 --> 00:00:06.000
The big bunny wakes up

00:00:06.500 --> 00:00:09.500
Something is about to happen

Automatic checks, and Codex
  • type = "text"; file = "talk.vtt"; contains = ["WEBVTT", "00:00:03.500 --> 00:00:06.000", "The big bunny wakes up"]

Codex with deft: passed. Without deft: passed.

Subtitles to a plain transcript Checks passed

Turn talk.srt into a plain text transcript with no timestamps, as transcript.txt.

deft subtitle convert talk.srt -o transcript.txt

Input

talk.srt 0 KB
1
00:00:00,500 --> 00:00:03,000
A quiet morning in the forest

2
00:00:03,500 --> 00:00:06,000
The big bunny wakes up

3
00:00:06,500 --> 00:00:09,500
Something is about to happen

Output

transcript.txt 0 KB
A quiet morning in the forest The big bunny wakes up Something is about to happen
Automatic checks, and Codex
  • type = "text"; file = "transcript.txt"; contains = ["A quiet morning in the forest", "Something is about to happen"]; absent = ["-->", "00:00"]

Codex with deft: passed. Without deft: passed.

video

Add a soundtrack Checks passed

Replace the sound of movie.mp4 with music.mp3 and save it as scored.mp4.

deft video add-audio movie.mp4 --audio music.mp3 -o scored.mp4

Input

movie.mp4 1.1 MB · h264 1280x720, aac, 10.0s
music.mp3 96 KB · mp3, 6.1s

Output

scored.mp4 1.0 MB · h264 1280x720, aac, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "scored.mp4"; has_audio = true; has_video = true

Codex with deft: not run. Without deft: not run.

Burn subtitles into a video Checks passed

Burn the subtitles from talk.srt into bunny.mp4 so they are always visible. Save it as subbed.mp4.

deft video add-subtitles bunny.mp4 --subtitles talk.srt -o subbed.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s
talk.srt 0 KB
1
00:00:00,500 --> 00:00:03,000
A quiet morning in the forest

2
00:00:03,500 --> 00:00:06,000
The big bunny wakes up

3
00:00:06,500 --> 00:00:09,500
Something is about to happen

Output

subbed.mp4 1.9 MB · h264 1280x720, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "subbed.mp4"; duration = 10; tolerance = 0.6; has_video = true
  • type = "video_frame"; file = "subbed.mp4"; from = "bunny.mp4"; at = 1.5; min_difference = 0.15

Codex with deft: passed. Without deft: passed.

Shrink a video to a size limit Checks passed

bunny.mp4 must be under 400KB for an upload form. Save it as small.mp4, keeping the full length.

deft video compress bunny.mp4 --target-size 380KB -o small.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

small.mp4 369 KB · h264 1280x720, 10.0s
Automatic checks, and Codex
  • type = "max_bytes"; file = "small.mp4"; bytes = 409600
  • type = "media"; file = "small.mp4"; duration = 10; tolerance = 0.5

Codex with deft: passed. Without deft: passed.

Crop a video to a square Checks passed

Crop bunny.mp4 to a centered square called square.mp4.

deft video crop bunny.mp4 --aspect 1:1 -o square.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

square.mp4 1.1 MB · h264 720x720, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "square.mp4"; width = 720; height = 720

Codex with deft: passed. Without deft: passed.

Join with a crossfade Checks passed

Join bunny.mp4 and jellyfish.mp4 with a one second fade between them into joined.mp4.

deft video merge bunny.mp4 jellyfish.mp4 --transition fade -o joined.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s
jellyfish.mp4 1023 KB · h264 1280x720, 10.0s

Output

joined.mp4 4.5 MB · h264 1280x720, 19.0s
Automatic checks, and Codex
  • type = "media"; file = "joined.mp4"; has_video = true

Codex with deft: not run. Without deft: not run.

Save the soundtrack Checks passed

Save the audio track of movie.mp4 as sound.mp3.

deft video extract-audio movie.mp4 -o sound.mp3

Input

movie.mp4 1.1 MB · h264 1280x720, aac, 10.0s

Output

sound.mp3 157 KB · mp3, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "sound.mp3"; has_audio = true; has_video = false; audio_codec = "mp3"; duration = 10; tolerance = 0.5

Codex with deft: passed. Without deft: passed.

Grab one frame Checks passed

Save the frame at 5 seconds in bunny.mp4 as frame.jpg.

deft video frames bunny.mp4 --at 5 -o frame.jpg

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

frame.jpg 101 KB
frame.jpg
Automatic checks, and Codex
  • type = "image"; file = "frame.jpg"; format = "JPEG"; width = 1280

Codex with deft: passed. Without deft: passed.

Sample frames Checks passed

Save one frame every 2 seconds of bunny.mp4 as images in a folder called frames.

deft video frames bunny.mp4 --fps 0.5 -o frames/

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

bunny-0001.jpg 101 KB
bunny-0001.jpg
bunny-0002.jpg 130 KB
bunny-0002.jpg
bunny-0003.jpg 237 KB
bunny-0003.jpg
bunny-0004.jpg 237 KB
bunny-0004.jpg
bunny-0005.jpg 190 KB
bunny-0005.jpg
Automatic checks, and Codex
  • type = "count_files"; glob = "frames/*"; min = 5; max = 6

Codex with deft: passed. Without deft: passed.

Sample frames from a point Checks passed

Starting at 4 seconds into bunny.mp4, save one frame every 2 seconds into a folder called frames.

deft video frames bunny.mp4 --from 4 --interval 2 -o frames/

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

bunny-0001.jpg 102 KB
bunny-0001.jpg
bunny-0002.jpg 131 KB
bunny-0002.jpg
bunny-0003.jpg 245 KB
bunny-0003.jpg
Automatic checks, and Codex
  • type = "count_files"; glob = "frames/*"; min = 3; max = 4

Codex with deft: not run. Without deft: not run.

Make a GIF Checks passed

Make a 320 pixel wide GIF called clip.gif from the first 3 seconds of bunny.mp4.

deft video to-gif bunny.mp4 --to-time 3 --size 320x -o clip.gif

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

clip.gif 1.4 MB
clip.gif
Automatic checks, and Codex
  • type = "image"; file = "clip.gif"; format = "GIF"; width = 320
  • type = "media"; file = "clip.gif"; duration = 3; tolerance = 0.5

Codex with deft: passed. Without deft: passed.

Answer a question about a video Checks passed

How long is jellyfish.mp4 in seconds, and what is its resolution? Write the answer to info.txt.

deft video info jellyfish.mp4 > info.txt

Input

jellyfish.mp4 1023 KB · h264 1280x720, 10.0s

Output

info.txt 0 KB
ok video.info jellyfish.mp4  0:10.010, 1280x720
duration=10.01001 width=1280 height=720 fps=29.97 video_codec=h264 bitrate=837535
Automatic checks, and Codex
  • type = "text"; file = "info.txt"; contains = ["1280", "720"]

Codex with deft: passed. Without deft: passed.

Join two clips Checks passed

Join bunny.mp4 and jellyfish.mp4, in that order, into both.mp4.

deft video merge bunny.mp4 jellyfish.mp4 -o both.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s
jellyfish.mp4 1023 KB · h264 1280x720, 10.0s

Output

both.mp4 4.5 MB · h264 1280x720, 20.0s
Automatic checks, and Codex
  • type = "media"; file = "both.mp4"; duration = 20; tolerance = 0.6

Codex with deft: passed. Without deft: passed.

Remove the sound Checks passed

Remove the audio from movie.mp4 and save it as silent.mp4.

deft video mute movie.mp4 -o silent.mp4

Input

movie.mp4 1.1 MB · h264 1280x720, aac, 10.0s

Output

silent.mp4 947 KB · h264 1280x720, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "silent.mp4"; has_audio = false; has_video = true

Codex with deft: passed. Without deft: passed.

Cut into equal parts Checks passed

Cut bunny.mp4 into 3 second parts in a folder called parts.

deft video chunk bunny.mp4 --length 3 -o parts/

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

bunny-000.mp4 1.2 MB · h264 1280x720, 6.0s
bunny-001.mp4 735 KB · h264 1280x720, 3.0s
bunny-002.mp4 296 KB · h264 1280x720, 1.0s
Automatic checks, and Codex
  • type = "count_files"; glob = "parts/*.mp4"; min = 2

Codex with deft: not run. Without deft: not run.

Scale down Checks passed

Make a 480p version of bunny.mp4 called sd.mp4.

deft video resize bunny.mp4 --size x480 -o sd.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

sd.mp4 1.1 MB · h264 854x480, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "sd.mp4"; height = 480

Codex with deft: passed. Without deft: passed.

Rotate a video Checks passed

Rotate bunny.mp4 90 degrees clockwise and save it as tall.mp4.

deft video rotate bunny.mp4 -o tall.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

tall.mp4 1.9 MB · h264 720x1280, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "tall.mp4"; width = 720; height = 1280

Codex with deft: passed. Without deft: passed.

Photos to a video Checks passed

Make a slideshow show.mp4 from hopper.png and DSCN0010.jpg, three seconds each.

deft video from-images hopper.png DSCN0010.jpg --duration 3 -o show.mp4

Input

DSCN0010.jpg 158 KB
DSCN0010.jpg
hopper.png 30 KB
hopper.png

Output

show.mp4 15 KB · h264 128x128, 6.0s
Automatic checks, and Codex
  • type = "media"; file = "show.mp4"; duration = 6; tolerance = 0.5

Codex with deft: not run. Without deft: not run.

Add a subtitle track viewers can switch off Checks passed

Add talk.srt to bunny.mp4 as a subtitle track that viewers can turn on and off. Do not re-encode the video. Save it as soft.mp4.

deft video add-subtitles bunny.mp4 --subtitles talk.srt --soft -o soft.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s
talk.srt 0 KB
1
00:00:00,500 --> 00:00:03,000
A quiet morning in the forest

2
00:00:03,500 --> 00:00:06,000
The big bunny wakes up

3
00:00:06,500 --> 00:00:09,500
Something is about to happen

Output

soft.mp4 947 KB · h264 1280x720, mov_text, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "soft.mp4"; has_subtitles = true; video_codec = "h264"

Codex with deft: passed. Without deft: passed.

Speed up a clip Checks passed

Make bunny.mp4 play twice as fast and save it as fast.mp4.

deft video speed bunny.mp4 --factor 2 -o fast.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

fast.mp4 1.3 MB · h264 1280x720, 5.0s
Automatic checks, and Codex
  • type = "python"; code = "import subprocess; d = lambda f: float(subprocess.check_output(['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of', 'csv=p=0', f])); assert abs(d('fast.mp4') * 2 - d('bunny.mp4')) < 1"

Codex with deft: not run. Without deft: not run.

Steady a shaky clip Checks passed

shaky.mp4 was filmed by hand. Stabilize it and save it as steady.mp4.

deft video stabilize shaky.mp4 -o steady.mp4

Input

shaky.mp4 3.5 MB · h264 1280x720, 10.0s

Output

steady.mp4 1.6 MB · h264 1280x720, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "steady.mp4"; has_video = true
  • type = "python"; code = """; import re, subprocess; out = subprocess.run(['ffmpeg', '-i', 'steady.mp4', '-vf', 'tblend=all_mode=difference,signalstats,metadata=print:key=lavfi.signalstats.YAVG:file=-', '-f', 'null', '-'], capture_output=True, text=True).stdout; change = [float(v) for v in re.findall(r'YAVG=([0-9.]+)', out)]; assert sum(change) / len(change) < 6, 'the picture still shakes'; """

Codex with deft: not run. Without deft: not run.

Poster image Checks passed

Make a poster image poster.jpg for bunny.mp4 from the frame at 5 seconds.

deft video thumbnail bunny.mp4 --at 5 -o poster.jpg

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

poster.jpg 101 KB
poster.jpg
Automatic checks, and Codex
  • type = "image"; file = "poster.jpg"; format = "JPEG"

Codex with deft: not run. Without deft: not run.

Cut a clip Checks passed

Cut seconds 2 to 5 out of bunny.mp4 and save them as clip.mp4.

deft video split bunny.mp4 --from 2 --to-time 5 -o clip.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

clip.mp4 618 KB · h264 1280x720, 3.0s
Automatic checks, and Codex
  • type = "media"; file = "clip.mp4"; duration = 3; tolerance = 0.3; has_video = true

Codex with deft: passed. Without deft: passed.

Fit into a vertical frame Checks passed

Put bunny.mp4 into a 1080x1920 vertical frame with black bars, keeping the whole picture. Save it as tall.mp4.

deft video pad bunny.mp4 --size 1080x1920 -o tall.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

tall.mp4 1.6 MB · h264 1080x1920, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "tall.mp4"; width = 1080; height = 1920

Codex with deft: not run. Without deft: not run.

Put a watermark on a video Checks passed

Add the text SAMPLE in the bottom right corner of bunny.mp4 for its whole length. Save it as marked.mp4.

deft video watermark bunny.mp4 --text SAMPLE -o marked.mp4

Input

bunny.mp4 946 KB · h264 1280x720, 10.0s

Output

marked.mp4 1.9 MB · h264 1280x720, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "marked.mp4"; duration = 10; tolerance = 0.6
  • type = "video_frame"; file = "marked.mp4"; from = "bunny.mp4"; at = 5; min_difference = 0.1

Codex with deft: passed. Without deft: passed.

Convert WebM for compatibility Checks passed

Convert bunny.webm to an H.264 MP4 called bunny.mp4.

deft video convert bunny.webm -o bunny.mp4

Input

bunny.webm 1022 KB · vp9 1280x720, 10.0s

Output

bunny.mp4 1.9 MB · h264 1280x720, 10.0s
Automatic checks, and Codex
  • type = "media"; file = "bunny.mp4"; video_codec = "h264"; duration = 10; tolerance = 0.5

Codex with deft: passed. Without deft: passed.

Credits

Other inputs were made for these tests, some from the files above.