Why was patch declined: Modified force_key_frames option to accept frame numbers?

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

Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick
Hi,
why was the "Modified force_key_frames option to accept frame numbers"
(2014) declined?

> https://ffmpeg.org/pipermail/ffmpeg-devel/2014-November/165167.html
You can even specify frame numbers in the current ffmpeg version using:
> -force_key_frames expr:gte(n,n_forced*96)
Using a framerate of 24 means a keyframe every 4s.
I think it is very useful to have something like

> /force_key_frames n:0,25,50,75,100/
Someone said that the frame numbers are not aligned for different video
qualities. Why?
If I have a constant framerate and I insert a keyframe at x-frame it
should be at the same time for all video qualities?

_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Gyan


On 16-02-2019 05:03 AM, Nick wrote:

> Hi,
> why was the "Modified force_key_frames option to accept frame numbers"
> (2014) declined?
>
>> https://ffmpeg.org/pipermail/ffmpeg-devel/2014-November/165167.html
> You can even specify frame numbers in the current ffmpeg version using:
>> -force_key_frames expr:gte(n,n_forced*96)
> Using a framerate of 24 means a keyframe every 4s.
> I think it is very useful to have something like
>
>> /force_key_frames n:0,25,50,75,100/

For a regular pattern like that one, you can already use

     -force_key_frames expr:not(mod(n,25))

Expressions are be evaluated using the interface documented at
https://ffmpeg.org/ffmpeg-utils.html#Expression-Evaluation


Gyan
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick
Thanks for the answer.
But I want to do the same thing like the person from the mailing list.
I want that ffmpeg cuts the video in specific segments for DASH with
variable durations.
I want to extract this information and use it to cut the video again
using different qualities.
I could use the -map command for directly encoding different qualities
but I want to outsource the workload.
I want to be sure that everything is aligned.

The one person from the mailing list said:

> In this particular case, you can easily work around the floating point
> rounding issues, since the rounding behaviour of -force_key_frames is
> specified: "more precisely at the first frames after each specified time".
> You just have to make sure your timestamps are rounded down. For example,
> with 24000/1001 FPS: 4.21 4.25 4.30* 4.34 4.38, you need to write 4.29, not
> 4.30, but you can also write any value between 4.25425 and the actual
> 4.295958333. (4.25+4.30)/2 = 4.275 should always work.
This looks a bit like a workaround to me. Frame numbers look more
precise for me.
I do not understand why frame numbers should not be aligned except the
frame rate is changing.

On 2/16/19 8:52 AM, Gyan wrote:

>
>
> On 16-02-2019 05:03 AM, Nick wrote:
>> Hi,
>> why was the "Modified force_key_frames option to accept frame numbers"
>> (2014) declined?
>>
>>> https://ffmpeg.org/pipermail/ffmpeg-devel/2014-November/165167.html
>> You can even specify frame numbers in the current ffmpeg version using:
>>> -force_key_frames expr:gte(n,n_forced*96)
>> Using a framerate of 24 means a keyframe every 4s.
>> I think it is very useful to have something like
>>
>>> /force_key_frames n:0,25,50,75,100/
>
> For a regular pattern like that one, you can already use
>
>     -force_key_frames expr:not(mod(n,25))
>
> Expressions are be evaluated using the interface documented at
> https://ffmpeg.org/ffmpeg-utils.html#Expression-Evaluation
>
>
> Gyan
> _______________________________________________
> 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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick
Changing the resolution breaks the force_key_frame segmentation with
timestamps. :/
Is there some way to do it?

On 2/16/19 11:22 AM, Nick wrote:

> Thanks for the answer.
> But I want to do the same thing like the person from the mailing list.
> I want that ffmpeg cuts the video in specific segments for DASH with
> variable durations.
> I want to extract this information and use it to cut the video again
> using different qualities.
> I could use the -map command for directly encoding different qualities
> but I want to outsource the workload.
> I want to be sure that everything is aligned.
>
> The one person from the mailing list said:
>
>> In this particular case, you can easily work around the floating point
>> rounding issues, since the rounding behaviour of -force_key_frames is
>> specified: "more precisely at the first frames after each specified time".
>> You just have to make sure your timestamps are rounded down. For example,
>> with 24000/1001 FPS: 4.21 4.25 4.30* 4.34 4.38, you need to write 4.29, not
>> 4.30, but you can also write any value between 4.25425 and the actual
>> 4.295958333. (4.25+4.30)/2 = 4.275 should always work.
> This looks a bit like a workaround to me. Frame numbers look more
> precise for me.
> I do not understand why frame numbers should not be aligned except the
> frame rate is changing.
>
> On 2/16/19 8:52 AM, Gyan wrote:
>>
>> On 16-02-2019 05:03 AM, Nick wrote:
>>> Hi,
>>> why was the "Modified force_key_frames option to accept frame numbers"
>>> (2014) declined?
>>>
>>>> https://ffmpeg.org/pipermail/ffmpeg-devel/2014-November/165167.html
>>> You can even specify frame numbers in the current ffmpeg version using:
>>>> -force_key_frames expr:gte(n,n_forced*96)
>>> Using a framerate of 24 means a keyframe every 4s.
>>> I think it is very useful to have something like
>>>
>>>> /force_key_frames n:0,25,50,75,100/
>> For a regular pattern like that one, you can already use
>>
>>     -force_key_frames expr:not(mod(n,25))
>>
>> Expressions are be evaluated using the interface documented at
>> https://ffmpeg.org/ffmpeg-utils.html#Expression-Evaluation
>>
>>
>> Gyan
>> _______________________________________________
>> 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".
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

kumowoon1025
> Changing the resolution breaks the force_key_frame segmentation with
> timestamps. :/
How does it break?

> I do not understand why frame numbers should not be aligned except the
> frame rate is changing.
I think one of the lines of discussion was that frame rate isn’t always constant for all formats. But I don’t think the patch was rejected, just never resubmitted.
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick

On 2/17/19 12:19 AM, Ted Park wrote:
>> Changing the resolution breaks the force_key_frame segmentation with
>> timestamps. :/
> How does it break?

I think scene cut detection is different using different resolutions.
If I turn off the detection I can align the segmentation using key_frames.

>> I do not understand why frame numbers should not be aligned except the
>> frame rate is changing.
> I think one of the lines of discussion was that frame rate isn’t always constant for all formats. But I don’t think the patch was rejected, just never resubmitted.
K. If I have time I will resubmit this patch. :)
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

kumowoon1025
> I think scene cut detection is different using different resolutions.
> If I turn off the detection I can align the segmentation using key_frames.

Using the same segment_times and force_key_frames has different results depending on whether scene cut detection is enabled? I can’t get my head around the math right now, but segment_time_delta of twice the framerate might fix if its due to rounding error and is splitting before and after the timestamp.
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick
>> I think scene cut detection is different using different resolutions.
>> If I turn off the detection I can align the segmentation using key_frames.
I calculated the I-Frame positions from a already segmented video with a
different resolution.
When I disabled scenedetection and placed them manually while encoding
using force_key_frame it worked!
BUT, I miss 8 I-Frames because they are not packed into seperate chunks.
If I now insert all I-Frames (obtained from the video with different
resolution), the alignment is displaced again. :(
Is there a way to select the I-Frame where the video gets split into chunks?
Is there a limit for the minimum filesize for a chunk?
Can I split on each I-frame?
So obtain +8 video chunks?

Thanks for your help. :)

_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick

>>> I think scene cut detection is different using different resolutions.
>>> If I turn off the detection I can align the segmentation using key_frames.
> I calculated the I-Frame positions from a already segmented video with a
> different resolution.
> When I disabled scenedetection and placed them manually while encoding
> using force_key_frame it worked!
> BUT, I miss 8 I-Frames because they are not packed into seperate chunks.
> If I now insert all I-Frames (obtained from the video with different
> resolution), the alignment is displaced again. :(
> Is there a way to select the I-Frame where the video gets split into chunks?
> Is there a limit for the minimum filesize for a chunk?
> Can I split on each I-frame?
> So obtain +8 video chunks?
>
> Thanks for your help. :)

If I manually place the I-frames in the video with the "different
resolution" I get the different alignment too...
So both are aligned again. :)


_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick

On 2/17/19 2:37 AM, Nick wrote:

>>>> I think scene cut detection is different using different resolutions.
>>>> If I turn off the detection I can align the segmentation using key_frames.
>> I calculated the I-Frame positions from a already segmented video with a
>> different resolution.
>> When I disabled scenedetection and placed them manually while encoding
>> using force_key_frame it worked!
>> BUT, I miss 8 I-Frames because they are not packed into seperate chunks.
>> If I now insert all I-Frames (obtained from the video with different
>> resolution), the alignment is displaced again. :(
>> Is there a way to select the I-Frame where the video gets split into chunks?
>> Is there a limit for the minimum filesize for a chunk?
>> Can I split on each I-frame?
>> So obtain +8 video chunks?
>>
>> Thanks for your help. :)
> If I manually place the I-frames in the video with the "different
> resolution" I get the different alignment too...
> So both are aligned again. :)
>
And if I extract the I-Frames again, I get the same positions as in the
original video.
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

kumowoon1025
In reply to this post by Nick
> I calculated the I-Frame positions from a already segmented video with a
> different resolution.
> When I disabled scenedetection and placed them manually while encoding
> using force_key_frame it worked!
> BUT, I miss 8 I-Frames because they are not packed into seperate chunks.
Okay, but I frames might not be keyframes. And scenecut might place I frames that are not idr frames. Maybe that’s the reason for the differences.

> BUT, I miss 8 I-Frames because they are not packed into seperate chunks.
> If I now insert all I-Frames (obtained from the video with different
> resolution), the alignment is displaced again. :(

When you say you insert I-frames, you mean you are forcing keyframes right? Are you also telling the segmenter to split at those timestamps?

> Is there a way to select the I-Frame where the video gets split into chunks?
Depends on the muxer you are using.

> Is there a limit for the minimum filesize for a chunk?
Probably, depends on the format.

> Can I split on each I-frame?
You can split anywhere, but the results might not be very useful depending on what you plan to do with it.
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

Nick

>> If I now insert all I-Frames (obtained from the video with different
>> resolution), the alignment is displaced again. :(
> When you say you insert I-frames, you mean you are forcing keyframes right? Are you also telling the segmenter to split at those timestamps?
>
Yep.
Is there a way to tell ffmpeg to split at those timestamps?

>> Is there a way to select the I-Frame where the video gets split into chunks?
> Depends on the muxer you are using.

I'm using dash muxer.

>> Is there a limit for the minimum filesize for a chunk?
> Probably, depends on the format.

fmp4

>> Can I split on each I-frame?
> You can split anywhere, but the results might not be very useful depending on what you plan to do with it.
I think if I insert a keyframe, ffmpeg splits it there... Inserting 220
key frames results in 220 segments. ^^

Thanks a lot :)
_______________________________________________
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: Why was patch declined: Modified force_key_frames option to accept frame numbers?

kumowoon1025
> I'm using dash muxer.

It looks like -seg_duration sets the minimum, 5 seconds by default, though -use_timeline is needed if duration varies too much. If this isn’t actually for DASH, just use the segment muxer.
_______________________________________________
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".