Capturing video using ffmpeg in source format

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Capturing video using ffmpeg in source format

Dhananjay Umap
Hi,

We want to capture the 4K video without ffmpeg scaling the video to 4K. The input signal is at HDMI 4K and the capture card is a 4K  card.
We want to capture the video without scaling introduced by ffmpeg to 4K i.e. if video stream is HD then HD video capture, if the video is 4K then 4K video would be captured.
Hence I prefer to use this command:
ffmpeg -f video4linux2 -i /dev/video0 -start_number 1 -vframes 250 -c:v mpeg4 -qscale:v 1 test1.avi

I am using SuSE Sled 12, kernel 4.4.73 kernel version. The installed rpm libraries for Video4Linux2 on our system.
libv4lconvert0-0.8.9-6.107.x86_64
libv4l-0.8.9-6.107.x86_64
libv4l-devel-0.8.9-6.107.x86_64
libv4l2-0-0.8.9-6.107.x86_64
libv4l1-0-0.8.9-6.107.x86_64

I believe the installed libraries support 4K content by default
./ffmpeg -f v4l2 -list_formats all -i /dev/video0
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8 (SUSE Linux)
  configuration: --enable-gpl --enable-version3 --enable-debug --enable-ffplay --enable-fontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libxvid
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[video4linux2,v4l2 @ 0x20a4980] Raw       :     yuyv422 :           YUYV 4:2:2 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :     uyvy422 :           UYVY 4:2:2 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :        nv12 :         Y/CbCr 4:2:0 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :     yuv420p :     Planar YVU 4:2:0 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :     yuv420p :     Planar YUV 4:2:0 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :       rgb24 :     24-bit RGB 8-8-8 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :        0rgb : 32-bit A/XRGB 8-8-8-8 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :       bgr24 :     24-bit BGR 8-8-8 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :        bgr0 : 32-bit BGRA/X 8-8-8-8 : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :        gray :      8-bit Greyscale : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       :    gray16le :     16-bit Greyscale : {48-4096, 1}x{32-2160, 1}
[video4linux2,v4l2 @ 0x20a4980] Raw       : Unsupported : 32-bit A/XYUV 8-8-8-8 : {48-4096, 1}x{32-2160, 1}
If I use the following command, I capture HD video with 25 fps:

ffmpeg -f video4linux2 -i /dev/video0 -start_number 1 -vframes 250 -c:v mpeg4 -qscale:v 1 test1.avi
As I can see below the rawvideo is at 1920x1080 format, but the input to the card is 4K as well as the card is 4K capable.
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 75555.202508, bitrate: 622080 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 622080 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, avi, to 'test.avi':
  Metadata:
    ISFT            : Lavf57.83.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1920x1080, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.107.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame=   44 fps= 25 q=1.0 Lsize=    5607kB time=00:00:01.76 bitrate=26097.0kbits/s speed=1.01x
video:5600kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.117881%
Exiting normally, received signal 2.

If I use the following command, I capture 4K video with 25 fps.
./ffmpeg -f video4linux2 -i /dev/video0 -s 3840x2160 -start_number 1 -vframes 250 -c:v mpeg4 -qscale:v 1 test.avi
In this case scaling is performed by the ffmpeg to 4K which affects the KPI of the captured video. This also affect the speed of the capture since ffmpeg is processing the video to 4K during capture which eventually affects the KPI for the captured video.
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 73446.222527, bitrate: 622080 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 622080 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, avi, to 'netflixtest4.avi':
  Metadata:
    ISFT            : Lavf57.83.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 3840x2160, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.107.100 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame=   32 fps= 11 q=1.0 Lsize=    7127kB time=00:00:01.28 bitrate=45610.7kbits/s speed=0.45x
video:7120kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.088695%

Q: How can I capture a video in default format at which it is transmitted without ffmpeg upscaling downscaling the captured content?
     The default format meaning if its HD video then HD capturing and if it is 4K video then 4K capture. No processing done by ffmpeg during the capture of the video content.

Kind Regards

Dhananjay Umap
Software Engineer




--
SIGOS
Klingenhofstrasse 50d
90411 Nuernberg
GERMANY

Tel.: +49 911 95168-0
www.sigos.com<http://www.sigos.com>

HRB 9323 Nuernberg
Gerichtsstand: Nuernberg
Geschaeftsfuehrer: Adil Kaya, John van Siclen, Kevin Burns

Follow us on: linkedin<https://www.linkedin.com/company/253905?trk=tyah&trkInfo=clickedVertical%3Acompany%2CclickedEntityId%3A253905%2Cidx%3A2-1-2%2CtarId%3A1453450966999%2Ctas%3Asigos> | xing<https://www.xing.com/companies/sigosgmbh/> | twitter<https://twitter.com/sigos_global/> | facebook<https://www.facebook.com/sigos.global/>

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Capturing video using ffmpeg in source format

Moritz Barsnick
On Wed, Dec 06, 2017 at 15:58:28 +0000, Dhananjay Umap wrote:

> ffmpeg -f video4linux2 -i /dev/video0 -start_number 1 -vframes 250 -c:v mpeg4 -qscale:v 1 test1.avi
> As I can see below the rawvideo is at 1920x1080 format, but the input to the card is 4K as well as the card is 4K capable.

> If I use the following command, I capture 4K video with 25 fps.
> ./ffmpeg -f video4linux2 -i /dev/video0 -s 3840x2160 -start_number 1 -vframes 250 -c:v mpeg4 -qscale:v 1 test.avi
> In this case scaling is performed by the ffmpeg to 4K which affects
> the KPI of the captured video. This also affect the speed of the
> capture since ffmpeg is processing the video to 4K during capture
> which eventually affects the KPI for the captured video.

You need to tell the v4l2 device to choose the correct input
resolution. The input option "-video_size <resolution>" should work.
(You may also want to choose the correct "-pixel_format".)

Yet even then, ffmpeg will convert 3840x2160 (raw) to 3840x2160
(mpeg4), and take about as much CPU as when it does soft upscaling
1920x1080 -> 3840x2160). Only that the quality will be better. You need
to find encoding settings which are faster (at the cost of quality or
size/compression ratio). With x264, I would try various presets, such
as "-preset fast". I'm not sure what to do for the mpeg4 codec, Google
or others on this list should help you. The default of 200 kb/s is
probably the issue, I'm guessing that the codec many be trying really
hard to compress the hell out of your HD images (and won't succeed).

Cheers,
Gruß nach Nürnberg,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Capturing video using ffmpeg in source format

Carl Eugen Hoyos-2
2017-12-07 16:25 GMT+01:00 Moritz Barsnick <[hidden email]>:

> I'm not sure what to do for the mpeg4 codec, Google
> or others on this list should help you. The default of 200 kb/s is
> probably the issue, I'm guessing that the codec many be trying really
> hard to compress the hell out of your HD images (and won't succeed).

Since -qscale 1 was specified, (default) bitrate is no issue, the
video is encoded with near-lossless quality.
Note that old MEncoder documentation suggested to always
use -qscale 2 instead -qscale 1.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".