[FFmpeg-user] Cutting out part of a video does not work
Cecil Westerhof
Cecil at decebal.nl
Fri Mar 26 18:28:40 EET 2021
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
>>
>> which is five seconds earlier. I get the same output.
>>
>> Am I doing something wrong?
>
> This is the expected outcome, because, due to the nature of lossy video
> codecs, one can only start on keyframes. Please have a look at the
> description of the -ss option for further details
>
>> Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
>> 1920x1080, 2070 kb/s, 25 fps, 25 tbr, 30k tbn, 60k tbc (default)
>> Metadata:
>> creation_time : 2021-03-25T19:02:11.000000Z
>> handler_name : H.264/AVC video
>> encoder : AVC Coding
>
> This is a lossy codec.
>
> If you can live with further quality loss in the video, you can
> transcode it, i.e. -c:v libx264.
>
> Or you can set the start point some seconds further back. This way you
> will not get the perfect cut but at least you do not lose anything of
> the content you want.
No, that I cannot do. I cannot publish stuff containing other people.
I now use:
ffmpeg -y -ss 1189 -i 2021-03-25ToastmastersClubAvond.mp4 -to 442 -acodec copy -vcodec libx264 -crf 8 -async 1 speech.mp4
This takes about 8 minutes instead of a second. But I have to live
with that.
There is only one problem. The video is 7:21 long, but both mpv and
vlc think it is 7:30 long.
And even ffprobe does think that:
ffprobe version 4.1.6-1~deb10u1 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'speech.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:07:30.90, start: 0.000000, bitrate: 2750 kb/s
Chapter #0:0: start 0.000000, end 442.000000
Metadata:
title : Recording Started
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1024x576, 2765 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : H.264/AVC video
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 34 kb/s (default)
Metadata:
handler_name : AAC audio
Stream #0:2(eng): Data: bin_data (text / 0x74786574)
Metadata:
handler_name : SubtitleHandler
Unsupported codec with id 100359 for input stream 2
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
More information about the ffmpeg-user
mailing list