On Mon, Sep 11, 2017 at 12:43 PM, Daniel <[email protected]> wrote: > Hello everyone > > I am trying to stream my webcam to youtube. Here is the command i use: > > ffmpeg -re -f v4l2 -input_format mjpeg -s 640x480 -hwaccel cuvid -c:v > mjpeg_cuvid -i /dev/video1 -c:v libx264 -an -f flv rtmp:// > a.rtmp.youtube.com/live2/key > and the error i get : > > ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers > built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609 > configuration: --enable-gpl --enable-libass --enable-libfdk-aac > --enable-libfreetype --enable-libmp3lame --enable-libopus > --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 > --enable-libx265 --enable-nonfree --enable-cuda --enable-cuvid > --enable-nvenc --bindir=/usr/bin > libavutil 55. 58.100 / 55. 58.100 > libavcodec 57. 89.100 / 57. 89.100 > libavformat 57. 71.100 / 57. 71.100 > libavdevice 57. 6.100 / 57. 6.100 > libavfilter 6. 82.100 / 6. 82.100 > libswscale 4. 6.100 / 4. 6.100 > libswresample 2. 7.100 / 2. 7.100 > libpostproc 54. 5.100 / 54. 5.100 > Input #0, video4linux2,v4l2, from '/dev/video1': > Duration: N/A, start: 8778.032889, bitrate: N/A > Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), > 640x480, 30 fps, 30 tbr, 1000k tbn, 1000k tbc > Stream mapping: > Stream #0:0 -> #0:0 (mjpeg (mjpeg_cuvid) -> h264 (libx264)) > Press [q] to stop, [?] for help > [mjpeg_cuvid @ 0x2b31700] ignoring invalid SAR: 0/0 > Impossible to convert between the formats supported by the filter > 'Parsed_null_0' and the filter 'auto_scaler_0' >
This above message tells you there is a problem changing pixel formats. You've commanded for "-hwaccel cuvid" so pixel format is cuda coming out of the hw-decoder, but libx264 does not support cuda pixel format. If you increased your verbosity, you would see that more clearly. You have a few options. I don't know if youtube supports yuvj422p (which it looks like your input is), I believe they recommend yuv420p for h264. You should investigate further if they support yuvj422p if you want to use that. I will include some examples, change them to fit your exact case: 1. Do not use "-hwaccel cuvid". It will still decode the frames in hw, but ffmpeg will be working with frames in main/system RAM and not GPU RAM. This first one ouptuts yuv420p ffmpeg -c:v mjpeg_cuvid -i foo.mkv -c:v libx264 -an bar-yuv420p.mkv ffmpeg -c:v mjpeg_cuvid -i foo.mkv -c:v libx264 -pix_fmt yuvj422p -an bar-yuvj422p.mkv 2. Use a filter to download frames from GPU RAM and change the pixel format. This is basically like the first option, decode in hw and download frames to main memory. You have to specify format because libx264 does not support cuda pixel format. NV12 is the only common format between those two. ffmpeg -hwaccel cuvid -c:v mjpeg_cuvid -i foo.mkv -c:v libx264 -filter:v "hwdownload,format=nv12" -an bar-yuv420p.mkv ffmpeg -hwaccel cuvid -c:v mjpeg_cuvid -i foo.mkv -c:v libx264 -filter:v "hwdownload,format=nv12" -pix_fmt yuvj422p -an bar-yuvj422p.mkv 3. Use full hw transcoding (NVenc does not support yuvj422p so you'll have to decide what format is best for you): ffmpeg -hwaccel cuvid -c:v mjpeg_cuvid -i foo.mkv -c:v h264_nvenc -an bar-yuv420p.mkv To chance pixel format (this does pixel format conversion in sw, so it might be slower and use a lot of system resources): ffmpeg -hwaccel cuvid -c:v mjpeg_cuvid -i foo.mkv -c:v h264_nvenc -filter:v "hwdownload,format=nv12,format=yuv444p,hwupload_cuda" -an bar-yuv444p.mkv 4. Use full sw transcoding (this might be just as fast as hw->sw transcoding. Decoding on modern cpu is fast, but it does use more system resources.) ffmpeg -i foo.mkv -c:v libx264 -an bar-yuv420p.mkv ffmpeg -i foo.mkv -c:v lib264 -pix_fmt yuvj422p -an bar-yuvj422p.mkv > Error reinitializing filters! > Failed to inject frame into filter network: Function not implemented > Error while processing the decoded data for stream #0:0 > [video4linux2,v4l2 @ 0x2b2f9a0] Some buffers are still owned by the caller > on close. > Conversion failed! > > > if anyone has idea how to stream the webcam and what i am doing wrong > please let me know. > _______________________________________________ ffmpeg-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
