Muszę scalić sześć plików MP4 w jeden. Oto informacje o plikach:
pt1.mp4
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 998 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
pt2.mp4
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 1000 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn,
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 130 kb/s (default)
pt3.mp4
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 1001 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn,
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
pt4.mp4
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 990 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn,
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
pt5.mp4
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 994 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn,
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
pt6.mp4
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 997 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn,
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Po przeczytaniu dokumentacji ffmpeg przekonwertuj pliki na ts, a następnie konkat:
ffmpeg -i pt1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts pt1.ts
...
ffmpeg -i pt6.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts pt6.ts
ffmpeg -i concat:"pt1.ts|pt2.ts|pt3.ts|pt4.ts|pt5.ts|pt6.ts" -c copy -bsf:a aac_adtstoasc output.mp4
Niestety plik wynikowy odmawia normalnej pracy, chociaż osobno pliki działają.
Oto dziennik konkatenacji:
Input #0, mpegts, from 'concat:pt1.ts|pt2.ts|pt3.ts|pt4.ts|pt5.ts|pt6.ts':
Duration: 00:33:11.57, start: 1.400000, bitrate: 7453 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 125 kb/s
[mp4 @ 0x12e3080] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x12e3080] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'output.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 854x480 [SAR 1:1 DAR 427:240], q=2-31, 23.98 fps, 23.98 tbr, 90k tbn, 90k tbc
Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 125 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x12e3080] Non-monotonous DTS in output stream 0:1; previous: 195910409, current: 195909909; changing to 195910410. This may result in incorrect timestamps in the output file.
[mp4 @ 0x12e3080] Non-monotonous DTS in output stream 0:1; previous: 301545749, current: 301545544; changing to 301545750. This may result in incorrect timestamps in the output file.
[mp4 @ 0x12e3080] Non-monotonous DTS in output stream 0:1; previous: 475343963, current: 475340939; changing to 475343964. This may result in incorrect timestamps in the output file.
[mp4 @ 0x12e3080] Non-monotonous DTS in output stream 0:1; previous: 475343964, current: 475341963; changing to 475343965. This may result in incorrect timestamps in the output file.
[mp4 @ 0x12e3080] Non-monotonous DTS in output stream 0:1; previous: 475343965, current: 475342987; changing to 475343966. This may result in incorrect timestamps in the output file.
frame=294625 fps=38748 q=-1.0 Lsize= 1645766kB time=03:18:14.48 bitrate=1133.5kbits/s
video:1449809kB audio:186316kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.589257%
Być może wynika to z innej liczby klatek na sekundę, pięciu klatek na sekundę 23,98 i jednej 29,97?