Get exact duration of an mpeg1 file

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

Get exact duration of an mpeg1 file

Robert Krüger-3
Hi,

is there a way to get the exact duration of a raw mpeg1 file using the
ffmpeg command line? For testing I created a 30 minute test file using
ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the duration
using VLC and mediainfo and it is indeed exactly 30 minutes long but ffmpeg
-i shows the file's duration as 00:00:04.98 after displaying this warning:

[mpegvideo @ 0x7fe212806000] Estimating duration from bitrate, this may be
inaccurate

Are there command line parameters to make it compute the exact size or is
this a design or implementation limitation?

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Carl Zwanzig
On 12/13/2018 8:10 AM, Robert Krüger wrote:
> Are there command line parameters to make it compute the exact size or is
> this a design or implementation limitation?

IIRC (and I could be wrong), the generic "info" uses metadata whereas
mediainfo actually counts frames and applies the frame rate to that. Without
a container, there's no appropriate metadata.

It's easy enough to tell, if ffmpeg -i returns almost immediately, it's
probably not counting frames. You also might get a more accurate answer by
using -probesize with a parameter larger than the actual file.

Later,

z!
who's not at the right system to try this now
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Robert Krüger-3
Hi Carl,

On Thu, Dec 13, 2018 at 5:31 PM Carl Zwanzig <[hidden email]> wrote:

> On 12/13/2018 8:10 AM, Robert Krüger wrote:
> > Are there command line parameters to make it compute the exact size or is
> > this a design or implementation limitation?
>
> IIRC (and I could be wrong), the generic "info" uses metadata whereas
> mediainfo actually counts frames and applies the frame rate to that.
> Without
> a container, there's no appropriate metadata.
>

yes, absolutely, that's what I assumed, I just didn't know the option to
force it to do something else.


>
> It's easy enough to tell, if ffmpeg -i returns almost immediately, it's
> probably not counting frames. You also might get a more accurate answer by
> using -probesize with a parameter larger than the actual file.
>
>
that did the trick, thanks! There still a minor inaccuracy of a few frames
but that is probably still https://trac.ffmpeg.org/ticket/3683. My main
concern was estimating vs. actually parsing.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Robert Krüger-3
Hi again,

On Thu, Dec 13, 2018 at 6:01 PM Robert Krüger <[hidden email]>
wrote:

> Hi Carl,
>
> On Thu, Dec 13, 2018 at 5:31 PM Carl Zwanzig <[hidden email]> wrote:
>
>> On 12/13/2018 8:10 AM, Robert Krüger wrote:
>> > Are there command line parameters to make it compute the exact size or
>> is
>> > this a design or implementation limitation?
>>
>> IIRC (and I could be wrong), the generic "info" uses metadata whereas
>> mediainfo actually counts frames and applies the frame rate to that.
>> Without
>> a container, there's no appropriate metadata.
>>
>
> yes, absolutely, that's what I assumed, I just didn't know the option to
> force it to do something else.
>
>
>>
>> It's easy enough to tell, if ffmpeg -i returns almost immediately, it's
>> probably not counting frames. You also might get a more accurate answer
>> by
>> using -probesize with a parameter larger than the actual file.
>>
>>
> that did the trick, thanks! There still a minor inaccuracy of a few frames
> but that is probably still https://trac.ffmpeg.org/ticket/3683. My main
> concern was estimating vs. actually parsing.
>
>
>
Sorry, I have to take that back as I used the wrong file and got something
mixed up when looking at it. -probesize doesn't change the behaviour at
all. I set it to a value larger than the file and still got the warning and
the incorrect number. So for mpeg1 this does not seem to work and seems to
be consistent with my last test a long time ago.

Sorry about the confusion.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Carl Zwanzig
On 12/13/2018 9:07 AM, Robert Krüger wrote:
> Sorry, I have to take that back as I used the wrong file and got something
> mixed up when looking at it. -probesize doesn't change the behaviour at
> all. I set it to a value larger than the file and still got the warning and
> the incorrect number. So for mpeg1 this does not seem to work and seems to
> be consistent with my last test a long time ago.

Happens :).

You could simply "play" the file into null output and catch the frame count
at the end ("ffmpeg -i <file> -f null -"). May have to play with other
options to get readily-parsible text.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Carl Eugen Hoyos-2
In reply to this post by Robert Krüger-3
2018-12-13 17:10 GMT+01:00, Robert Krüger <[hidden email]>:

> is there a way to get the exact duration of a raw mpeg1 file using the
> ffmpeg command line? For testing I created a 30 minute test file using
> ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the duration
> using VLC and mediainfo and it is indeed exactly 30 minutes long but ffmpeg
> -i shows the file's duration as 00:00:04.98 after displaying this warning:
>
> [mpegvideo @ 0x7fe212806000] Estimating duration from bitrate, this may be
> inaccurate
>
> Are there command line parameters to make it compute the exact size or is
> this a design or implementation limitation?

Just the mpeg specification;-)

$ ffmpeg -i input -c copy -f null -

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Robert Krüger-3
On Fri, Dec 14, 2018 at 3:03 AM Carl Eugen Hoyos <[hidden email]> wrote:

> 2018-12-13 17:10 GMT+01:00, Robert Krüger <[hidden email]>:
>
> > is there a way to get the exact duration of a raw mpeg1 file using the
> > ffmpeg command line? For testing I created a 30 minute test file using
> > ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the duration
> > using VLC and mediainfo and it is indeed exactly 30 minutes long but
> ffmpeg
> > -i shows the file's duration as 00:00:04.98 after displaying this
> warning:
> >
> > [mpegvideo @ 0x7fe212806000] Estimating duration from bitrate, this may
> be
> > inaccurate
> >
> > Are there command line parameters to make it compute the exact size or is
> > this a design or implementation limitation?
>
> Just the mpeg specification;-)
>
>
Yes, sure, having to count packets/frames is unavoidable for some formats.
My question is rather whether ffmpeg's (or rather libavformat's) duration
computation code can be made to do this internally without these
workarounds.


> $ ffmpeg -i input -c copy -f null -
>

Thanks for the command line.

Just a comparison: This approach gives me the duration information for a
180 minute file in 1.8 seconds while mediainfo does it in 0.25 seconds
(being exact while ffmpeg is a few frames off, but that's a different
topic), so there must be a faster way to implement it. Tested with a number
of different files with identical results in principle.

What keeps confusing me is that analyzeduration and probesize really seem
to be the parameters that should address the behaviour and give the user a
choice to make the trade-off between accuracy and performance but
specifying these with limits beyond file duration and size does not change
anything in this case. Looking at avformat_find_stream_info this looks like
what it was meant to do but I am by far no ffmpeg code expert, so I might
be misreading it.

Disclaimer: I am neither criticising ffmpeg nor promoting mediainfo :-).
Just interested in getting closer to a solution for the ffmpeg/libavformat
community and trying to understand what the status quo is.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Carl Eugen Hoyos-2
2018-12-14 17:19 GMT+01:00, Robert Krüger <[hidden email]>:

> On Fri, Dec 14, 2018 at 3:03 AM Carl Eugen Hoyos <[hidden email]> wrote:
>
>> 2018-12-13 17:10 GMT+01:00, Robert Krüger <[hidden email]>:
>>
>> > is there a way to get the exact duration of a raw mpeg1 file using the
>> > ffmpeg command line? For testing I created a 30 minute test file using
>> > ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the duration
>> > using VLC and mediainfo and it is indeed exactly 30 minutes long but
>> > ffmpeg -i shows the file's duration as 00:00:04.98 after displaying this
>> > warning:
>> >
>> > [mpegvideo @ 0x7fe212806000] Estimating duration from bitrate, this
>> > may be inaccurate
>> >
>> > Are there command line parameters to make it compute the exact
>> > size or is this a design or implementation limitation?
>>
>> Just the mpeg specification;-)
>>
> Yes, sure, having to count packets/frames is unavoidable for some formats.
> My question is rather whether ffmpeg's (or rather libavformat's) duration
> computation code can be made to do this internally without these
> workarounds.
>
>> $ ffmpeg -i input -c copy -f null -
>
> Thanks for the command line.
>
> Just a comparison: This approach gives me the duration information for a
> 180 minute file in 1.8 seconds while mediainfo does it in 0.25 seconds

(Does your input have timestamp discontinuities? You could try to
concatenate a few parts - or cut away something - from the input file.)

> (being exact while ffmpeg is a few frames off, but that's a different
> topic), so there must be a faster way to implement it.

Patch probably welcome.

> Tested with a number
> of different files with identical results in principle.

> What keeps confusing me is that analyzeduration and probesize really seem
> to be the parameters that should address the behaviour

No, you misunderstand "analyzeduration", it does not analyze the
duration of the input but specifies the duration that should be used
for analysis.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Carl Zwanzig
In reply to this post by Robert Krüger-3
On 12/14/2018 8:19 AM, Robert Krüger wrote:
> Just a comparison: This approach gives me the duration information for a
> 180 minute file in 1.8 seconds while mediainfo does it in 0.25 seconds
> (being exact while ffmpeg is a few frames off, but that's a different
> topic), so there must be a faster way to implement it. Tested with a number
> of different files with identical results in principle.

I'd have to look at the code, and I'm not going to now :), but maybe
mediainfo is looking at time stamps and calculating. As another tool, have
you tried mplayer to see what it comes up with?

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Robert Krüger-3
In reply to this post by Carl Eugen Hoyos-2
On Fri, Dec 14, 2018 at 5:28 PM Carl Eugen Hoyos <[hidden email]> wrote:

> 2018-12-14 17:19 GMT+01:00, Robert Krüger <[hidden email]>:
> > On Fri, Dec 14, 2018 at 3:03 AM Carl Eugen Hoyos <[hidden email]>
> wrote:
> >
> >> 2018-12-13 17:10 GMT+01:00, Robert Krüger <[hidden email]>:
> >>
> >> > is there a way to get the exact duration of a raw mpeg1 file using the
> >> > ffmpeg command line? For testing I created a 30 minute test file using
> >> > ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the
> duration
> >> > using VLC and mediainfo and it is indeed exactly 30 minutes long but
> >> > ffmpeg -i shows the file's duration as 00:00:04.98 after displaying
> this
> >> > warning:
> >> >
> >> > [mpegvideo @ 0x7fe212806000] Estimating duration from bitrate, this
> >> > may be inaccurate
> >> >
> >> > Are there command line parameters to make it compute the exact
> >> > size or is this a design or implementation limitation?
> >>
> >> Just the mpeg specification;-)
> >>
> > Yes, sure, having to count packets/frames is unavoidable for some
> formats.
> > My question is rather whether ffmpeg's (or rather libavformat's) duration
> > computation code can be made to do this internally without these
> > workarounds.
> >
> >> $ ffmpeg -i input -c copy -f null -
> >
> > Thanks for the command line.
> >
> > Just a comparison: This approach gives me the duration information for a
> > 180 minute file in 1.8 seconds while mediainfo does it in 0.25 seconds
>
> (Does your input have timestamp discontinuities? You could try to
> concatenate a few parts - or cut away something - from the input file.)
>

Very unlikely since I generated the sample using an ffmpeg command line
using testsrc.


>
> > (being exact while ffmpeg is a few frames off, but that's a different
> > topic), so there must be a faster way to implement it.
>
> Patch probably welcome.
>

My asking is actually with the motivation to get enough information about
the problem as possible to decide whether to offer sponsoring for a patch
implementing the behaviour I describe, so it's good to know a patch would
be welcome.


>
> > Tested with a number
> > of different files with identical results in principle.
>
> > What keeps confusing me is that analyzeduration and probesize really seem
> > to be the parameters that should address the behaviour
>
> No, you misunderstand "analyzeduration", it does not analyze the
> duration of the input but specifies the duration that should be used
> for analysis.
>

That's how I understood it, so in my tests I set it to a value beyond the
duration of the file so that, if needed, the entire file is parsed for
calculating its duration (as well as setting probesize to a value larger
than the file size) but that did not happen.

Robert


>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Robert Krüger-3
In reply to this post by Carl Zwanzig
On Fri, Dec 14, 2018 at 5:31 PM Carl Zwanzig <[hidden email]> wrote:

> On 12/14/2018 8:19 AM, Robert Krüger wrote:
> > Just a comparison: This approach gives me the duration information for a
> > 180 minute file in 1.8 seconds while mediainfo does it in 0.25 seconds
> > (being exact while ffmpeg is a few frames off, but that's a different
> > topic), so there must be a faster way to implement it. Tested with a
> number
> > of different files with identical results in principle.
>
> I'd have to look at the code, and I'm not going to now :), but maybe
> mediainfo is looking at time stamps and calculating. As another tool, have
> you tried mplayer to see what it comes up with?
>
> know because I'm actually more interested in getting this to work using
libavformat and I am just testing the possibilities using the command line.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Carl Eugen Hoyos-2
In reply to this post by Robert Krüger-3
2018-12-18 21:49 GMT+01:00, Robert Krüger <[hidden email]>:

> On Fri, Dec 14, 2018 at 5:28 PM Carl Eugen Hoyos <[hidden email]> wrote:
>
>> 2018-12-14 17:19 GMT+01:00, Robert Krüger <[hidden email]>:
>> > On Fri, Dec 14, 2018 at 3:03 AM Carl Eugen Hoyos <[hidden email]>
>> wrote:
>> >
>> >> 2018-12-13 17:10 GMT+01:00, Robert Krüger <[hidden email]>:
>> >>
>> >> > is there a way to get the exact duration of a raw mpeg1 file using
>> >> > the
>> >> > ffmpeg command line? For testing I created a 30 minute test file
>> >> > using
>> >> > ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the
>> duration
>> >> > using VLC and mediainfo and it is indeed exactly 30 minutes long but
>> >> > ffmpeg -i shows the file's duration as 00:00:04.98 after displaying
>> this
>> >> > warning:
>> >> >
>> >> > [mpegvideo @ 0x7fe212806000] Estimating duration from bitrate, this
>> >> > may be inaccurate
>> >> >
>> >> > Are there command line parameters to make it compute the exact
>> >> > size or is this a design or implementation limitation?
>> >>
>> >> Just the mpeg specification;-)
>> >>
>> > Yes, sure, having to count packets/frames is unavoidable for some
>> formats.
>> > My question is rather whether ffmpeg's (or rather libavformat's)
>> > duration
>> > computation code can be made to do this internally without these
>> > workarounds.
>> >
>> >> $ ffmpeg -i input -c copy -f null -
>> >
>> > Thanks for the command line.
>> >
>> > Just a comparison: This approach gives me the duration information for a
>> > 180 minute file in 1.8 seconds while mediainfo does it in 0.25 seconds
>>
>> (Does your input have timestamp discontinuities? You could try to
>> concatenate a few parts - or cut away something - from the input file.)
>>
>
> Very unlikely since I generated the sample using an ffmpeg command line
> using testsrc.

But you should test with a file with timestamp discontinuities to
test your claim that it can be done faster than with FFmpeg.

>> > (being exact while ffmpeg is a few frames off, but that's a different
>> > topic), so there must be a faster way to implement it.
>>
>> Patch probably welcome.
>>
>
> My asking is actually with the motivation to get enough information about
> the problem as possible to decide whether to offer sponsoring for a patch
> implementing the behaviour I describe, so it's good to know a patch would
> be welcome.
>
>
>>
>> > Tested with a number
>> > of different files with identical results in principle.
>>
>> > What keeps confusing me is that analyzeduration and probesize really
>> > seem
>> > to be the parameters that should address the behaviour
>>
>> No, you misunderstand "analyzeduration", it does not analyze the
>> duration of the input but specifies the duration that should be used
>> for analysis.
>>
>
> That's how I understood it, so in my tests I set it to a value beyond the
> duration of the file so that, if needed, the entire file is parsed for
> calculating its duration (as well as setting probesize to a value larger
> than the file size) but that did not happen.

Sorry for being unclear: The "analysis" does not contain file duration.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Robert Krüger-3
On Tue, Dec 18, 2018 at 11:40 PM Carl Eugen Hoyos <[hidden email]>
wrote:

> 2018-12-18 21:49 GMT+01:00, Robert Krüger <[hidden email]>:
> > On Fri, Dec 14, 2018 at 5:28 PM Carl Eugen Hoyos <[hidden email]>
> wrote:
> >
> >> 2018-12-14 17:19 GMT+01:00, Robert Krüger <[hidden email]>:
> >> > On Fri, Dec 14, 2018 at 3:03 AM Carl Eugen Hoyos <[hidden email]>
> >> wrote:
> >> >
> >> >> 2018-12-13 17:10 GMT+01:00, Robert Krüger <[hidden email]
> >:
> >> >>
> >> >> > is there a way to get the exact duration of a raw mpeg1 file using
> >> >> > the
> >> >> > ffmpeg command line? For testing I created a 30 minute test file
> >> >> > using
> >> >> > ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the
> >> duration
> >> >> > using VLC and mediainfo and it is indeed exactly 30 minutes long
> but
> >> >> > ffmpeg -i shows the file's duration as 00:00:04.98 after displaying
> >> this
> >> >> > warning:
> >> >> >
> >> >> > [mpegvideo @ 0x7fe212806000] Estimating duration from bitrate, this
> >> >> > may be inaccurate
> >> >> >
> >> >> > Are there command line parameters to make it compute the exact
> >> >> > size or is this a design or implementation limitation?
> >> >>
> >> >> Just the mpeg specification;-)
> >> >>
> >> > Yes, sure, having to count packets/frames is unavoidable for some
> >> formats.
> >> > My question is rather whether ffmpeg's (or rather libavformat's)
> >> > duration
> >> > computation code can be made to do this internally without these
> >> > workarounds.
> >> >
> >> >> $ ffmpeg -i input -c copy -f null -
> >> >
> >> > Thanks for the command line.
> >> >
> >> > Just a comparison: This approach gives me the duration information
> for a
> >> > 180 minute file in 1.8 seconds while mediainfo does it in 0.25 seconds
> >>
> >> (Does your input have timestamp discontinuities? You could try to
> >> concatenate a few parts - or cut away something - from the input file.)
> >>
> >
> > Very unlikely since I generated the sample using an ffmpeg command line
> > using testsrc.
>
> But you should test with a file with timestamp discontinuities to
> test your claim that it can be done faster than with FFmpeg.
>

I begin to understand. You are saying that it is possible that Mediainfo is
more or less "cheating" to obtain its results. Interesting. For my use
cases I could probably live with the risk that the method is inexact in the
case of timestamp discontinuities.


>
> >> > (being exact while ffmpeg is a few frames off, but that's a different
> >> > topic), so there must be a faster way to implement it.
> >>
> >> Patch probably welcome.
> >>
> >
> > My asking is actually with the motivation to get enough information about
> > the problem as possible to decide whether to offer sponsoring for a patch
> > implementing the behaviour I describe, so it's good to know a patch would
> > be welcome.
> >
> >
> >>
> >> > Tested with a number
> >> > of different files with identical results in principle.
> >>
> >> > What keeps confusing me is that analyzeduration and probesize really
> >> > seem
> >> > to be the parameters that should address the behaviour
> >>
> >> No, you misunderstand "analyzeduration", it does not analyze the
> >> duration of the input but specifies the duration that should be used
> >> for analysis.
> >>
> >
> > That's how I understood it, so in my tests I set it to a value beyond the
> > duration of the file so that, if needed, the entire file is parsed for
> > calculating its duration (as well as setting probesize to a value larger
> > than the file size) but that did not happen.
>
> Sorry for being unclear: The "analysis" does not contain file duration.
>

Thanks, I did not know that. That is a good explanation for what I observe.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Get exact duration of an mpeg1 file

Carl Eugen Hoyos-2
2018-12-20 14:22 GMT+01:00, Robert Krüger <[hidden email]>:

> On Tue, Dec 18, 2018 at 11:40 PM Carl Eugen Hoyos <[hidden email]>
> wrote:
>
>> 2018-12-18 21:49 GMT+01:00, Robert Krüger <[hidden email]>:
>> > On Fri, Dec 14, 2018 at 5:28 PM Carl Eugen Hoyos <[hidden email]>
>> wrote:
>> >
>> >> 2018-12-14 17:19 GMT+01:00, Robert Krüger <[hidden email]>:
>> >> > On Fri, Dec 14, 2018 at 3:03 AM Carl Eugen Hoyos <[hidden email]>
>> >> wrote:
>> >> >
>> >> >> 2018-12-13 17:10 GMT+01:00, Robert Krüger <[hidden email]
>> >:
>> >> >>
>> >> >> > is there a way to get the exact duration of a raw mpeg1 file using
>> >> >> > the
>> >> >> > ffmpeg command line? For testing I created a 30 minute test file
>> >> >> > using
>> >> >> > ffmpeg (using -c:v mpeg1video -f mpeg1video), then verified the
>> >> duration
>> >> >> > using VLC and mediainfo and it is indeed exactly 30 minutes long
>> but
>> >> >> > ffmpeg -i shows the file's duration as 00:00:04.98 after
>> >> >> > displaying
>> >> this
>> >> >> > warning:
>> >> >> >
>> >> >> > [mpegvideo @ 0x7fe212806000] Estimating duration from bitrate,
>> >> >> > this
>> >> >> > may be inaccurate
>> >> >> >
>> >> >> > Are there command line parameters to make it compute the exact
>> >> >> > size or is this a design or implementation limitation?
>> >> >>
>> >> >> Just the mpeg specification;-)
>> >> >>
>> >> > Yes, sure, having to count packets/frames is unavoidable for some
>> >> formats.
>> >> > My question is rather whether ffmpeg's (or rather libavformat's)
>> >> > duration
>> >> > computation code can be made to do this internally without these
>> >> > workarounds.
>> >> >
>> >> >> $ ffmpeg -i input -c copy -f null -
>> >> >
>> >> > Thanks for the command line.
>> >> >
>> >> > Just a comparison: This approach gives me the duration information
>> for a
>> >> > 180 minute file in 1.8 seconds while mediainfo does it in 0.25
>> >> > seconds
>> >>
>> >> (Does your input have timestamp discontinuities? You could try to
>> >> concatenate a few parts - or cut away something - from the input file.)
>> >>
>> >
>> > Very unlikely since I generated the sample using an ffmpeg command line
>> > using testsrc.
>>
>> But you should test with a file with timestamp discontinuities to
>> test your claim that it can be done faster than with FFmpeg.
>
> I begin to understand. You are saying that it is possible that Mediainfo is
> more or less "cheating" to obtain its results.

I meant that it is possible to calculate a duration in an mpeg stream
by looking at the first and the last timestamp, MPlayer does it iirc.

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

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".