Log in

View Full Version : extracting images, problem with framecount


tacman1123
19th November 2008, 19:21
I'm running a utility to create an image an mp4 file. The frames look right in Avisynth, they look right in AVS Video ReMaker, but when I try to extract a single image using ffmpeg, the frame numbers are off by a significant amount (several seconds).

My theory: I installed haali splitter and ffdshow yesterday, so now mp4 files playing correctly. Maybe the ffmpeg library reads the file directly and skips some critical decoding, causing the frames to be off.

I was hoping to dynamically create images from the mp4 file. I can't use ImageWriter, because I want it to be dynamic (and I want it to run under 'nix). It appears that MOST of the time extracting frames works, but in this case it doesn't. I can post the mp4 file if that's helpful, but maybe somebody knows if my theory holds any water.

Any suggestions for a dynamic image extractor that pulls still frames out of an mp4 file and can resize them, etc.?

Here's my Avisynth code that properly extracts the frame:

DirectShowSource("c:\avi\media\mp4\07dLvKGZ8D8.mp4").Trim(810, -1).ConvertToRGB32(matrix="Rec601", interlaced=false)
ImageWriter("c:\avi\media\mp4\problem_", type="jpg")

The mp4 file can be found at

http://videothoughts.com/wowza/avisynth/07dLvKGZ8D8.mp4

An example of the problem image is at

http://videothoughts.com/project/movietools/clip_image.php?full_fn=/usr/sites/wowza/avisynth/07dLvKGZ8D8.mp4&frame=810

The result of the Avisynth script above can be found at

http://videothoughts.com/wowza/avisynth/problem_000000.jpg

It's not just a zero-based, off by one, problem. Using the ffmpeg library I'm almost 100 frames off from using Avisynth (again, I believe Avisynth is accurate).

I guess the other issue, rather than the Haali Splitter, could be something to do with the frame rate, though that doesn't really feel right.

Thanks,

Tac

Leak
20th November 2008, 00:58
Never use "DirectShowSource" and "accurate seeking" in the same sentence - it's a bad idea... :)

But anyway, you might want to use ffmpegSource (http://forum.doom9.org/showthread.php?t=127037) instead, which should be frame accurate...

np: Rhythm & Sound with Tikiman - Never Tell You (Version) (Showcase)

tacman1123
20th November 2008, 01:48
Thanks, I've installed it, but getting a "Unable to load c:\plugins\FFMpegSource.dll, even though the file is in the directory.

I've uninstalled Haali and ffdshow, while I was able to open .mp4 files and hear sound while they were installed, I was no longer able to open plain .avi files with either AviSource or DirectShowSource, and that broke lots of things. My application that was calling avisynth also was not returning accurate frame counts at all -- in fact, it always came out as frame 1 of 4.

So I've come to the conclusion that different programs are going to seek differently, depending on the file format, program, and codecs and utilities installed. This is somewhat problematic, as I was using a Windows-based scene detection program (AVS Video ReMaker), extracting the start frames from their project file, then feeding those into a web interface with start and end frames, with the idea that the user would be able to make comments on individual scenes. Finally, those comments would get integrated back into an avisynth script. Although the comments weren't subtitles, if they were, how does one make sure the subtitles are kept in sync with the video if the frame positioning changes between systems? Use a Timed Text format instead?

The mp4 files come from youtube, downloaded from Tubetilla to mp4. Not sure if that's relevant to this conversation, but maybe it is.

Thx,

Tac

tacman1123
20th November 2008, 16:22
Is it possible that the runtime functions and frame seeking aren't 100% accurate in AvsP, and may differ from running the same script through another player? Leak mentioned it shouldn't be used for accurate seeking, so I'm guessing that some of the reasons I'm pulling my hair out right now is that I'm doing debugging in AvsP with a file created in Avisynth, but running it through another player.

I'm using ConditionalReader and ClipScript() and it seems to work sometimes, but when I go to debug in AvsP the frames are all in the wrong spot. Sometimes. Maybe when going forwards and backwards? Anyway, if this is known behavior then I'll relax, it appears to work consistently through other players, but not in AvsP.

Tac

Gavino
20th November 2008, 17:07
...when I go to debug in AvsP the frames are all in the wrong spot. Sometimes. Maybe when going forwards and backwards?
This is your problem, I think. See Leek's remarks.

If still using DirectShowSource, you might get better results by changing any or all of the parameters fps, seekzero and framecount.

tacman1123
20th November 2008, 18:50
Does ffmpegSource need something else installed to work? I think this is an avisynth configuration issue, I have the dll installed in the plugin directory, I believe it's the latest one:


10/06/2007 08:57 PM 188,416 FFMpegSource.dll


But I'm still getting an Avisynth error message with the simple


FFMpegSource("test.mp4")

returns

LoadPlugin: unable to load "c:\as\plugins\FFMegSource.dll"



I'm using the latest beta, 2.5.8rc4.

Thx,

Tac

Gavino
20th November 2008, 19:00
Does ffmpegSource need something else installed to work?
There should be a number of other (non-Avisynth) dll's that come in the same zip file and also have to be installed.