4

I've attempted to concatenate 2 mkv videos with ffmpeg, using the following commands:

ffmpeg -i file-01.mkv -f mpegts -c copy -bsf:v h264_mp4toannexb file-01.mpeg.ts
ffmpeg -i file-02.mkv -f mpegts -c copy -bsf:v h264_mp4toannexb file-02.mpeg.ts
ffmpeg -isync -i "concat:file-01.mpeg.ts|file-02.mpeg.ts" -f matroska
-c copy output.mkv

However, I receive the following error:

[matroska @ 0x7fc72a000600] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly [matroska @ 0x7fc72a000600] Can't write packet with unknown timestamp av_interleaved_write_frame(): Invalid argument

How do I go about setting the timestamps?

a-goonie
  • 99
  • 1
  • 10

2 Answers2

2

Not necessarily a solution, per se, but mkvmerge worked for me in the end. Was much simpler, too:

mkvmerge -o "merged.mkv" "file1.mkv" +"file2.mkv"
a-goonie
  • 99
  • 1
  • 10
0

Ok, try these steps:

ffmpeg -i file-01.mkv -c copy -map v 01.mp4
ffmpeg -i file-02.mkv -c copy -map v 02.mp4
ffmpeg -i 01.mp4 -i file-01.mkv -map 0:v -map 1:a -c copy -bsf:v h264_mp4toannexb file-01.mpeg.ts
ffmpeg -i 02.mp4 -i file-02.mkv -map 0:v -map 1:a -c copy -bsf:v h264_mp4toannexb file-02.mpeg.ts
ffmpeg -i "concat:file-01.mpeg.ts|file-02.mpeg.ts" -f matroska
-c copy output.mkv

Some H.264 streams have packets with no PTS values. FFmpeg has haphazard support for muxing these streams.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Still not working, @Mulvya. Same erros resulting in failed conversion: `[matroska @ 0x7f869c000000] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly [matroska @ 0x7f869c000000] Can't write packet with unknown timestamp av_interleaved_write_frame(): Invalid argument frame= 1143 fps=0.0 q=-1.0 Lsize= 8381kB time=00:00:45.60 bitrate=1505.7kbits/s speed= 667x video:7857kB audio:528kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Conversion failed!` – a-goonie Jan 22 '17 at 09:37
  • Upload the files. – Gyan Jan 22 '17 at 09:45
  • I ended up using mkvmerge instead. Had no issues. Much simpler. – a-goonie Jan 29 '17 at 02:32