{"id":9175,"date":"2025-02-23T05:05:00","date_gmt":"2025-02-23T04:05:00","guid":{"rendered":"https:\/\/andyland.info\/wordpress\/?p=9175"},"modified":"2025-02-08T20:09:00","modified_gmt":"2025-02-08T19:09:00","slug":"use-ffmpeg-to-record-from-usb-webcam-pipe-output-to-replay","status":"publish","type":"post","link":"https:\/\/andyland.info\/wordpress\/use-ffmpeg-to-record-from-usb-webcam-pipe-output-to-replay\/","title":{"rendered":"Use FFmpeg to record from webcam, pipe output to FFplay"},"content":{"rendered":"\n<p>This code will record the video which is grabbed from an USB webcam and save it to a file. In parallel, it will output a preview to your screen by piping ffmpeg&#8217;s output into ffplay. The code is tested on a Raspberry Pi 5, the webcam in question is a Logitec c920. The output to screen has some noticeable lag and low resolution but it&#8217;s enough to help as a control.<\/p>\n<p>\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -y -f v4l2 -input_format mjpeg -video_size 1280x720 -framerate 30 -i \/dev\/video0 -vcodec libx264 -an output.mp4 -f nut - | ffplay -i -<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This code will record the video which is grabbed from an USB webcam and save it to a file. In parallel, it will output a preview to your screen by piping ffmpeg&#8217;s output into ffplay. The code is tested on a Raspberry Pi 5, the webcam in question is a \u2026 <a class=\"continue-reading-link\" href=\"https:\/\/andyland.info\/wordpress\/use-ffmpeg-to-record-from-usb-webcam-pipe-output-to-replay\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[24,21],"tags":[485,469,483,484,486,58],"class_list":["post-9175","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","category-video","tag-c920","tag-ffmpeg","tag-ffplay","tag-logitec","tag-preview","tag-raspberry-pi-2","odd"],"_links":{"self":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/9175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/comments?post=9175"}],"version-history":[{"count":12,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/9175\/revisions"}],"predecessor-version":[{"id":9207,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/9175\/revisions\/9207"}],"wp:attachment":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/media?parent=9175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/categories?post=9175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/tags?post=9175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}