[FFmpeg-user] Cutting out part of a video does not work
Peter White
peter.white at posteo.net
Sat Mar 27 08:22:30 EET 2021
On Sat, Mar 27, 2021 at 06:18:59AM +0100, Cecil Westerhof via ffmpeg-user wrote:
> Peter White <peter.white at posteo.net> writes:
>
> > On Fri, Mar 26, 2021 at 05:28:40PM +0100, Cecil Westerhof via ffmpeg-user wrote:
> >> Peter White <peter.white at posteo.net> writes:
> >>
> >> > On Fri, Mar 26, 2021 at 09:55:21AM +0100, Cecil Westerhof via ffmpeg-user wrote:
> >> >> I want to publish a speech I gave during a Zoom meeting. But cutting
> >> >> it out does not work.
> >> >>
> >> >> When I use:
> >> >> ffmpeg -y -i 2021-03-25ToastmastersClubAvond.mp4 -ss 1190 -to 1631
> >> >> -acodec copy -vcodec copy -async 1 speech.mp4
> >> >>
> >> >> The video starts just a bit to late. But when I use:
> >> >> ffmpeg -y -i 2021-03-25ToastmastersClubAvond.mp4 -ss 1185 -to 1631
> >> >> -acodec copy -vcodec copy -async 1 speech.mp4
> >> >>
> >> >
> >> > If you can live with further quality loss in the video, you can
> >> > transcode it, i.e. -c:v libx264.
> >> >
> >>
> >> I now use:
> >> ffmpeg -y -ss 1189 -i 2021-03-25ToastmastersClubAvond.mp4 -to 442
> >> -acodec copy -vcodec libx264 -crf 8 -async 1 speech.mp4
> >
> > CRF 8 seems excessive. Try 16 for a start. From various online sources I
> > gathered that it is pretty much transparent, as in no noticeable
> > difference to the original. My own experience shows the same.
>
> So crf is useful? (Other post said not.) I am now running it without
> crf (and async). When it is finished I will try it with crf 16.
I am pretty certain Carl Eugen also meant that CRF 8 is excessive for
no visible gain in quality. From the documentation of x264 I remember
that an decrement of 1 results in a size increase of the video of
roughly 12.5 %, so when you use 8 instead of 16 that is 1.125 to the
power of 8 the size of the same video encoded with CRF 16, so roughly
2.5 times the size. And you won't notice the difference. Might even try
higher values for CRF. Since I, personally, are very conscious about not
losing any quality, I use 16. But even that might be too conservative.
Consider it a rough ball park figure to get you started.
> >> This takes about 8 minutes instead of a second. But I have to live
> >> with that.
> >
> > You could try to do this in multiple stages, maybe. Only transcode the
> > first few seconds up to the next keyframe and then stitch that and the
> > copied rest together. In theory this should work, but may be not as easy
> > to achieve. Obviously the codecs, frame rates and resolutions need to
> > match. I guess codec parameters need to match as well, not sure. The
> > question is if it is worth the effort.
>
> I was thinking about a variant of this. Create a few seconds of the
> start and a few seconds of the end until I entered the correct values
> and then generate the complete file.
Don't worry about the end, because there is no restriction on what kind
of frame is allowed there. The encoder will simply stop encoding.
> It seems that without crf the video is generated faster. It now only
> took five minutes. (But maybe my computer was doing less.) It is a lot
> smaller: 41.5 MB instead of 147.8 MB.
Have a look at the defaults of the x264 encoder. If memory serves, CRF
is 23 by default and you will most certainly notice artifacts,
especially since you are transcoding from one lossy format to another,
because losses propagate.
> Now trying with crf 16. And then comparing the video quality.
You will see a difference between not specifying CRF and 16. I am pretty
sure about that. ;)
Cheers,
Peter
More information about the ffmpeg-user
mailing list