Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [FEATURE] Cut a video (-ss) with timings non-aligned on keyframes, with minimal re-encoding
@ 2024-08-13  7:35 basj
  2024-08-13  8:55 ` Timo Rothenpieler
  0 siblings, 1 reply; 5+ messages in thread
From: basj @ 2024-08-13  7:35 UTC (permalink / raw)
  To: ffmpeg-devel


A little bump, does anyone have an idea about this?

Do you think it would be worth developing a command-line option so that exact cutting with minimal re-encoding would be easier?

Linked: https://superuser.com/questions/1850814/cut-a-video-with-ffmpeg-with-no-or-minimal-reencoding
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [FEATURE] Cut a video (-ss) with timings non-aligned on keyframes, with minimal re-encoding
  2024-08-13  7:35 [FFmpeg-devel] [FEATURE] Cut a video (-ss) with timings non-aligned on keyframes, with minimal re-encoding basj
@ 2024-08-13  8:55 ` Timo Rothenpieler
  0 siblings, 0 replies; 5+ messages in thread
From: Timo Rothenpieler @ 2024-08-13  8:55 UTC (permalink / raw)
  To: ffmpeg-devel

On 13.08.2024 09:35, basj@gget.it wrote:
> 
> A little bump, does anyone have an idea about this?
> 
> Do you think it would be worth developing a command-line option so that exact cutting with minimal re-encoding would be easier?

How do you plan to figure out the options needed to be passed to each 
and every encoder, so that it'll produce compatible output to enable the 
necessary concatenation of old and new encoded data?

That's by far the biggest roadblock I see with this.

> Linked: https://superuser.com/questions/1850814/cut-a-video-with-ffmpeg-with-no-or-minimal-reencoding
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [FEATURE] Cut a video (-ss) with timings non-aligned on keyframes, with minimal re-encoding
  2024-08-14 10:05 basj
@ 2024-08-14 11:42 ` Zhao Zhili
  0 siblings, 0 replies; 5+ messages in thread
From: Zhao Zhili @ 2024-08-14 11:42 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Aug 14, 2024, at 18:05, basj@gget.it wrote:
> 
> 
>>> Do you think it would be worth developing a command-line option so that exact cutting with minimal re-encoding would be easier?
>> 
>> How do you plan to figure out the options needed to be passed to each
>> and every encoder, so that it'll produce compatible output to enable the
>> necessary concatenation of old and new encoded data?
>> 
>> That's by far the biggest roadblock I see with this.
> 
> I see. You're right, then this technique is probably a dead-end...
> 
> More generally, which is the recommanded way to cut a video with a specific starting point and specific length, with minimal re-encoding?
> Millions of hours of CPU-time are probably wasted to reencode already-perfectly-encoded content, just for cutting ;)

Only do remux without transcoding, and let mp4 muxer use editlist to strip the timeline from IDR to the requested start time.
The preroll at the beginning can be slow when playback, but seeking also has the same preroll

Other choice is use multiple groups of SPS/PPS in mp4 sample description. We have that support in mp4 demuxer, but not
in muxer. It’s standard in specification but not widely supported. So if we add support to muxer and it works with our own 
demuxer, it’s not surprise to experience a lot of compatibility issues with other software.

> 
> Are there already promising dev attempts in the direction of a feature able to cut with minimal re-encoding?
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [FFmpeg-devel] [FEATURE] Cut a video (-ss) with timings non-aligned on keyframes, with minimal re-encoding
@ 2024-08-14 10:05 basj
  2024-08-14 11:42 ` Zhao Zhili
  0 siblings, 1 reply; 5+ messages in thread
From: basj @ 2024-08-14 10:05 UTC (permalink / raw)
  To: ffmpeg-devel


> > Do you think it would be worth developing a command-line option so that exact cutting with minimal re-encoding would be easier?
> 
> How do you plan to figure out the options needed to be passed to each
> and every encoder, so that it'll produce compatible output to enable the
> necessary concatenation of old and new encoded data?
> 
> That's by far the biggest roadblock I see with this.

I see. You're right, then this technique is probably a dead-end...

More generally, which is the recommanded way to cut a video with a specific starting point and specific length, with minimal re-encoding?
Millions of hours of CPU-time are probably wasted to reencode already-perfectly-encoded content, just for cutting ;)

Are there already promising dev attempts in the direction of a feature able to cut with minimal re-encoding?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [FFmpeg-devel] [FEATURE] Cut a video (-ss) with timings non-aligned on keyframes, with minimal re-encoding
@ 2024-08-05 19:45 basj
  0 siblings, 0 replies; 5+ messages in thread
From: basj @ 2024-08-05 19:45 UTC (permalink / raw)
  To: ffmpeg-devel

Hi,

Before trying to develop a new feature, and diving in the code base, I wanted to know if it currently exists, or is already in a work-in-progress task:

When cutting a video with no re-encoding:

    ffmpeg -ss 120 -t 60 -i input.mp4 -c copy output.mp4

the result is often choppy or non-smooth in the first seconds, because the cut point doesn't necessarily coincide with a keyframe, at least on some players (such as Media Player Classic, etc.).

Some more complex solutions involve reencoding just the beginning until the next keyframe, and then use copy codec for the rest of the video, and then concatenating, all of this requiring multiple calls of ffmpeg.

Is there a feature already in development that would allow to do this in one single pass of ffmpeg, without multiple calls and concatenation?

Something like:

    ffmpeg -ss 120 -t 60 -i input.mp4 -c copy -reencodebeforekeyframe output.mp4

Thanks,
Basj
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-14 11:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-13  7:35 [FFmpeg-devel] [FEATURE] Cut a video (-ss) with timings non-aligned on keyframes, with minimal re-encoding basj
2024-08-13  8:55 ` Timo Rothenpieler
  -- strict thread matches above, loose matches on Subject: below --
2024-08-14 10:05 basj
2024-08-14 11:42 ` Zhao Zhili
2024-08-05 19:45 basj

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git