Concat 2 videos, results in wrong length of the result

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Concat 2 videos, results in wrong length of the result

Marek Sebera
Hi,

I'm trying to concat 2 video files, process that worked pretty well for
us for the past few months.

Using Debian binary distribution ffmpeg (7:3.2.7-1~deb9u1) and libx264
(libx264-148:amd64  2:0.148.2748+git97eaef2-1)

Concat 2 files, ffmpeg command, ffprobe of both source files and result
files below.

Concat of the 2 videos, of lenght (00:00:21.00) and (00:00:28.03)
results in video of lenght (00:01:54.92), which is obviously wrong.

Is it issue within ffmpeg handling or user error?

Thank you
MS

==== FFMPEG COMMAND ====
ffmpeg -f concat -y -safe 0 -i concat.121.def -c:a none -c:v h264 -an
/var/www/html/webroot/video/121.merged.out.mp4

==== FFMPEG COMMAND output ====

ffmpeg version 3.2.7-1~deb9u1 Copyright (c) 2000-2017 the FFmpeg
developers

  built with gcc 6.3.0 (Debian 6.3.0-18) 20170516


  configuration: --prefix=/usr --extra-version='1~deb9u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --enab
le-gpl --disable-stripping --enable-avresample --enable-avisynth
--enable-gnutls --enable-ladspa --enable-libass --enable-libbluray
--enable-libbs2b --enable-l
ibcaca --enable-libcdio --enable-libebur128 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm -
-enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt
--enable-libopus --enable-libpulse --enable-librubberband
--enable-libshine --enable-libsnappy --en
able-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp -
-enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi
--enable-omx --enable-openal --enable-opengl --enable-sdl2
--enable-libdc1394 --enable-libiec
61883 --enable-chromaprint --enable-frei0r --enable-libopencv
--enable-libx264 --enable-shared

  libavutil      55. 34.101 / 55. 34.101


  libavcodec     57. 64.101 / 57. 64.101


  libavformat    57. 56.101 / 57. 56.101


  libavdevice    57.  1.100 / 57.  1.100


  libavfilter     6. 65.100 /  6. 65.100


  libavresample   3.  1.  0 /  3.  1.  0

               libswscale      4.  2.100 /  4.  2.100

                            libswresample   2.  3.100 /  2.  3.100

                                         libpostproc    54.  1.100 / 54.
 1.100

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5635dbf2c080] Auto-inserting
h264_mp4toannexb bitstream filter
                            Input #0, concat, from 'concat.121.def':

                                           Duration: N/A, start:
0.000000, bitrate: 1455 kb/s

    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080, 1455 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc

    Metadata:


      handler_name    : VideoHandler


[libx264 @ 0x5635dbf30100] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2

[libx264 @ 0x5635dbf30100] profile High, level 4.0


[libx264 @ 0x5635dbf30100] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4
AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html -
options: cabac=1 re
f=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1
cqm=0 deadzone=21,11 fast_pski
p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0
nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0
bframes=3 b_pyramid=2 b
_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0
.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00


Output #0, mp4, to '/var/www/html/webroot/video/121.merged.out.mp4':

  Metadata:
    encoder         : Lavf57.56.101


    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc

    Metadata:


      handler_name    : VideoHandler


      encoder         : Lavc57.64.101 libx264


    Side data:


      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1


Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))

             Press [q] to stop, [?] for help


[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5635dc783ba0] Auto-inserting
h264_mp4toannexb bitstream filter7x

frame= 2873 fps= 43 q=-1.0 Lsize=    8251kB time=00:01:54.80 bitrate=
588.8kbits/s dup=1508 drop=0 speed= 1.7x

video:8217kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.412306%

[libx264 @ 0x5635dbf30100] frame I:12    Avg QP:13.70  size:110270


[libx264 @ 0x5635dbf30100] frame P:900   Avg QP:17.60  size:  6470


[libx264 @ 0x5635dbf30100] frame B:1961  Avg QP:23.12  size:   646


[libx264 @ 0x5635dbf30100] consecutive B-frames:  3.9% 14.3%  2.8% 78.9%


[libx264 @ 0x5635dbf30100] mb I  I16..4: 33.3% 36.1% 30.6%


[libx264 @ 0x5635dbf30100] mb P  I16..4:  1.9%  2.3%  0.5%  P16..4:
7.0%  1.7%  0.8%  0.0%  0.0%    skip:85.8%

[libx264 @ 0x5635dbf30100] mb B  I16..4:  0.1%  0.1%  0.0%  B16..8:
3.5%  0.2%  0.0%  direct: 0.2%  skip:95.9%  L0:39.4% L1:57.9% BI: 2.7%

[libx264 @ 0x5635dbf30100] 8x8 transform intra:45.9% inter:64.1%


[libx264 @ 0x5635dbf30100] coded y,uvDC,uvAC intra: 22.5% 36.7% 15.1%
inter: 0.9% 1.6% 0.2%

[libx264 @ 0x5635dbf30100] i16 v,h,dc,p: 37% 36%  7% 19%


[libx264 @ 0x5635dbf30100] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 25% 37%
2%  2%  2%  2%  2%  3%
               [libx264 @ 0x5635dbf30100] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:
35% 25% 15%  3%  6%  4%  4%  3%  3%
                            [libx264 @ 0x5635dbf30100] i8c dc,h,v,p: 59%
21% 15%  5%
                                         [libx264 @ 0x5635dbf30100]
Weighted P-Frames: Y:0.4% UV:0.1%
                                                           [libx264 @
0x5635dbf30100] ref P L0: 72.1%  8.9% 13.5%  5.4%  0.0%

  [libx264 @ 0x5635dbf30100] ref B L0: 80.0% 17.7%  2.3%

               [libx264 @ 0x5635dbf30100] ref B L1: 96.9%  3.1%


[libx264 @ 0x5635dbf30100] kb/s:585.71

==== concat.121.def contents ====
file '/var/www/html/webroot/video/98.out.mp4'
file '/var/www/html/webroot/video/96.out.mp4'

==== ffprobe of 98.out.mp4 ====
ffprobe version 3.2.7-1~deb9u1 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping
--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libebur128 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg
--enable-libopenmpt --enable-libopus --enable-libpulse
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid
--enable-libzmq --enable-libzvbi --enable-omx --enable-openal
--enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264
--enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '98.out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:00:21.00, start: 0.000000, bitrate: 1457 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080, 1455 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler

==== ffprobe of 96.out.mp4 ====
ffprobe version 3.2.7-1~deb9u1 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping
--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libebur128 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg
--enable-libopenmpt --enable-libopus --enable-libpulse
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid
--enable-libzmq --enable-libzvbi --enable-omx --enable-openal
--enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264
--enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '96.out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:00:28.03, start: 0.000000, bitrate: 922 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080, 919 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler

==== ffprobe of result (121.merged.out.mp4) ====
ffprobe version 3.2.7-1~deb9u1 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1'
--toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu
--incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping
--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libebur128 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg
--enable-libopenmpt --enable-libopus --enable-libpulse
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid
--enable-libzmq --enable-libzvbi --enable-omx --enable-openal
--enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883
--enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264
--enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '121.merged.out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:01:54.92, start: 0.000000, bitrate: 588 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080, 585 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler


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

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

signature.asc (868 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Concat 2 videos, results in wrong length of the result

Gyan
On Fri, Sep 8, 2017 at 3:38 PM, Marek Sebera <[hidden email]> wrote:

>
> Concat of the 2 videos, of lenght (00:00:21.00) and (00:00:28.03)
> results in video of lenght (00:01:54.92), which is obviously wrong.
>
>
> ==== ffprobe of 98.out.mp4 ====
>


>     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> 1920x1080, 1455 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
>


> ==== ffprobe of 96.out.mp4 ====
>


>     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> 1920x1080, 919 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
>

The timescales are different 12800 vs 30000. The concat demuxer initializes
output properties based on the first file, and doesn't rescale timestamps
of the other files.

Run this on 96.out.mp4

    ffmpeg -i 96.out.mp4 -c copy -video_track_timescale 12800 96.new.mp4

and concat this with the other file.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://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: Concat 2 videos, results in wrong length of the result

Nitish Prabhu
On Sat, Sep 9, 2017 at 10:24 AM, Gyan <[hidden email]> wrote:
>
> Run this on 96.out.mp4
>
>     ffmpeg -i 96.out.mp4 -c copy -video_track_timescale 12800 96.new.mp4
>
> and concat this with the other file.

Won't altering the timebase for "96.out.mp4" make the "96.new.mp4" play
slower than it was recorded at?

Is it better to instead drop the frames in "96.out.mp4" (which has a frame
rate of 29.97fps) and make it 25fps (frame rate of 98.out.mp4), and then
concatenate the streams?

Otherwise, we can also use the concat filter
<https://trac.ffmpeg.org/wiki/Concatenate#filter> (present on recent ffmepg
versions) to generate a variable frame rate concatenated output (with all
frames intact).
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://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: Concat 2 videos, results in wrong length of the result

Gyan
On Sat, Sep 9, 2017 at 11:01 AM, Nitish Prabhu <[hidden email]>
wrote:

>
> Won't altering the timebase for "96.out.mp4" make the "96.new.mp4" play
> slower than it was recorded at?
>

When the timescale is changed here, ffmpeg will rescale the timestamps to
maintain timing. There's a loss of precision since the temporal resolution
is decreased ~2x but for a 30 fps video and a 10^4 timescale, it makes no
difference.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

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