Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command failed with EBADF #2452

Closed
christiangenco opened this issue Jun 26, 2023 · 6 comments
Closed

Command failed with EBADF #2452

christiangenco opened this issue Jun 26, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@christiangenco
Copy link

christiangenco commented Jun 26, 2023

Recently when running some remotion jobs I've been getting an ffmpeg error at the very end of processing: Command failed with EBADF. Though remotion reports all frames have been rendered and encoded my final video.mp4 file isn't there.

Bug Report 🐛

I'm running remotion 3.3.100 on macOS 12.5.1 Monterey and ffmpeg 6.0. I haven't yet put together a minimal project that still gets this error in the hopes that this is a simple fix that might not have anything to do with remotion since it seems like the remotion part of actually rendering and encoding the video is succeeding.

Additionally, the /var/folders/jr/dbp0prg11g7_vsmyhys2p66h0000gn/T/remotion-v3-3-100-assetsb70v685s8f/remotion-assets-dir/08187108230777085.wav file that seems to be the cause of this error doesn't exist after the command finishes, and neither does the /var/folders/jr/dbp0prg11g7_vsmyhys2p66h0000gn/T/remotion-v3-3-100-assetsb70v685s8f parent directory.

Here's a little more context from my zsh shell:

$ /Users/cgenco/projects/multicam/node_modules/.bin/remotion render src/index.ts multicam --timeout 1000000 --props={} '/Users/cgenco/videos/2023-05-25 asia 05/video.mp4'
(1/3) ╭───────────────────╮ Bundled code 5630ms
    + ╭───────────────────╮ Copying public dir 4873ms
Entry point = src/index.ts (argument passed - found in cwd), Composition = multicam (Passed as argument), Codec = h264 (derived from out name), Output = /Users/cgenco/videos/2023-05-25 asia 05/video.mp4
(2/3) ╭───────────────────╮ Rendered frames (5x) 12529374ms
    + ╭───────────────────╮ Downloading 2 files
(3/3) ╭───────────────────╮ Encoding video 91157/91157
An error occurred:
Error: Command failed with EBADF: ffprobe -v error -show_entries stream=channels:format=duration -of default=nw=1 /var/folders/jr/dbp0prg11g7_vsmyhys2p66h0000gn/T/remotion-v3-3-100-assetsb70v685s8f/remotion-assets-dir/08187108230777085.wav
spawn EBADF
    at ChildProcess.spawn (node:internal/child_process:420:11)
    at Object.spawn (node:child_process:757:9)
    at execa (/Users/cgenco/projects/multicam/node_modules/execa/index.js:83:26)
    at getAudioChannelsAndDurationUnlimited (/Users/cgenco/projects/multicam/node_modules/@remotion/renderer/dist/assets/get-audio-channels.js:23:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.

I'd love any help in debugging this! If putting together a minimal failing project would help I can do that but it'd be some work I'd like to avoid if possible.

@christiangenco christiangenco added the bug Something isn't working label Jun 26, 2023
@JonnyBurger
Copy link
Member

JonnyBurger commented Jun 26, 2023

Wow interesting, it fails with a rare error code EBADF.

This should never happen and indicates an error in Node.JS.
Maybe nodejs/node#25335?

Could you let me know your Node version? Maybe try a newer one (>=16)?

@christiangenco
Copy link
Author

I'm on node v19.8.1.

I'm having a lot of trouble making a minimal working example for this bug—it doesn't happen with the exact same project if I limit the number of rendered frames.

Is there anything else you can think of that I could try?

@JonnyBurger
Copy link
Member

Interesting!

Let's try to think about reasons why EBADF could occur - it means "Bad file descriptor", meaning ffprobe is somehow a bad file descriptor?

Is there anything special about this binary? Does it only get downloaded before the render (maybe incomplete / still in macOS quarantine)?

Do you render multiple things at once or have other processes running?
Can you reliably run ffprobe on your system?

In Remotion 4.0, we will not rely on the system-installed ffprobe anymore. Instead, we ship our version that is confirmed running. Maybe this can also solve the problem (https://v4.remotion.dev/docs/4-0-alpha or official launch on July 3)

@christiangenco
Copy link
Author

OH I FIXED IT BUT I DON'T KNOW WHY

Switching to node v16.13.0 from v19.8.1 just made it work. I suppose I'll just make sure I'm on that node version until remotion 4.0 gets launched (I'm very excited for that by the way!).

To your questions:

  • I don't think there's anything special about the ffprobe binary. I installed it with homebrew and it lives at /opt/homebrew/bin/ffprobe and works fine in the shell. Certainly nothing about it changes between node versions.
  • I don't render multiple things at once but I do have tons of other processes running, though I don't think anything else would be running anything video related. It's possible on some of the failed commands I've been running another small ffmpeg job—Ill pay attention to whether this small job gets run on failed Remotion renders.

@JonnyBurger
Copy link
Member

Interesting, it must definitely be a Node bug then (maybe fixed by nodejs/node#44461)

I share your excitement! ✌️
I think there is nothing we can do, so closing this issue. But I will link this issue if someone gets a EBADF error in the future.

@JonnyBurger
Copy link
Member

faaf50c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants