[FFmpeg-user] splitting and concatenating file results in a different file

Jon Beyer jbeyer at gmail.com
Thu Oct 31 19:22:09 EET 2019


Thanks Carl, here is the full output from each of those commands.  Nothing
unusual that I can see.  I have truncated the diff output, because the
output is superfluous after those three frames are inserted after
chunk_000.mp4.  I'll point out that the second-to-last line of the concat
filter command appears to properly show 4,073 frames, but then when
converting to .jpg, 4,076 frames are produced.



ffmpeg -i input.mp4 -map 0 -c copy -f segment -segment_time 10
chunk_%03d.mp4

ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.8)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_1 --enable-shared
--enable-pthreads --enable-version3 --enable-avresample --cc=clang
--host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include
-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin
-fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls
--enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame
--enable-libopus --enable-librubberband --enable-libsnappy
--enable-libtesseract --enable-libtheora --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
--enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype
--enable-frei0r --enable-libass --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp
--enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack
--disable-indev=jack
  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 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.40.101
  Duration: 00:02:15.84, start: 0.000000, bitrate: 5041 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 4906 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
(default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[segment @ 0x7fb231815800] Opening 'chunk_000.mp4' for writing
Output #0, segment, to 'chunk_%03d.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,
1280x720 [SAR 1:1 DAR 16:9], q=2-31, 4906 kb/s, 30 fps, 30 tbr, 15360 tbn,
30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[segment @ 0x7fb231815800] Opening 'chunk_001.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_002.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_003.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_004.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_005.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_006.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_007.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_008.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_009.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_010.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_011.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_012.mp4' for writing
[segment @ 0x7fb231815800] Opening 'chunk_013.mp4' for writing/A speed= 245x
frame= 4073 fps=0.0 q=-1.0 Lsize=N/A time=00:02:15.81 bitrate=N/A speed=
258x
video:81321kB audio:2137kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown


ffmpeg -f concat -safe 0 -i mylist.txt -c copy concat.mp4

ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.8)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_1 --enable-shared
--enable-pthreads --enable-version3 --enable-avresample --cc=clang
--host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include
-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin
-fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls
--enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame
--enable-libopus --enable-librubberband --enable-libsnappy
--enable-libtesseract --enable-libtheora --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
--enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype
--enable-frei0r --enable-libass --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp
--enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack
--disable-indev=jack
  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
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf4808c00] Auto-inserting h264_mp4toannexb
bitstream filter
Input #0, concat, from 'mylist.txt':
  Duration: N/A, start: 0.000000, bitrate: 3996 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 3866 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 130 kb/s
    Metadata:
      handler_name    : SoundHandler
Output #0, mp4, to 'concat.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], q=2-31, 3866 kb/s, 30 fps, 30 tbr, 15360 tbn,
15360 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 130 kb/s
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf4808c00] Auto-inserting h264_mp4toannexb
bitstream filter
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf3803a00] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf3006800] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf4001400] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf4808c00] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf3802e00] Auto-inserting h264_mp4toannexb
bitstream filter7x
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf4007000] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf3802e00] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf4808c00] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf3006800] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf400fe00] Auto-inserting h264_mp4toannexb
bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fecf4001400] Auto-inserting h264_mp4toannexb
bitstream filter29x
frame= 4073 fps=3955 q=-1.0 Lsize=   83591kB time=00:02:15.91
bitrate=5038.4kbits/s speed= 132x
video:81322kB audio:2137kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.157127%



ffmpeg -i input.mp4 video1/frames_%05d.jpg

ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.8)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_1 --enable-shared
--enable-pthreads --enable-version3 --enable-avresample --cc=clang
--host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include
-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin
-fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls
--enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame
--enable-libopus --enable-librubberband --enable-libsnappy
--enable-libtesseract --enable-libtheora --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
--enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype
--enable-frei0r --enable-libass --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp
--enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack
--disable-indev=jack
  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 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.40.101
  Duration: 00:02:15.84, start: 0.000000, bitrate: 5041 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 4906 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
(default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x11246b000] deprecated pixel format used, make sure you did
set range correctly
Output #0, image2, to 'video1/frames_%05d.jpg':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1280x720 [SAR 1:1 DAR
16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 4073 fps= 72 q=24.8 Lsize=N/A time=00:02:15.76 bitrate=N/A
speed=2.39x
video:97113kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown


ffmpeg -i concat.mp4 video2/frames_%05d.jpg

ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.8)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.1_1 --enable-shared
--enable-pthreads --enable-version3 --enable-avresample --cc=clang
--host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include
-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home/include/darwin
-fno-stack-check' --host-ldflags= --enable-ffplay --enable-gnutls
--enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame
--enable-libopus --enable-librubberband --enable-libsnappy
--enable-libtesseract --enable-libtheora --enable-libvidstab
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
--enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype
--enable-frei0r --enable-libass --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp
--enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack
--disable-indev=jack
  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 'concat.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:02:15.94, start: 0.000000, bitrate: 5037 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 4903 kb/s, 29.98 fps, 30 tbr, 15360 tbn, 60
tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x10ecd7000] deprecated pixel format used, make sure you did
set range correctly
Output #0, image2, to 'video2/frames_%05d.jpg':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1280x720 [SAR 1:1 DAR
16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 4076 fps= 73 q=24.8 Lsize=N/A time=00:02:15.86 bitrate=N/A dup=3
drop=0 speed=2.44x
video:97160kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown




diff -r video1/ video2/

Binary files video1/frames_00474.jpg and video2/frames_00474.jpg differ
Binary files video1/frames_00475.jpg and video2/frames_00475.jpg differ
Binary files video1/frames_00476.jpg and video2/frames_00476.jpg differ
Binary files video1/frames_00477.jpg and video2/frames_00477.jpg differ
Binary files video1/frames_00479.jpg and video2/frames_00479.jpg differ
(truncated)
Binary files video1/frames_04067.jpg and video2/frames_04067.jpg differ
Binary files video1/frames_04068.jpg and video2/frames_04068.jpg differ
Binary files video1/frames_04069.jpg and video2/frames_04069.jpg differ
Binary files video1/frames_04070.jpg and video2/frames_04070.jpg differ
Binary files video1/frames_04071.jpg and video2/frames_04071.jpg differ
Only in video2/: frames_04074.jpg
Only in video2/: frames_04075.jpg
Only in video2/: frames_04076.jpg





On Thu, Oct 31, 2019 at 11:32 AM Carl Eugen Hoyos <ceffmpeg at gmail.com>
wrote:

>
>
> > Am 31.10.2019 um 14:55 schrieb Jon Beyer <jbeyer at gmail.com>:
> >
> > I'm trying to understand the basics of splitting a file on I frames and
> > then concatenating the smaller files back together.
>
> The fundamentals are that ffmpeg is a transcoding application, not a file
> archiver.
> Your command lines should provide identical output for some input files,
> but without the command lines you tested posted together with the complete,
> uncut console output there is not much we can say (or guess).
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list