1

I have a file that has multiple WebM(vp9/opus) streams stitched together sequentially.

When trying to play it through regular media players it stops at the end of 1st stream in the sequence.

When used with FFMPEG for transcoding it to MP4, the trancoding stops at the end of first stream.

Using FFMPEG is it possible to make a regular WebM(vp9/opus) file from a file that contains multiple WebM(vp9/opus) stitched together sequentially?

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
thedeadalive
  • 35
  • 1
  • 6
  • You could try to use `-ss`and `-t`to select a specific part of your video corresponding to a single stream. [Documentation for main options including -t and -ss](https://ffmpeg.org/ffmpeg.html#toc-Main-options) [An example in another question](https://superuser.com/questions/377343/cut-part-from-video-file-from-start-position-to-end-position-with-ffmpeg) – Jao Sep 08 '20 at 13:12
  • Thanks for the comment and suggestion! I could try that, but the end goal i'm trying to achieve is to process a stream of data of the nature explained in the question above, so the solution i was looking out for is to tweak the trancoder to accommodate the varying nature of the stream. – thedeadalive Sep 08 '20 at 13:54
  • I assume you don't have the original WebMs anymore. Are you working with a file or data stream i.e. is the input seekable and persistent? – Gyan Sep 08 '20 at 17:35
  • @Gyan i do have file containing the multiple streams stitched together for testing – thedeadalive Sep 08 '20 at 19:01

1 Answers1

1

You cannot achieve this with ffmpeg command line, but if you are writing your own transcoder based on ffmpeg libraries (avformat and avcodec), you can use a custom AVIOContext; when the first stream is finished, your context handler will know the file offset; now, you can skip forward until you come across the next 1a 45 df a3 marker, and open the next 'input file' at this position.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Thanks a lot for the response! If you have any pointers towards a sample implementation for referring to it would be great! – thedeadalive Sep 09 '20 at 09:14
  • I would start with the official [transcode](https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/transcoding.c) example. [Here](https://github.com/alexcohn/mobile-ffmpeg/commit/0c8aaa72cbf7684598e50d92f929a437b326542c) you can see how a custom AVIOContext can be introduced. *You don't need the fd-specific logic there, but I would suggest to do all your work with **stdin**, then you don't care which input file to open*. – Alex Cohn Sep 09 '20 at 11:21