extract first 26 seconds not workings as expected

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

extract first 26 seconds not workings as expected

FFmpeg-users mailing list
Hello,


I have a video (main.mp4 - that has about 52 minutes) that I want to cut its first 26 seconds.

For this, I'm using command


$ ffmpeg -i main.mp4 -ss 00:00:00.00 -t 00:00:26.00 -c copy part1.mp4
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --toolchain=hardened --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. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'main.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:52:08.25, start: 0.000000, bitrate: 182 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1366x768 [SAR 1:1 DAR 683:384], 180 kb/s, 23.80 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Output #0, mp4, to 'part1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1366x768 [SAR 1:1 DAR 683:384], q=2-31, 180 kb/s, 23.80 fps, 24 tbr, 12288 tbn, 12288 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=  322 fps=0.0 q=-1.0 Lsize=     523kB time=00:00:25.95 bitrate= 165.2kbits/s speed=8.19e+03x    
video:519kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.881877%




However, file part1.mp4 has only 13 seconds!

$ ffprobe part1.mp4
ffprobe version 4.2.3 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --toolchain=hardened --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. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'part1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:13.42, start: 12.666016, bitrate: 319 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1366x768 [SAR 1:1 DAR 683:384], 316 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler



What I did wrong?

Also, how can I cut one part that begins at 00:01:00 and ends at 00:02:16 ?


Kind regards,

Leonardo
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: extract first 26 seconds not workings as expected

Carl Eugen Hoyos-2
Am So., 28. Juni 2020 um 20:31 Uhr schrieb Leonardo via ffmpeg-user
<[hidden email]>:

> I have a video (main.mp4 - that has about 52 minutes) that I want to cut its first 26 seconds.
>
> For this, I'm using command
>
> $ ffmpeg -i main.mp4 -ss 00:00:00.00 -t 00:00:26.00 -c copy part1.mp4
> ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers

Please test current FFmpeg git head, if the issue is reproducible
provide an input sample.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: extract first 26 seconds not workings as expected

Moritz Barsnick
In reply to this post by FFmpeg-users mailing list
On Sun, Jun 28, 2020 at 18:31:15 +0000, Leonardo via ffmpeg-user wrote:
> $ ffmpeg -i main.mp4 -ss 00:00:00.00 -t 00:00:26.00 -c copy part1.mp4
[...]
> frame=  322 fps=0.0 q=-1.0 Lsize=     523kB time=00:00:25.95 bitrate= 165.2kbits/s speed=8.19e+03x    
> video:519kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.881877%

322 frames at 23.8 fps looks suspiciously like 13.5 seconds.

> However, file part1.mp4 has only 13 seconds!
>   Duration: 00:00:13.42, start: 12.666016, bitrate: 319 kb/s

13.42 + 12.66 is approximately 25.

So my guess is that your input file's first keyframe is at 12.66
seconds, and ffmpeg refuses to copy the frames before that one.

You may want to try the option "-copyinkf" ("copy initial
non-keyframes") when using "-c copy".

> Also, how can I cut one part that begins at 00:01:00 and ends at 00:02:16 ?

How about "-ss 00:01:00 -t 1:16"? (I'm also not sure how this behaves
without keyframes, and whether that segment will ever be playable.)

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: extract first 26 seconds not workings as expected

FFmpeg-users mailing list
Hello

>You may want to try the option "-copyinkf" ("copy initial

>non-keyframes") when using "-c copy".

 I tried with this option, but the extracted part was "grayed" at the beginning.


The only workaround that I found that worked was


$ ffmpeg -i main.mp4 -vf "trim=start=0:end=26" part1.mp4

but re-encoded is needed.

As you pointed out, the file has 23.80 fps, and this may be the problem.

I created a sample video (53.63 seconds) if someone want to try some code on it.


The video of the original post and this one were created using SimpleScreenRecorder

Perhaps some configuration on the GUI is not properly set to produce a "good video file".
Will try to play with it a bit.

Kind regard,
Leonardo
 
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: extract first 26 seconds not workings as expected

FFmpeg-users mailing list
In reply to this post by Moritz Barsnick
 I forgot to add the sample


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

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

sample.mp4 (227K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: extract first 26 seconds not workings as expected

FFmpeg-users mailing list
In reply to this post by Carl Eugen Hoyos-2
Hello
Carl,

> Please test current FFmpeg git head, if the issue is reproducible
> provide an input sample.

I tested with current git and the results were the same.

As noticed by Moritz at the output of ffprobe


$ ffprobe part1.mp4
ffprobe version N-98341-gcca982ee01 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --toolchain=hardened --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. 55.100 / 56. 55.100
  libavcodec     58. 93.100 / 58. 93.100
  libavformat    58. 47.100 / 58. 47.100
  libavdevice    58. 11.100 / 58. 11.100
  libavfilter     7. 86.100 /  7. 86.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'part1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.47.100
  Duration: 00:00:13.54, start: 12.666016, bitrate: 316 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1366x768 [SAR 1:1 DAR 683:384], 316 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler


the Duration and the start values are 13.54 and 12.66, respectively.

It looks like that ffmpeg is not respecting "extract from 0 to 26" and instead doing something like

"well, I will start at 12.6 and will stop at 26"

Forcing with -copyinkf as suggested by Moritz, although the extracted part has, indeed, 26 seconds, there is only a "gray screen" from 0 to 12.6 and after that it plays well.

The main.mp4 file plays normal.

Kind regards,
Leonardo

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

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

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