0

I am using the following command to use my Nikon as a webcam:

sudo modprobe v4l2loopback && gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2

This works like a charm:

ffmpeg version N-49161-g50e194e6e1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.101 / 58. 28.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
[mjpeg @ 0x6d15940] Format mjpeg detected only with low score of 25, misdetection possible!
Input #0, mjpeg, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 640x426, 25 tbr, 1200k tbn, 25 tbc

However the max resolution for this is 640x426 I would love to be able to use larger formats if possible?

1 Answer 1

0

Since you have rawvideo as input, you must tell ffmpeg the frame size. Problem is, that the raw video codec data does not necessarily contain the dimensions of a frame.

So the ffmpeg part of your call could look like this:

ffmpeg -video_size 1024x780 -i - -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video2

I've omitted the threads parameter in order to let ffmpeg use all available threads and added -s 1024x780 as an example for a frame size - which you can substitute to the real size of the raw stream.

More infos here

3
  • The input is not rawvideo but a raw mjpeg stream. Your -s parameter will rescale the input. What the OP wants is to procure a larger frame from the source. This will require configuration changes in the camera and/or gphoto2 if at all possible.
    – Gyan
    Jun 28, 2020 at 5:53
  • Well, the ffmpeg doc distinguishes between input and output parameters. Quote: "As an input option, this is a shortcut for the video_size private option, recognized by some demuxers for which the frame size is either not stored in the file or is configurable – e.g. raw video or video grabbers." - But you are right: I've borked the command and will correct it....
    – kanehekili
    Jun 28, 2020 at 21:19
  • Thank you both :) Interesting it says the option was not found: Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort. [mjpeg @ 0x663b8c0] Format mjpeg detected only with low score of 25, misdetection possible! Option video_size not found. But I can also see it clearly in the documentation Jun 28, 2020 at 21:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .