Clipped video using ffmpeg is shorter than expected

0

I'm trying to get a clip of length 6 secs from a MP4 video (size: 1.44 GB, length: 02:23:38). But video stream stops after 1 sec, while audio stream keeps playing normally until 6 secs.

I'm using this command to do the clipping:

ffmpeg -i myvid.mp4 -ss 00:50:40.0 -c:v copy -c:a copy -t 00:00:06.0 -async 1 clip.mp4

Can any one help me in this issue?

Thankyou

Update 1: Here is the output of command:

ffmpeg version N-69530-g52f2adc-Sherpya Copyright (c) 2000-2015 the FFmpeg devel
opers
  built with gcc 4.9.2 (GCC)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myvid.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-02-22 12:22:10
  Duration: 02:23:38.07, start: 0.000000, bitrate: 1437 kb/s
    Chapter #0:0: start 0.000000, end 354.125000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 354.125000, end 2339.125000
    Metadata:
      title           : 00:05:54.125
    Chapter #0:2: start 2339.125000, end 2573.125000
    Metadata:
      title           : 00:38:59.125
    Chapter #0:3: start 2573.125000, end 3504.750000
    Metadata:
      title           : 00:42:53.125
    Chapter #0:4: start 3504.750000, end 3854.458000
    Metadata:
      title           : 00:58:24.750
    Chapter #0:5: start 3854.458000, end 4364.125000
    Metadata:
      title           : 01:04:14.458
    Chapter #0:6: start 4364.125000, end 5029.125000
    Metadata:
      title           : 01:12:44.125
    Chapter #0:7: start 5029.125000, end 5526.750000
    Metadata:
      title           : 01:23:49.125
    Chapter #0:8: start 5526.750000, end 5796.958000
    Metadata:
      title           : 01:32:06.750
    Chapter #0:9: start 5796.958000, end 6084.416000
    Metadata:
      title           : 01:36:36.958
    Chapter #0:10: start 6084.416000, end 8316.416000
    Metadata:
      title           : 01:41:24.416
    Chapter #0:11: start 8316.416000, end 8618.068333
    Metadata:
      title           : 02:18:36.416
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x544
[SAR 1:1 DAR 40:17], 1242 kb/s, 24 fps, 24 tbr, 96 tbn, 48 tbc (default)
    Metadata:
      creation_time   : 2013-02-22 12:22:10
      handler_name    : Jab We Met (2009) BRRip 1080P DTS ESub Chapters [DDR]
    Stream #0:1(und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fl
tp, 192 kb/s (default)
    Metadata:
      creation_time   : 2013-02-22 12:22:23
      handler_name    : på.
Output #0, mp4, to 'clip.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    encoder         : Lavf56.19.100
    Chapter #0:0: start 0.000000, end 6.000000
    Metadata:
      title           : 00:42:53.125
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x544 [S
AR 1:1 DAR 40:17], q=2-31, 1242 kb/s, 24 fps, 24 tbr, 12288 tbn, 96 tbc (default
)
    Metadata:
      creation_time   : 2013-02-22 12:22:10
      handler_name    : Jab We Met (2009) BRRip 1080P DTS ESub Chapters [DDR]
    Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, 5.1, 192 kb
/s (default)
    Metadata:
      creation_time   : 2013-02-22 12:22:23
      handler_name    : på.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   25 fps=6.4 q=-1.0 Lsize=     226kB time=00:00:06.01 bitrate= 307.1kbits
/s
video:82kB audio:141kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 1.334416%

Anjan0791

Posted 2015-06-02T19:33:26.063

Reputation: 3

What happens if you leave out the -async option? – slhck – 2015-06-03T07:22:42.557

Event after removing -async, problem persists. I think problem was with codecs as when I explicitly mentioned codecs (mpeg4, aac) and bit rates. It clipped the video correctly. Thanks any way for your help. – Anjan0791 – 2015-06-03T14:50:16.257

Answers

0

You shouldn't really copy the encoded stream when your target is just a segment of it. You can either place the -ss & -t options before the input file but then the cutting will be done on a keyframe, or place them before the output file as you've done for a precise cutting, but you'll have to transcode the video, that is, remove the -c:v copy -c:a copy from your command. A detailed explanation is available in this answer.

avnr

Posted 2015-06-02T19:33:26.063

Reputation: 316

Thanks for your help. It worked after explicitly specifying codecs & codecs parameters. – Anjan0791 – 2015-06-03T14:46:16.393

That's not quite correct. In principle you can cut segments even with stream copying. They may not be frame accurate but I don't see how the example given by the OP shouldn't work. @anjan – slhck – 2015-06-03T16:15:50.600

@slhck - you are right. But in practice, the question is how to get things done, so I assume that there is no interest in investing the time to research why the incorrect command produced a wrong output of this sort rather than the other wrong output... – avnr – 2015-06-03T16:24:47.363