Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

classic Classic list List threaded Threaded
49 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
If I convert a rawvideo, or ffvhuff-compressed AVI file to images
with both ffmpeg and mencoder, the images are not the same.   For
example, image 1000 from the mencoder output might correspond
to image 998 from ffmpeg.  As the image number gets higher and
higher, they diverge further.  The results are not consistent from one
video file to to the next.


This is causing my problems with incorrect cut edits:
The ffmpeg select filter is counting frames differently then the
ffmpeg image demuxer, or whatever you call the component that
ffmpeg uses to convert video into image files.


Why is this happening?  Is it possible that ffmpeg doesn't handle dropped
frames correctly?  Is there any easy way to fix this?  I spent several
hours editing video based on what now seems like incorrect frame
numbers.  Is there a way I can get ffmpeg to tell me when it dropped
a frame so that the output agrees with mencoder, which is correct?

Please tell me I didn't waste 4 hours because of an ffmpeg bug.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Paul B Mahol
On 9/2/13, James Board <[hidden email]> wrote:

> If I convert a rawvideo, or ffvhuff-compressed AVI file to images
> with both ffmpeg and mencoder, the images are not the same.   For
> example, image 1000 from the mencoder output might correspond
> to image 998 from ffmpeg.  As the image number gets higher and
> higher, they diverge further.  The results are not consistent from one
> video file to to the next.
>
>
> This is causing my problems with incorrect cut edits:
> The ffmpeg select filter is counting frames differently then the
> ffmpeg image demuxer, or whatever you call the component that
> ffmpeg uses to convert video into image files.
>
>
> Why is this happening?  Is it possible that ffmpeg doesn't handle dropped
> frames correctly?  Is there any easy way to fix this?  I spent several
> hours editing video based on what now seems like incorrect frame
> numbers.  Is there a way I can get ffmpeg to tell me when it dropped
> a frame so that the output agrees with mencoder, which is correct?
>
> Please tell me I didn't waste 4 hours because of an ffmpeg bug.

You never mentioned what you are actually doing.

For image demuxer you need to set input frame rate or default one
will be used, which may not be what you want.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
>> Please tell me I didn't waste 4 hours because of an ffmpeg bug.

>
>You never mentioned what you are actually doing.

I'm converting a video file to a sequence of image files.  I used both ffmpeg and
mencoder (actually, mplayer) (I mentioned this is the first line).  Here is an example:

    ffmpeg -i IN.avi -q:v 4 -f image2 %08d.jpg

>For image demuxer you need to set input frame rate or default one
>will be used, which may not be what you want.

The image2 muxer documentation doesn't mention this.  How do I
specify an input frame rate (24000/1001) for the above command?

Also, I have a huge edit list which took 4 hours to generate.  Is there
some formula I can use which will convert the frame numbers that ffmpeg
used as output for the jpeg images to the  equivalent frame numbers that ffmpeg
will use as input to the select filter?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Paul B Mahol
On 9/2/13, James Board <[hidden email]> wrote:

>>> Please tell me I didn't waste 4 hours because of an ffmpeg bug.
>
>>
>>You never mentioned what you are actually doing.
>
> I'm converting a video file to a sequence of image files.  I used both
> ffmpeg and
> mencoder (actually, mplayer) (I mentioned this is the first line).  Here is
> an example:
>
>     ffmpeg -i IN.avi -q:v 4 -f image2 %08d.jpg
>
>>For image demuxer you need to set input frame rate or default one
>>will be used, which may not be what you want.
>
> The image2 muxer documentation doesn't mention this.  How do I
> specify an input frame rate (24000/1001) for the above command?

You need it for whatever reads images not for creating them....

So it is needed for DEmuxer, not for muxer (unless you want to
dupe/remove random frames).

>
> Also, I have a huge edit list which took 4 hours to generate.  Is there
> some formula I can use which will convert the frame numbers that ffmpeg
> used as output for the jpeg images to the  equivalent frame numbers that
> ffmpeg
> will use as input to the select filter?

Use same frame rate for input as for output, its simple enough.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
>> The image2 muxer documentation doesn't mention this.  How do I
>> specify an input frame rate (24000/1001) for the above command?

>
>You need it for whatever reads images not for creating them....

No.  The program which reads the images doesn't care what the frame rate is.

I am not using ffmpeg to read the images.  When I use the select filter, I use it on the same AVI video file that I used to
create the images.

>> Also, I have a huge edit list which took 4 hours to generate.  Is there
>> some formula I can use which will convert the frame numbers that ffmpeg
>> used as output for the jpeg images to the  equivalent frame numbers that
>> ffmpeg
>> will use as input to the select filter?
>
>Use same frame rate for input as for output, its simple enough.

What?  But that won't solve the problem.  Here is the problem again.
I used ffmpeg to generate image files from an AVI video.  The frame
numbers on those image files are incorrect.  Unfortunately, I used those
image files to generate edit lists and those edit lists won't work because
of the ffmpeg bug in generating the image files.

The problem is that ffmpeg uses one formula for numbering frames when
it outputs images and it uses another formula for numbering frames when it
uses the select filter.  I just want to know what the formulas are so I can
convert the frame numbers that ffmpeg used when creating the image files
to the frame numbers that ffmpeg will later use with the select filter.  Then
I can compensate for the ffmpeg bug, and my edits will be frame exact.

Thanks.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Paul B Mahol
On 9/2/13, James Board <[hidden email]> wrote:

>>> The image2 muxer documentation doesn't mention this.  How do I
>>> specify an input frame rate (24000/1001) for the above command?
>
>>
>>You need it for whatever reads images not for creating them....
>
> No.  The program which reads the images doesn't care what the frame rate
> is.
>
> I am not using ffmpeg to read the images.  When I use the select filter, I
> use it on the same AVI video file that I used to
> create the images.
>
>>> Also, I have a huge edit list which took 4 hours to generate.  Is there
>>> some formula I can use which will convert the frame numbers that ffmpeg
>>> used as output for the jpeg images to the  equivalent frame numbers that
>>> ffmpeg
>>> will use as input to the select filter?
>>
>>Use same frame rate for input as for output, its simple enough.
>
> What?  But that won't solve the problem.  Here is the problem again.
> I used ffmpeg to generate image files from an AVI video.  The frame
> numbers on those image files are incorrect.  Unfortunately, I used those
> image files to generate edit lists and those edit lists won't work because
> of the ffmpeg bug in generating the image files.
>
> The problem is that ffmpeg uses one formula for numbering frames when
> it outputs images and it uses another formula for numbering frames when it
> uses the select filter.  I just want to know what the formulas are so I can
> convert the frame numbers that ffmpeg used when creating the image files
> to the frame numbers that ffmpeg will later use with the select filter.
> Then
> I can compensate for the ffmpeg bug, and my edits will be frame exact.

Sorry, but how can I reproduce that bug?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
>Sorry, but how can I reproduce that bug?


I run ffmpeg on a file to produce jpeg (or pnm or whatever) images as output.
At seemingly random locations in the sequence, some image files
are duplicated. This causes the frame numbers of those files
to be incorrect.  Why?  Because those are extra frames not present in
the original source video.  For example, let's say my input video
had frames like this
    A B C D E
When I use ffmpeg to extract jpeg images from the video, I might get
    A B C D D E
See the difference?  In one sequence, there is a single 'D'.  In the other
there are two 'D's.  That means there will be one extra image file in the
output.  Also, all file names, which hold the frame number, after 'D' will
then be incorrect.  And if you're video editor is based on ffmpeg to
do this, it will be incorrect.

This is a bug with ffmpeg.  If I run the same test with mencoder (actually mplayer),
then I don't see the bug.  For example, if the input video had frames like this
    A B C D E
When I use mencoder to extract jpeg images from the video, I get
    A B C D E
mencoder produces the correct files.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Paul B Mahol
On 9/2/13, James Board <[hidden email]> wrote:

>>Sorry, but how can I reproduce that bug?
>
>
> I run ffmpeg on a file to produce jpeg (or pnm or whatever) images as
> output.
> At seemingly random locations in the sequence, some image files
> are duplicated. This causes the frame numbers of those files
> to be incorrect.  Why?  Because those are extra frames not present in
> the original source video.  For example, let's say my input video
> had frames like this
>     A B C D E
> When I use ffmpeg to extract jpeg images from the video, I might get
>     A B C D D E
> See the difference?  In one sequence, there is a single 'D'.  In the other
> there are two 'D's.  That means there will be one extra image file in the
> output.  Also, all file names, which hold the frame number, after 'D' will
> then be incorrect.  And if you're video editor is based on ffmpeg to
> do this, it will be incorrect.
>
> This is a bug with ffmpeg.  If I run the same test with mencoder (actually
> mplayer),

Why you think this is bug?
By default ffmpeg creates cfr output.
So probably your input is vfr and that is why some frames are duplicated.

> then I don't see the bug.  For example, if the input video had frames like
> this
>     A B C D E
> When I use mencoder to extract jpeg images from the video, I get
>     A B C D E
> mencoder produces the correct files.
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
>Why you think this is bug?

>By default ffmpeg creates cfr output.
>So probably your input is vfr and that is why some frames are duplicated.

So then what is it?  A feature?  You've got to be joking.
This is the simplest possible video processing task: convert
an uncomressed raw video file to the correct sequence of images.

Don't complain when I still use mencoder for my video
tasks.  If ffmpeg can't get the simplest of all possible video tasks
right, that makes you wonder how many more things
are incorrect, but people just don't notice.

Are you really tryng to help?  CFR?  VFR?  The source is uncompressed
raw video!  The output is (should be) a sequence of images, one for each
frame in the input video.  Where does CFR or VFR even come into play?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Paul B Mahol
On 9/2/13, James Board <[hidden email]> wrote:

>>Why you think this is bug?
>
>>By default ffmpeg creates cfr output.
>>So probably your input is vfr and that is why some frames are duplicated.
>
> So then what is it?  A feature?  You've got to be joking.
> This is the simplest possible video processing task: convert
> an uncomressed raw video file to the correct sequence of images.
>
> Don't complain when I still use mencoder for my video
> tasks.  If ffmpeg can't get the simplest of all possible video tasks
> right, that makes you wonder how many more things
> are incorrect, but people just don't notice.
>
> Are you really tryng to help?  CFR?  VFR?  The source is uncompressed
> raw video!  The output is (should be) a sequence of images, one for each
> frame in the input video.  Where does CFR or VFR even come into play?

Because you never posted actual commands I'm left to guessing.

Try adding "-vsync 0".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Nicolas George-2
In reply to this post by James Board
Le sextidi 16 fructidor, an CCXXI, James Board a écrit :

> So then what is it?  A feature?  You've got to be joking.
> This is the simplest possible video processing task: convert
> an uncomressed raw video file to the correct sequence of images.
>
> Don't complain when I still use mencoder for my video
> tasks.  If ffmpeg can't get the simplest of all possible video tasks
> right, that makes you wonder how many more things
> are incorrect, but people just don't notice.
>
> Are you really tryng to help?  CFR?  VFR?  The source is uncompressed
> raw video!  The output is (should be) a sequence of images, one for each
> frame in the input video.  Where does CFR or VFR even come into play?
Please stop being rude. Your input is not "uncompressed raw video", it is an
AVI file, you did not tell how it was generated and AVI is one of the worst
formats there is. Expect all sorts of problems.

In the future, maybe you will remember you should never work with frame
numbers but always with timestamps.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
In reply to this post by Paul B Mahol
>Because you never posted actual commands I'm left to guessing.

>
No. this isn't true.  I posted the actual command.  Again, here is the command:
   
    ffmpeg -i IN.avi -q:v 4 -f image2 %08d.jpg
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Paul B Mahol
On 9/3/13, James Board <[hidden email]> wrote:
>>Because you never posted actual commands I'm left to guessing.
>
>>
> No. this isn't true.  I posted the actual command.  Again, here is the
> command:
>
>     ffmpeg -i IN.avi -q:v 4 -f image2 %08d.jpg

commandS
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
In reply to this post by Nicolas George-2
>Please stop being rude. Your input is not "uncompressed raw video", it is an

>AVI file, you did not tell how it was generated and AVI is one of the worst
>formats there is. Expect all sorts of problems.

Sorry, if I'm being rude.  I'm reporting an obvious ffmpeg bug, which
wasted 4 hours of my time, and the response is that this is a feature.  What
would your tone be?

How many times on this mailing list have I received complaints about my
top-posting?  Or complaints about my mixing threads?  Or complaints about
my using line length that was too long for some people's screen?  Or because
I mentioned that I use mencoder?  Or whatever trivial issue?  On and on....
Conversely.  My comments have been about your product, and the bugs I've
found, that nobody seems inclined to correct, or even accept as bugs.

Also, the AVI file stores it's frames in an uncompressed YUV format.  There is
no interframe compression, or intra-frame compression.  I call this "uncompressed raw video".
What is the correct term for this?  It was generated from my capture card.

Thank you.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Nicolas George-2
Le septidi 17 fructidor, an CCXXI, James Board a écrit :
> It was generated from my capture card.

As long as you refuse to show exactly how you generated the corresponding
AVI file, there is nothing anyone can do for you except guessing irritatedly
that it has variable frame rate and there is no bug.

Regards,

--
  Nicolas George

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Robert Krüger-2
In reply to this post by James Board
On Tue, Sep 3, 2013 at 3:33 PM, James Board <[hidden email]> wrote:
>>Please stop being rude. Your input is not "uncompressed raw video", it is an
>
>>AVI file, you did not tell how it was generated and AVI is one of the worst
>>formats there is. Expect all sorts of problems.
>
> Sorry, if I'm being rude.  I'm reporting an obvious ffmpeg bug, which
> wasted 4 hours of my time, and the response is that this is a feature.  What
> would your tone be?

What you could do:

- Post full command line _and_ output of the ffmpeg command that
converts the AVI file to the image sequence (if your assumption is
correct, the output will probably show if ffmpeg knowingly duplicates
frames)
- Ensure the timestamps correspond to the assumed framerate by using
the setpts filter and see if that makes things better
- Check/post output of ffprobe for the frame timestamps to see if they
are well-behaved
- Not complain about the time you lost using ffmpeg (here) because it
is nobody's fault
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
In reply to this post by Paul B Mahol
>> No. this isn't true.  I posted the actual command.  Again, here is the

>> command:
>>
>>     ffmpeg -i IN.avi -q:v 4 -f image2 %08d.jpg
>
>commandS

What other command would you like?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
In reply to this post by Nicolas George-2
>> It was generated from my capture card.

>
>As long as you refuse to show exactly how you generated the corresponding
>AVI file, there is nothing anyone can do for you except guessing irritatedly
>that it has variable frame rate and there is no bug.

I'm not trying to be difficult here.  But I don't understand half the requests
that are made of me.  I really did generate the AVI file from my capture card. 
What else should I say?  It uses an app called MediaExpress.  Is that what you wanted?
This generates AVI files which have no inter-frame compression (no mpeg-like codecs)
and no intra-frame compression (it's YUV422).
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

Paul B Mahol
In reply to this post by James Board
On 9/3/13, James Board <[hidden email]> wrote:
>>> No. this isn't true.  I posted the actual command.  Again, here is the
>
>>> command:
>>>
>>>     ffmpeg -i IN.avi -q:v 4 -f image2 %08d.jpg
>>
>>commandS
>
> What other command would you like?

Did you tried -vsync 0 with above command?

Doess ffmpeg 'eats' or 'dupes' certain frames?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Image extraction broken with ffmpeg, but not with mencoder. How can I fix this?

James Board
In reply to this post by Nicolas George-2
>In the future, maybe you will remember you should never work with frame

>numbers but always with timestamps.

1: I'm using ffmpeg to separate a video file into a sequence of frames.  In
doing so, ffmpeg generates extra frames.  This is the problem.  Whether or
not I used frame numbers, or timestamps, this would still be the case.

2: Ultimately I must use frame numbers because I need to know which
frames (which are stored as distinct files) to include and which not to include. 

3: Timestamps are floating-point numbers, and floating-point numbers are not exact.
Frame numbers are integers and integers are exact. I asked previously for a
formula to map timestamps to frame numbers and didn't get an answer.  Here's
the issue: If I try to use a time stamp that falls midway between two frames, which frame will ffmpeg
select?  What if I try to use a timestamp that is .000001 less than the timestamp of
the frame I want?  Will ffmpeg round to the nearest frame, or round down to the previous
frame, or round up to the next frame, or does ffmpeg even do anything consistent?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
123