Gource icon indicating copy to clipboard operation
Gource copied to clipboard

gource ppm output triggers ffmpeg invalid data error

Open catchingknives opened this issue 7 years ago • 47 comments

Since version 0.5 ffmpeg comes back with the errors/warnings

Stream #0: not enough frames to estimate rate; consider increasing probesize

(but increasing probesize doesn't help) and

Invalid data found when processing input

when using the command line

gource -1280x720 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gource.mp4

as used in this example. This also applies to WebM encoding and for the method where you first go via the raw (ppm) video. ffmpeg always fails at the same second mark in my input file so it seems there's something there which it doesn't like?

catchingknives avatar Sep 27 '19 19:09 catchingknives

Same issue here. My version is ffmpeg-4.2.1.

hankcs avatar Sep 28 '19 05:09 hankcs

Does this happen with Gource 0.49 if you build it from source too? Wondering if its a change in behaviour with ffmpeg. Also what distro and release is this occuring on?

acaudwell avatar Oct 03 '19 03:10 acaudwell

Yes, it does. But 2.8.15 works fine.

hankcs avatar Oct 03 '19 03:10 hankcs

Can confirm I see the same issue with ffmpeg 4.2.1. ffmpeg 3.4.6 is fine.

acaudwell avatar Oct 07 '19 02:10 acaudwell

The Gource ppm header has a comment line # Generated by Gource. I tried generating a ppm without it and the Invalid data found when processing input error doesn't occur.

I see that the last change to the pnm_parser.c in FFmpeg is to the comment parsing: https://github.com/FFmpeg/FFmpeg/commit/10ea6c3116f95fc7f79d268ee2b839eea477337c

I think maybe bs = match + 1 should maybe be bs = match, but I haven't tried it.

acaudwell avatar Oct 11 '19 00:10 acaudwell

Hmm. That doesn't seem to be the right bit of code.

Since the comment in the header Gource includes is superfluous. I've removed it as a workaround for now https://github.com/acaudwell/Gource/commit/a3e7269b8f84be8f729a1f38e4a0c9bf3ce6379b.

acaudwell avatar Oct 17 '19 00:10 acaudwell

Gource 0.51 ffmpeg 4.2.1

Seems the issue still exists

image

apalchys avatar Nov 14 '19 07:11 apalchys

Oh? The fix is in the sub module, in src/core (src/core/ppm.cpp), is it possible the submodule is out of date?

Tried it again seems to be working.

acaudwell avatar Nov 14 '19 08:11 acaudwell

is there any way how I can troubleshoot it? I checked and ppm.cpp is up to date. I'm using MacOS (Catalina)

btw, it works if I set --stop-at-time 3 but when I set --stop-at-time 10 or longer, it starts failing.

apalchys avatar Nov 14 '19 12:11 apalchys

Things you could try:

  • check if gource is adding the #Generated by Gource header to the ppm output: gource -o - |head -n 2. If you see that message then you are running the old code
  • at the bottom of ppm.cpp in the dumpImpl() method add: fprintf(stderr, "width %d height %d rowstride %d\n", display.width, display.height, (int)rowstride); recompile and check that you see that message when you are recording gource with ffmpeg to confirm its actually using that version of ppm.cpp.

If it is using the new code and its still an issue could you could supply the command line your using, what resolution your running at.

acaudwell avatar Nov 14 '19 20:11 acaudwell

Would be useful to get other peoples experience with the fix.

acaudwell avatar Nov 14 '19 21:11 acaudwell

I did what you suggested above, recompiled and the issue still exists.

  1. gource -o - |head -n 2
P6
2048 1280 255
image

How I run: gource --viewport 1280x720 --seconds-per-day 1 --auto-skip-seconds 1 -o gource.ppm -r 25 --stop-at-time 20 --time-scale 2

ffmpeg -y -r 25 -f image2pipe -vcodec ppm -i gource.ppm -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -threads 0 -bf 0 gource.mp4

btw, it works fine with ffmpeg 3.4.2

apalchys avatar Nov 16 '19 09:11 apalchys

Thanks I will try those settings.

I notice the resolutions seem to be different in the output, I wonder if its has to do with Apple Retina display handling, maybe you could also try adding the SDL_WINDOW_ALLOW_HIGHDPI flag as detailed here: https://github.com/acaudwell/Gource/issues/74#issuecomment-443999494

One other thing to rule out is if you have several versions of gource and its running an old one?

acaudwell avatar Nov 17 '19 04:11 acaudwell

kia ora @acaudwell I confirmed that this change resolves this issue for me on FreeBSD when moving from 0.47 to 0.51. It's being used in dwatch(1) and you can see it in action later on in https://www.invidio.us/watch?v=xqOl_HY86n8 debugging kernels!

dch avatar Nov 26 '19 19:11 dch

@dch good to know. Didn't know about this thanks for the link.

acaudwell avatar Nov 27 '19 05:11 acaudwell

Having upgraded to 0.51 on macOS thanks to #225:

$ gource --help | head -1
Gource v0.51

I seem to still be running into the same issue. The generated log file's first couple of lines look like this:

$ head -2 prompt.ppm
P6
2560 1440 255

Display resolution is 2560x1600. The machine (Macbook Pro 2019, 13-inch, running 10.15.1) is also hooked up to two external displays, each of them displaying at 1920x1200. Gource was being run on the primary display (2560x1600).

ffmpeg was run like this:

$ ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i prompt.ppm -vcodec libx264 -preset medium -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 prompt.mp4

ffmpeg version is 4.2.1, installed via Homebrew.

If there's anything else I can provide to help diagnose this, apologies for omitting it and please don't hesitate to ask.

davep avatar Nov 28 '19 09:11 davep

Maybe it's related to the image size? You could try and render a smaller window (e.g. add -640x480 or something).

You could also try this SDL window flag option: https://github.com/acaudwell/Gource/issues/216#issuecomment-554701808

acaudwell avatar Nov 29 '19 02:11 acaudwell

It seems to still happen at 2560x1440. So the thing to eliminate if its any ppm video at that resolution or if its specific to gource.

acaudwell avatar Nov 29 '19 05:11 acaudwell

I should also really look at an alternative lossless video format with some basic compression. I might try adding a png output option with minimal compression so it's not too slow.

acaudwell avatar Nov 29 '19 05:11 acaudwell

Thanks @acaudwell, I'll look at checking those things (won't be back at my office desk until Tuesday so might not be until then -- unless I can get the data I was using down the wire at home).

I think I did forget to mention one thing: I'd run gource with -1280x720 as a parameter when generating the ppm. I'm afraid I don't know much about any of this, but does it make sense that it says "2560 1440" in the head of the ppm in that circumstance?

davep avatar Nov 29 '19 12:11 davep