videolang / video

Source Code for Video language.
https://lang.video
Apache License 2.0
137 stars 14 forks source link

Error on preview in DrRacket #31

Closed takikawa closed 7 years ago

takikawa commented 7 years ago

I opened the "8-image.rkt" example and tried to preview it in DrRacket with the toolbar button. The result was this error:

avcodec-open2: Invalid Argument
  context...:
   /home/asumu/code/video/video/private/ffmpeg-pipeline.rkt:593:4: open method in mux%
   /home/asumu/code/video/video/render.rkt:552:11
LeifAndersen commented 7 years ago

Hey Asumu, thanks for submitting this issue. Can you tell me what OS you were using when you found this issue? I presume some form of debian?

takikawa commented 7 years ago

Yeah this is on Debian stable.

The more detailed error turns out to be AVCodecContext: Specified sample format fltp is invalid or not supported. The following patch gets rid of the problem for me, but I don't know if it's really the right fix. (maybe it should detect what to use based on the system?)

From 8760499f2e4491ab1e1e2425616059cd413d7d14 Mon Sep 17 00:00:00 2001
From: Asumu Takikawa <asumu@simplyrobot.org>
Date: Mon, 11 Sep 2017 19:20:23 -0700
Subject: [PATCH] Use s16 sample format by default

---
 video/private/ffmpeg-pipeline.rkt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/video/private/ffmpeg-pipeline.rkt b/video/private/ffmpeg-pipeline.rkt
index c0bf393..be28625 100644
--- a/video/private/ffmpeg-pipeline.rkt
+++ b/video/private/ffmpeg-pipeline.rkt
@@ -50,7 +50,7 @@
 (define DEFAULT-MAX-B-FRAMES 8)
 (define DEFAULT-SAMPLE-FREQ 44100)
 (define DEFAULT-PIX-FMT 'yuv420p)
-(define DEFAULT-SAMPLE-FMT 'fltp)
+(define DEFAULT-SAMPLE-FMT 's16)
 (define DEFAULT-CHANNELS 2)
 (define DEFAULT-CHANNEL-LAYOUT 'stereo)

-- 
2.11.0

Here's a potentially relevant bug thread from elsewhere: https://trac.ffmpeg.org/ticket/3107

LeifAndersen commented 7 years ago

Oh, that actually makes a lot of sense. The problem being that @jbclements 's portaudio package only works with s16, and the preview button isn't properly setting that as the output. (Where as the preview command is.)

So, the solution is not to set the default to s16, (because fltp seems to be more common for storing videos, but to have the preview button set it to s16, which is more common for live previews.)

Thank you for finding this.

LeifAndersen commented 7 years ago

Can you send me the output you get when running:

racket -W debug -l raco video -p 8-image.rkt

Thanks.

jbclements commented 7 years ago

Oops, missed this one. It doesn't look to me like there's any action required on my part, but let me know if I'm misreading this.

LeifAndersen commented 7 years ago

@jbclements Yup, this is correct. About the only thing I can think of is putting in a feature request to support other formats. But nah, there's no bug. Thanks though. :)

@takikawa Okay, I think I have traced the origin of this bug down to the same source as the one resizing one. I will push a fix shortly.

LeifAndersen commented 7 years ago

@takikawa I think I fixed the bug, can you test it again to make sure?

takikawa commented 7 years ago

@LeifAndersen Just pulled and it looks to be fixed, thanks!

LeifAndersen commented 7 years ago

Cool. Thank you.