0

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!

fmagno
  • 1,446
  • 12
  • 27
  • Does vid.mp4 have moov at front? If not, run `ffmpeg -i vid.mp4 -c copy -movflags +faststart newvid.mp4` and check. – Gyan Mar 12 '19 at 17:38
  • @Gyan, The atoms of vid.mp4 are listed here: https://pastebin.com/U3PWLGvq I am not really sure on how to read it so I ran the command you suggested anyway, which produces newvid.mp4 with the following atoms file: https://pastebin.com/wJ2q8DD9 I reran the experiment but the result was exactly the same: `ffplay` starts playing only when command 2. reaches the end. – fmagno Mar 12 '19 at 20:02

1 Answers1

1

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.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • 1
    Share full log of ffplay attempt. – Gyan Mar 13 '19 at 16:06
  • 1
    Share full log of failing attempt – Gyan Mar 14 '19 at 20:00
  • First approach works well: `ffplay ./pipe_in`. Second approach not really: `ffplay -read_ahead_limit 65K cache:./pipe_in`. The behavior is the same as before which means `ffplay` will only start decoding when `cat vid.mp4 | pv -L 150k > pipe_in` finishes running. This is the log I get: https://0bin.net/paste/L+tVEYx2c43jDyE8#7DmJKWsEBsPshoCOgX0rjKpm-/UeaCb6JssoCnS69Sf (I'm deleting the previous comments to avoid confusion) – fmagno Mar 15 '19 at 14:10