FFMPEG: Transmux mpegts to mp4 gives error: muxer does not support non seekable output

Kr0e picture Kr0e · Dec 6, 2015 · Viewed 11.4k times · Source

When piping mpegts to ffmpeg, which should convert it to mp4 and pipe to stdout, ffmpeg says: "muxer does not support non seekable output".

After a lot of research I came to the conclusion that mp4 is a bad choice for doing those kinds of on-the-fly transcoding due to seeking. So in essence: MP4 cannot be piped through ffmpeg, which kind of makes sense.

But I do not have a contiguous mpegts stream, I have chunks of 5 seconds. So it's really just like:

  • Here is my 1 mb *.ts file
  • Please read it from pipe until you hit EOF
  • Please transmux it to mp4 (if you really have to seek, well use a buffer)
  • Please pipe the complete internal mp4 buffer to stdout

I need these mp4 chunks for a HTML5 MediaSource, the fragmentation is no problem, I use mp4box.js, which works like a charm.

Questions:

  • Can FFMPEG do this kind of internal buffering ?
  • Is there any better option to consider ?

In essence: Can I (somehow) interact with ffmpeg without using files ? My current solutions works with files and polling for new chunks, which is ugly.

If you are interested in my ffmpeg command, just let me know.

Answer

aergistal picture aergistal · Dec 7, 2015

Since you mentioned fragmentation then you can just enable it with movflags. Example for fragments starting on each keyframe:

ffmpeg -i segment.ts -c copy -movflags frag_keyframe+empty_moov -f mp4 -

Having an empty moov atom means it doesn't need to seek and thus works with a pipe.