Streaming video over named PIPE with limited "channel" bandwidth

451 Views Asked by At

I have a video container vid.mp4 that I want to play with ffplay through a named PIPE and be able to tweak the maximum bandwidth allowed by the "channel". Follows what I did:

1. Create a named PIPE:

mkfifo pipe_in

2. Send the container to the pipe with a limited bandwidth (150kB/s) with the help of pipe viewer pv:

cat vid.mp4 | pv -L 150k > pipe_in

3. Play the video with ffplay:

ffplay cache:./pipe_in

My expectation: To watch the video come through immediately but slowly given the bandwidth constraint.

What really happens: The video begins to show at normal speed only when command 2. finishes running.

Thank you in advance!

1

There are 1 best solutions below

3
On BEST ANSWER

Your video will need to have MOOV box upfront.

ffmpeg -i vid.mp4 -c copy -movflags +faststart newvid.mp4

Now, you should get as-available playback with

ffplay ./pipe_in

If you wish to use the cache protocol, you'll need to set a cache limit.

ffplay -read_ahead_limit 65K cache:./pipe_in

If the option isn't found, upgrade ffplay.