>> My goal is for ffmpeg to be running and listening on a network port, then 
>> from another machine to send the PNG sequence over the network directly into 
>> ffmpeg, and have the resulting video file saved.

>> So I need to work out how to configure ffmpeg to listen on the network for a 
>> sequence of PNG files, and I need to work out how to, from another machine, 
>> connect to ffmpeg, tell it what the output filename should be, and then 
>> transmit the PNG files.

>> Is there any way to do this?  Despite many hours research I can’t see if 
>> this is actually possible or not.

I’ll answer my own question as I worked it out eventually - maybe it will help 
someone else in the future.

The following command sets up ffmpeg to listen on a socket on port 8000, and 
when PNG images arrive, ffmpeg processes them.

ffmpeg -loglevel debug -framerate 60 -f image2pipe -i 
tcp://127.0.0.1:8000?listen=1 -c:v libvpx-vp9 -pix_fmt yuva420p ffmpeg.webm

You can test it with this Python script which reads all the png files from a 
directory and sends them to the socket, resulting in ffmpeg running its render 
and exiting.

import glob
path = '/home/ubuntu/tmp/*.png'
files=glob.glob(path)
import socket

TCP_IP = '127.0.0.1'
TCP_PORT =8000
BUFFER_SIZE = 1024

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
print('connection closed')
for file in files:
    f = open(file, 'rb')
    s.send(f.read())
    f.close()
s.close()



With the resulting output:

ubuntu@ip-10-0-0-196:~$ ffmpeg -y -framerate 60 -f image2pipe -i 
tcp://127.0.0.1:8000?listen=1 -c:v libvpx-vp9 -pix_fmt yuva420p ffmpeg.webm
ffmpeg version 2.8.14-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg 
developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 
--build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu 
--incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl 
--enable-shared --disable-stripping --disable-decoder=libopenjpeg 
--disable-decoder=libschroedinger --enable-avresample --enable-avisynth 
--enable-gnutls --enable-ladspa --enable-libass --enable-libbluray 
--enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite 
--enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme 
--enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg 
--enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger 
--enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex 
--enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis 
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 
--enable-libxvid --enable-libzvbi --enable-openal --enable-opengl 
--enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq 
--enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, image2pipe, from 'tcp://127.0.0.1:8000?listen=1':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 800x600, 60 fps, 60 tbr, 60 tbn, 60 tbc
Incompatible pixel format 'yuva420p' for codec 'libvpx-vp9', auto-selecting 
format 'yuv420p'
[libvpx-vp9 @ 0x2428e00] v1.5.0
Output #0, webm, to 'ffmpeg.webm':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: vp9 (libvpx-vp9), yuv420p, 800x600, q=-1--1, 200 kb/s, 
60 fps, 1k tbn, 60 tbc
    Metadata:
      encoder         : Lavc56.60.100 libvpx-vp9
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> vp9 (libvpx-vp9))
Press [q] to stop, [?] for help
[png @ 0x237e840] Invalid PNG signature 0xBA775E7E29DE8950.bitrate= 247.0kbits/s
Error while decoding stream #0:0: Invalid data found when processing input
frame=   98 fps= 18 q=0.0 Lsize=      42kB time=00:00:01.64 bitrate= 
208.8kbits/s
video:41kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: 2.742833%
ubuntu@ip-10-0-0-196:~$





_______________________________________________
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to