2

I'm working on a transcoder backend to a project that intends to serve static mpeg-dash manifests and files for a frontend player. And I'm trying to figure out how I can get multiple outputs into multiple pipes from ffmpeg.

One of the backend routes takes in a video file and uses ffmpeg to convert that video file into multiple mpeg-dash representations. I've already got a command working to convert a given mp4 into a manifest, 2 video representations, and 1 audio representation, using the sample command from ffmpeg's wiki:

 ffmpeg -re -i input.mp4 -c:a aac -c:v libx264 -map 0 -map 0 -b:v:0 800k -b:v:1 300k -s:v:1 320x170 -bf 1 -keyint_min 120 -g 120 -sc_threshold 0 -b_strategy 0 -ar:a:1 22050 -use_timeline 1 -use_template 1  -adaptation_sets "id=0,streams=v id=1,streams=a" -single_file 1 -f dash output.mpd

The problem I face is: How do I get the output of this ffmpeg command into pipes instead of files?

1
  • That gives: [NULL @ 0x557c065d3fc0] Unable to find a suitable output format for 'pipe1' [tee @ 0x557c03843a40] Slave muxer #0 failed, aborting.
    – Killpot
    Commented Feb 2, 2023 at 2:49

1 Answer 1

1

For anyone in a similar situation to me of wanting to make a server that transcodes videos uploaded to it, I found a pretty good solution, but it doesn't involve pipes like I originally thought would be best.

As it turns out ffmpeg automatically handles filenames being http urls, so by making a few internal routes for reading/writing objects from a minio bucket, I was able to get this to work.

My final command ended up being something like:

ffmpeg -re -i http://localhost:8080/read/input.mp4 \
  -c:a aac \
  -c:v libx264 \
  -map 0 -map 0 \
  -b:v:0 800k \
  -b:v:1 300k \
  -s:v:1 320x170 \
  -bf 1 \
  -keyint_min 120 \
  -g 120 \
  -sc_threshold 0 \
  -b_strategy 0 \
  -ar:a:1 22050 \
  -use_timeline 1 \
  -use_template 1  \
  -adaptation_sets "id=0,streams=v id=1,streams=a" \
  -single_file 1 \
  -f dash http://localhost:8080/write/output.mpd

This causes all the output streams to make requests to urls like: http://localhost:8080/write/output-stream1.mp4 etc.

An important note is that your read route must support byte ranges for file types (like mp4) that need to be seekable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .