[FFmpeg-user] how to record stream and take pictures at once?

erwin mueller erwin12344321 at yahoo.de
Wed May 22 20:47:31 EEST 2019


 Thanks for this great hint.
Now I have a different issue.
With this command 

I receive three files and a movie of 6 seconds. But recording is very slow ... 20 seconds are nearly 60s. And it is not stopping after 30 seconds ....
Command
ffmpeg -i "http://192.168.100.111:9000/?action=stream", -vcodec copy -an -t 00:00:07 -bufsize 2048k y Klingel.mp4 -f image2 -vf fps=1/10 "img%03d.jpg"

Output:MJPG Streamer Version: svn rev: 3:172M
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 1024 x 768
 i: Frames Per Second.: 24
 i: Format............: YUV
 i: JPEG Quality......: 80
 o: www-folder-path...: /usr/local/www/
 o: HTTP TCP port.....: 9000
 o: username:password.: disabled
 o: commands..........: disabled
 o: output folder.....: /home/pi/cam
 o: input plugin.....: 0: /usr/local/lib/input_uvc.so
 o: delay after save..: 12000
 o: ringbuffer size...: no ringbuffer
 o: command...........: disabled
ffmpeg version 3.2.12-1~deb9u1+rpt1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1+rpt1' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libfbfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libo-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-liibspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack  --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-omx-rpi --enable-mmal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --arch=armhf --enable-chromaprint --enable-frei0r --en-enable-libx264 --enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, mpjpeg, from 'http://192.168.100.111:9000/?action=stream':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1024x768 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 t
Output #0, mp4, to '/home/pi/cam/Klingel-20190522_193744.mp4':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0: Video: mjpeg (l[0][0][0] / 0x006C), yuvj420p(pc, bt470bg/unknown/unknown), 1024x768 [SAR 1:1 DAR 4:3], 12800 tbn, 25 tbc
Output #1, image2, to '/home/pi/cam/img%03d.jpg':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #1:0: Video: mjpeg, yuvj420p(pc), 1024x768 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 0.10 fps, 0.10 tbn, 0.10 tb
    Metadata:
      encoder         : Lavc57.64.101 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:0 -> #1:0 (mjpeg (native) -> mjpeg (native))
Press [q] to stop, [?] for help
setting signal to stop-1.0 q=1.6 size=    5950kB time=00:00:30.00 bitrate=1624.7kbits/s speed=0.224x
Traceback (most recent call last):
  File "ring.py", line 110, in <module>
    main()
  File "ring.py", line 105, in main
    record(ring_count)
  File "ring.py", line 77, in record
    record.wait()
  File "/usr/lib/python2.7/subprocess.py", line 1073, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/usr/lib/python2.7/subprocess.py", line 121, in _eintr_retry_call
    return func(*args)
KeyboardInterrupt
 i: cleaning up ressources allocated by input thread
frame=  174 fps=1.3 q=-1.0 Lq=1.6 size=    5951kB time=00:00:30.00 bitrate=1625.1kbits/s speed=0.223x






    Am Montag, 20. Mai 2019, 23:13:50 MESZ hat Carl Eugen Hoyos <ceffmpeg at gmail.com> Folgendes geschrieben:  
 
 Am Mo., 20. Mai 2019 um 22:56 Uhr schrieb erwin mueller via
ffmpeg-user <ffmpeg-user at ffmpeg.org>:

> I want to record a webcam stream for 30 seconds and at the same time I want to take 3 pictures (second 1, 15 and 30)
> I treid this command, fired with a pythn script:
> ffmpeg -i "http://192.168.100.111:9000/?action=stream" -vcodec copy -an -t 30 -bufsize 2048k -y "/home/pi/cam/Klingel-$(date +"%y_%m_%d_%H_%M_%S").mp4" -i  "/home/pi/cam/Klingel-$(date +"%y_%m_%d_%H_%M_%S").mp4" -f image2 -vf fps=1/10 img%03d.jpg
> but this is first recording a mp4 and then taking pictures. Is it possible to have it in parallel?

(Complete, uncut console output missing.)

Just remove "-i Klingel", ffmpeg can produce multiple outputs from one input.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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


More information about the ffmpeg-user mailing list