Skip to content

Commit 90eddb8

Browse files
committed
Merge branch 'master' of github.com:edamameldn/tape-cli
* 'master' of github.com:edamameldn/tape-cli: Fix windows gifs + non-TTY shells (#57)
2 parents e6f71e6 + 53c2812 commit 90eddb8

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/commands/video.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ export default class Video extends GithubIssueOnErrorCommand {
6060

6161
const video = new VideoKlass({ device, verbose: flags.debug })
6262
video.record()
63-
cli.action.start(
64-
' 🎬 Recording started. Press SPACE to save or ESC to abort.'
65-
)
66-
6763
const success = await waitForKeys('space', 'escape')
6864

6965
cli.action.start(' 📼 Processing your tape')

src/helpers/keyboard.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import cli from 'cli-ux'
12
const readline = require('readline')
23

34
// TODO these should be arrays..maybeh?
@@ -12,7 +13,18 @@ export const waitForKeys = (
1213
})
1314

1415
readline.emitKeypressEvents(rl.input)
15-
rl.input.setRawMode(true)
16+
17+
if (process.stdin.isTTY) {
18+
rl.input.setRawMode(true)
19+
cli.action.start(
20+
' 🎬 Recording started. Press SPACE to save or ESC to abort.'
21+
)
22+
} else {
23+
cli.action.start(
24+
' 🎬 Recording started. Press Ctrl + C to save.'
25+
)
26+
process.on('SIGINT', function() { resolve(true) })
27+
}
1628

1729
process.stdin.on('keypress', (str, key) => {
1830
// console.log({ str, key })

src/services/ffmpeg.service.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,13 @@ export const makeGif = async (
8888
if (frameOptions) {
8989
const intermediary = `${os.tmpdir()}/intermediary.mov`
9090
const { extraInputs, complexFilter } = decodeFrameOptions(frameOptions)
91-
await exec(
92-
`
93-
${getFfmpegBin()} -i "${inputVideoFile}" ${extraInputs} -vcodec prores_ks -pix_fmt yuva444p10le -profile:v 4444 -q:v 23 -preset fastest ${complexFilter} -y ${intermediary} &&
94-
${getFfmpegBin()} -i "${intermediary}" -vf "${gifFilters},palettegen=stats_mode=diff:max_colors=${maxColors}" -y ${palette} &&
95-
${getFfmpegBin()} -i "${intermediary}" -i "${palette}" -lavfi "${gifFilters},paletteuse=dither=${dither}" -y "${outputFile}.gif"
96-
`
97-
)
91+
await exec(`${getFfmpegBin()} -i "${inputVideoFile}" ${extraInputs} -vcodec prores_ks -pix_fmt yuva444p10le -profile:v 4444 -q:v 23 -preset fastest ${complexFilter} -y ${intermediary}`)
92+
await exec(`${getFfmpegBin()} -i "${intermediary}" -vf "${gifFilters},palettegen=stats_mode=diff:max_colors=${maxColors}" -y ${palette}`)
93+
await exec(`${getFfmpegBin()} -i "${intermediary}" -i "${palette}" -lavfi "${gifFilters},paletteuse=dither=${dither}" -y "${outputFile}.gif"`)
94+
9895
} else {
99-
await exec(
100-
`
101-
${getFfmpegBin()} -i "${inputVideoFile}" -vf "${gifFilters},palettegen=stats_mode=diff:max_colors=${maxColors}" -y ${palette} &&
102-
${getFfmpegBin()} -i "${inputVideoFile}" -i "${palette}" -lavfi "${gifFilters},paletteuse=dither=${dither}" -y "${outputFile}.gif"
103-
`
104-
)
96+
await exec(`${getFfmpegBin()} -i "${inputVideoFile}" -vf "${gifFilters},palettegen=stats_mode=diff:max_colors=${maxColors}" -y ${palette}`)
97+
await exec(`${getFfmpegBin()} -i "${inputVideoFile}" -i "${palette}" -lavfi "${gifFilters},paletteuse=dither=${dither}" -y "${outputFile}.gif"`)
10598
}
10699

107100
return `${outputFile}.gif`

0 commit comments

Comments
 (0)