Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown V4L2 pixel format equivalent for yuvj420p

I am trying to pipe a mp4 video located in Videos/video.mp4 to a virtual webcam device located at /dev/video0.

I tried running: ffmpeg -re -i Videos/video.mp4 -map 0:v -f v4l2 /dev/video0 and I keep getting the following error:

[video4linux2,v4l2 @ 0x5580cf270100] Unknown V4L2 pixel format equivalent for yuvj420p
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- 
Conversion failed!

Full log:

ffmpeg version 4.2.2-1+b1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Debian 9.2.1-28)
  configuration: --prefix=/usr --extra-version=1+b1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Videos/video.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2020-03-23T04:24:01.000000Z
    com.android.version: 8.1.0
  Duration: 00:01:00.14, start: 0.000000, bitrate: 20048 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080, 19898 kb/s, SAR 1:1 DAR 16:9, 29.43 fps, 29.58 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 270
      creation_time   : 2020-03-23T04:24:01.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of 90.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
    Metadata:
      creation_time   : 2020-03-23T04:24:01.000000Z
      handler_name    : SoundHandle
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[video4linux2,v4l2 @ 0x5580cf270100] Unknown V4L2 pixel format equivalent for yuvj420p
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- 
Conversion failed!

The desired result is that the mp4 video is seen by apps that try to view the webcam. I am running this on a desktop without a webcam or video interface, which is why I am using /dev/video0

like image 272
c10ud Avatar asked Dec 22 '22 18:12

c10ud


1 Answers

Add -vf format=yuv420p (or the alias -pix_fmt yuv420p).

The v4l2 output device doesn't support yuvj420p which is the pixel format of your input. In most cases ffmpeg will automatically choose a supported pixel format, but it is unable to do so for V4L2 output, so you have to manually do it:

ffmpeg -re -i Videos/video.mp4 -map 0:v -vf format=yuv420p -f v4l2 /dev/video0
like image 140
llogan Avatar answered Dec 28 '22 08:12

llogan