Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2038 closed enhancement (worksforme)

Request for ffmpeg being able to join multiple files

Reported by: ramitb Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: concat
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the enhancement request: FFMPEG is currently able to create multiple files by splitting an existing file using the segment option. However there is no option to be able to join the segments back into a single file.
Perhaps there can be a way (like concat for MPEGTS files) to be able to specify multiple file inputs and join the video and audio tracks to create a single output file.

Attachments (4)

test1.wtv (1.4 MB ) - added by ramitb 11 years ago.
test2.wtv (2.3 MB ) - added by ramitb 11 years ago.
test3.wtv (2.3 MB ) - added by ramitb 11 years ago.
concat.txt (45 bytes ) - added by Carl Eugen Hoyos 11 years ago.

Change History (12)

comment:1 by Carl Eugen Hoyos, 11 years ago

Keywords: concat added

Could you explain (= show an example command line including complete, uncut console output) why this is not possible with the concat protocol, the concat filter or the concat demuxer?

comment:2 by ramitb, 11 years ago

For example, if I run the following command (attaching 3 sample files used)

ffmpeg -i "concat:test1.wtv|test2.wtv|test3.wtv" -c copy test.wtv

The output file (test.wtv) only contains the first file (test1.wtv) and not the remaining two.

ffmpeg version N-48065-g6375318 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 21 2012 09:06:30 with gcc 4.7.2 (GCC)
  configuration: --enable-static --arch=x86 --target-os=mingw32 --cross-prefix=/home/rdp/dev/ffmpeg-windows-build-helper
s/sandbox/mingw-w64-i686/bin/i686-w64-mingw32- --pkg-config=pkg-config --enable-gpl --enable-libx264 --enable-avisynth -
-enable-libxvid --enable-libmp3lame --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis --enable-libtheo
ra --enable-libspeex --enable-libopenjpeg --enable-gnutls --enable-libgsm --enable-libfreetype --enable-fontconfig --ena
ble-libass --enable-libutvideo --enable-libopus --disable-w32threads --enable-frei0r --enable-filter=frei0r --enable-lib
vo-aacenc --enable-bzlib --enable-libxavs --extra-cflags=-DPTW32_STATIC_LIB --enable-libopencore-amrnb --enable-libopenc
ore-amrwb --enable-libvo-amrwbenc --enable-libschroedinger --enable-libbluray --enable-libvpx --enable-runtime-cpudetect

  libavutil      52. 12.100 / 52. 12.100
  libavcodec     54. 81.100 / 54. 81.100
  libavformat    54. 49.102 / 54. 49.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 29.100 /  3. 29.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, wtv, from 'concat:test1.wtv|test2.wtv|test3.wtv':
  Metadata:
    WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
    WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
    Title           : Guys With Kids
    WM/SubTitle     : Thanksgiving
    WM/SubTitleDescription: Sheila tries to win the gang over with a traditional Thanksgiving dinner; Gary decides to sp
end the holiday waiting in line for a TV that's on sale.
    genre           : Comedy;Series
    WM/OriginalReleaseTime: 0
    WM/MediaCredits : Anthony Anderson/Zach Cregger/Jesse Bradford/Jamie-Lynn Sigler/Tempestt Bledsoe;;;Emmitt Smith/Eri
nn Hayes
    service_provider: KNBC
    service_name    : KNBC
    WM/MediaNetworkAffiliation: NBC Affiliate
    WM/MediaOriginalChannel: 4
    WM/MediaOriginalChannelSubNumber: 0
    WM/MediaOriginalBroadcastDateTime: 2012-11-21T08:00:00Z
    WM/MediaOriginalRunTime: 20974292466
    WM/MediaIsStereo: true
    WM/MediaIsRepeat: false
    WM/MediaIsLive  : false
    WM/MediaIsTape  : false
    WM/MediaIsDelay : false
    WM/MediaIsSubtitled: false
    WM/MediaIsMovie : false
    WM/MediaIsPremiere: false
    WM/MediaIsFinale: false
    WM/MediaIsSAP   : false
    WM/MediaIsSport : false
    WM/ParentalRating: TV-PG
    WM/Provider     : MediaCenterDefault
    WM/VideoClosedCaptioning: true
    WM/WMRVEncodeTime: 2012-11-22 04:28:02
    WM/WMRVSeriesUID: !MCSeries!274690485
    WM/WMRVServiceID: !MCService!28455445
    WM/WMRVProgramID: !MCProgram!282437030
    WM/WMRVRequestID: 0
    WM/WMRVScheduleItemID: 0
    WM/WMRVQuality  : 0
    WM/WMRVOriginalSoftPrePadding: 420
    WM/WMRVOriginalSoftPostPadding: 180
    WM/WMRVHardPrePadding: -300
    WM/WMRVHardPostPadding: 0
    WM/WMRVATSCContent: true
    WM/WMRVDTVContent: true
    WM/WMRVHDContent: false
    WM/MediaThumbType: 3
    WM/MediaThumbTimeStamp: 4643601142938852099
    WM/WMRVEndTime  : 2012-11-22 05:03:01
    WM/WMRVBitrate  : 3.975938
    WM/WMRVKeepUntil: -1
    WM/WMRVActualSoftPrePadding: 417
    WM/WMRVActualSoftPostPadding: 181
    WM/WMRVContentProtected: false
    WM/WMRVContentProtectedPercent: 0
    WM/WMRVExpirationSpan: 9223372036854775807
    WM/WMRVInBandRatingSystem: 255
    WM/WMRVInBandRatingLevel: 255
    WM/WMRVInBandRatingAttributes: 0
    WM/WMRVWatched  : true
    WM/MediaThumbWidth: 352
    WM/MediaThumbHeight: 320
    WM/MediaThumbStride: 1056
    WM/MediaThumbRet: 0
    WM/MediaThumbRatingSystem: 9
    WM/MediaThumbRatingLevel: 10
    WM/MediaThumbRatingAttributes: 0
    WM/MediaThumbAspectRatioX: 4
    WM/MediaThumbAspectRatioY: 3
    encoder         : Lavf54.49.102
  Duration: 00:00:05.01, start: 0.005256, bitrate: 10001 kb/s
    Stream #0:0[0x2]: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:1[0x3]: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:2[0x4]: Video: mpeg2video (Main), yuv420p, 528x480 [SAR 40:33 DAR 4:3], 29.97 fps, 29.97 tbr, 10000k tbn,
59.94 tbc
Output #0, wtv, to 'test.wtv':
  Metadata:
    WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
    WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
    Title           : Guys With Kids
    WM/SubTitle     : Thanksgiving
    WM/SubTitleDescription: Sheila tries to win the gang over with a traditional Thanksgiving dinner; Gary decides to sp
end the holiday waiting in line for a TV that's on sale.
    genre           : Comedy;Series
    WM/OriginalReleaseTime: 0
    WM/MediaCredits : Anthony Anderson/Zach Cregger/Jesse Bradford/Jamie-Lynn Sigler/Tempestt Bledsoe;;;Emmitt Smith/Eri
nn Hayes
    service_provider: KNBC
    service_name    : KNBC
    WM/MediaNetworkAffiliation: NBC Affiliate
    WM/MediaOriginalChannel: 4
    WM/MediaOriginalChannelSubNumber: 0
    WM/MediaOriginalBroadcastDateTime: 2012-11-21T08:00:00Z
    WM/MediaOriginalRunTime: 20974292466
    WM/MediaIsStereo: true
    WM/MediaIsRepeat: false
    WM/MediaIsLive  : false
    WM/MediaIsTape  : false
    WM/MediaIsDelay : false
    WM/MediaIsSubtitled: false
    WM/MediaIsMovie : false
    WM/MediaIsPremiere: false
    WM/MediaIsFinale: false
    WM/MediaIsSAP   : false
    WM/MediaIsSport : false
    WM/ParentalRating: TV-PG
    WM/Provider     : MediaCenterDefault
    WM/VideoClosedCaptioning: true
    WM/WMRVEncodeTime: 2012-11-22 04:28:02
    WM/WMRVSeriesUID: !MCSeries!274690485
    WM/WMRVServiceID: !MCService!28455445
    WM/WMRVProgramID: !MCProgram!282437030
    WM/WMRVRequestID: 0
    WM/WMRVScheduleItemID: 0
    WM/WMRVQuality  : 0
    WM/WMRVOriginalSoftPrePadding: 420
    WM/WMRVOriginalSoftPostPadding: 180
    WM/WMRVHardPrePadding: -300
    WM/WMRVHardPostPadding: 0
    WM/WMRVATSCContent: true
    WM/WMRVDTVContent: true
    WM/WMRVHDContent: false
    WM/MediaThumbType: 3
    WM/MediaThumbTimeStamp: 4643601142938852099
    WM/WMRVEndTime  : 2012-11-22 05:03:01
    WM/WMRVBitrate  : 3.975938
    WM/WMRVKeepUntil: -1
    WM/WMRVActualSoftPrePadding: 417
    WM/WMRVActualSoftPostPadding: 181
    WM/WMRVContentProtected: false
    WM/WMRVContentProtectedPercent: 0
    WM/WMRVExpirationSpan: 9223372036854775807
    WM/WMRVInBandRatingSystem: 255
    WM/WMRVInBandRatingLevel: 255
    WM/WMRVInBandRatingAttributes: 0
    WM/WMRVWatched  : true
    WM/MediaThumbWidth: 352
    WM/MediaThumbHeight: 320
    WM/MediaThumbStride: 1056
    WM/MediaThumbRet: 0
    WM/MediaThumbRatingSystem: 9
    WM/MediaThumbRatingLevel: 10
    WM/MediaThumbRatingAttributes: 0
    WM/MediaThumbAspectRatioX: 4
    WM/MediaThumbAspectRatioY: 3
    encoder         : Lavf54.49.102
    Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 528x480 [SAR 40:33 DAR 4:3], q=2-31, 29.97 fps, 10000k
tbn, 29.97 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:2 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  150 fps=0.0 q=-1.0 Lsize=    1256kB time=00:00:05.02 bitrate=2048.0kbits/s
video:1062kB audio:118kB subtitle:0 global headers:0kB muxing overhead 6.496203%

This strategy only seems to work if the inputs files are mpegts files.

by ramitb, 11 years ago

Attachment: test1.wtv added

by ramitb, 11 years ago

Attachment: test2.wtv added

by ramitb, 11 years ago

Attachment: test3.wtv added

by Carl Eugen Hoyos, 11 years ago

Attachment: concat.txt added

comment:3 by Carl Eugen Hoyos, 11 years ago

Resolution: worksforme
Status: newclosed

Works fine here, see also http://ffmpeg.org/ffmpeg-formats.html#concat

$ ffmpeg -f concat -i concat.txt -c copy out.wtv
ffmpeg version N-48117-g707af43 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 23 2012 10:56:26 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      52. 12.100 / 52. 12.100
  libavcodec     54. 81.100 / 54. 81.100
  libavformat    54. 49.102 / 54. 49.102
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 29.101 /  3. 29.101
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[concat @ 0x26567c0] max_analyze_duration 5000000 reached at 5024000
[concat @ 0x26567c0] Estimating duration from bitrate, this may be inaccurate
Input #0, concat, from 'concat.txt':
  Duration: 00:00:00.01, start: 0.000001, bitrate: 30 kb/s
    Stream #0:0: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:2: Video: mpeg2video (Main), yuv420p, 528x480 [SAR 40:33 DAR 4:3], 29.97 fps, 29.97 tbr, 10000k tbn, 59.94 tbc
Output #0, wtv, to 'out.wtv':
  Metadata:
    encoder         : Lavf54.49.102
    Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 528x480 [SAR 40:33 DAR 4:3], q=2-31, 29.97 fps, 10000k tbn, 29.97 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 192 kb/s
Stream mapping:
  Stream #0:2 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  405 fps=0.0 q=-1.0 Lsize=    5660kB time=00:00:15.16 bitrate=3057.0kbits/s
video:5127kB audio:352kB subtitle:0 global headers:0kB muxing overhead 3.295385%

comment:4 by ramitb, 11 years ago

Okay thanks, yes I tried that it works now.

I have a request, it was a HUGE problem escaping ALL special characters INCLUDING spaces. Can the text file format be adjust to accept the ENTIRE file path within QUOTES and NO escaping of characters?

comment:5 by ramitb, 11 years ago

Alternative can the old Pipe format (like what I've used above) be retained? (only escaping the quotes are required).

in reply to:  5 comment:6 by Carl Eugen Hoyos, 11 years ago

Replying to ramitbhalla:

Alternative can the old Pipe format (like what I've used above) be retained?

What makes you think the concat protocol (if that is what you mean) will not be retained?

comment:7 by ramitb, 11 years ago

What I was suggesting is that the concat demuxed (-f concat if I get it correctly) should also use the same format as the concat protocol for inputs file name rather than a text file, it makes the command line management a whole lot easier.

i.e.

-f concat -i "\"C:\Test Directory\Test1.wtv\"|"C:\Test Directory\Test2.wtv\""

comment:8 by Carl Eugen Hoyos, 11 years ago

Why don't you open a feature request?

Note: See TracTickets for help on using tickets.