[edited]
Alright, scratch what I said earlier...
You should be able to use [the `tee` muxer](http://ffmpeg.org/ffmpeg-formats.html#tee-1) to save the file and pipe the encoded frames to another ffmpeg process. Something like this should work for you:
ffmpeg -i original.mp4 -crf 27 -s 640x480 -f tee "out.mp4 | [f=mp4]-" \
| ffmpeg -i - -i original.mp4 -filter_complex ...
(make them into 2 lines and remove \
for Windows)
Here is what works on my Windows PC (thanks to @Rotem for his help)
ffmpeg -i in.mp4 -vcodec libx264 -crf 27 -f nut pipe:
|
ffmpeg -i in.mp4 -f nut -i pipe:
-filter_complex "[0:v][1:v]libvmaf=log_fmt=json:log_path=log.json,nullsink"
-map 1 -c copy out.mp4
The main issue that @Rotem and I missed is that we need to terminate the libvmaf
's output. Also, h264
raw format does not carry header info, and using `nut alleviates that issue.
There are a couple caveats:
testing with the testsrc
example that @Rotem suggested in the comment below does not produce any libvmaf
log, at least as far as I can see, but in debug
mode, you can see the filter is getting initialized.
You'll likely see [nut @ 0000026b123afb80] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
message in the log. This just means that the frames are piped in faster than the 2nd ffmpeg is processing. FFmpeg does block on both ends, so no info should be lost.
For the full disclosure, I posted my Python test script on GitHub. It just runs the shell command, so it should be easy to follow even if you don't do Python.