Body: <p>Is there a way one can compress captured video input before saving to file? I have raspberry pi that I am using to record youtube videos. 1-2 min video takes over a Gb of space. I cant compress the recorded file because the pi does not have enough space to record the initial video. Is there a way using ffmpeg I can compress my webcam video directly after its captured before saving the file versus waiting until I am done recording then compressing the saved file?</p>
  
  <p>I'm using </p>
  
  <p><code>ffmpeg \ -f v4l2 \ -thread_queue_size 5000 -framerate 25 -video_size 640x480 -i /dev/video0 -y -c:v libx264 ~/Desktop/ffmpegTesting/money.mp4 \ -thread_queue_size 5000 -f alsa -ac 1 -ar 44100 -i hw:1,0 -t 30 -c:v copy -c:a ~/Desktop/ffmpegTesting/money.mp4 \</code></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T20:37:07.473Z
Comments.Text: Ive managed to compress before saving but the audio is disapearring now :(
Comments.UserDisplayName: sirshakir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T20:38:05.667Z
Comments.Text: to be more exact. The audio disappears around the 10-11 second mark in the video
Comments.UserDisplayName: sirshakir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T20:53:40.327Z
Comments.Text: Syntax is malformed, it should be: `ffmpeg -f v4l2 -thread_queue_size 5000 -framerate 25 -video_size 640x480 -i /dev/video0 -thread_queue_size 5000 -f alsa -i hw:1,0 -c:v libx264 -ac 1 -ar 44100 -c:a aac -y ~/Desktop/ffmpegTesting/money.mp4`
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T20:59:18.197Z
Comments.Text: The error I am getting now is :  cannot set channel count to 2 (Invalid argument)
  hw:1,0: Input/output error
Comments.UserDisplayName: sirshakir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T21:23:35.520Z
Comments.Text: Ok i fixed problem by setting hw:1,0 to plughw:1,0
Comments.UserDisplayName: sirshakir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T21:23:42.953Z
Comments.Text: ffmpeg -f v4l2 -thread_queue_size 5000 -framerate 25 -video_size 640x480 -i /dev/video0 -thread_queue_size 5000 -f alsa -i plughw:1,0 -c:v libx264 -ac 2 -ar 44100 -c:a aac -y ~/Desktop/ffmpegTesting/money.mp4
Comments.UserDisplayName: sirshakir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T21:24:03.967Z
Comments.Text: The audio still times out before the video ends
Comments.UserDisplayName: sirshakir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-09T21:28:37.017Z
Comments.Text: After further testing it appears the audio always times out a 4 - 5 seconds before the video ends no matter the length of video. Im starting to belive it has somehting to do when I stop the process. Maybe there is a lag between the video being compressed and adding the audio to it.
Comments.UserDisplayName: sirshakir
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-10T04:49:31.770Z
Comments.Text: How are you ending the process?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-11T19:51:44.097Z
Comments.Text: Either by pressing Q or Ctrl C
Comments.UserDisplayName: sirshakir
Tags: <ffmpeg><compression>
Title: ffmpeg video compression : Compress captured video being before saving to file
UserDisplayName: sirshakir
ThreadText: # ffmpeg video compression : Compress captured video being before saving to file
  
  (Asked by: username_0 on 2019-02-09)
  
  Is there a way one can compress captured video input before saving to file? I have raspberry pi that I am using to record youtube videos. 1-2 min video takes over a Gb of space. I cant compress the recorded file because the pi does not have enough space to record the initial video. Is there a way using ffmpeg I can compress my webcam video directly after its captured before saving the file versus waiting until I am done recording then compressing the saved file?
  
  I'm using
  
  `ffmpeg \ -f v4l2 \ -thread_queue_size 5000 -framerate 25 -video_size 640x480 -i /dev/video0 -y -c:v libx264 ~/Desktop/ffmpegTesting/money.mp4 \ -thread_queue_size 5000 -f alsa -ac 1 -ar 44100 -i hw:1,0 -t 30 -c:v copy -c:a ~/Desktop/ffmpegTesting/money.mp4 \`
  
  **Tags:** ffmpeg, compression
  
  > **Comments:**
  > **username_0**: Ive managed to compress before saving but the audio is disapearring now :(  
  > **username_0**: to be more exact. The audio disappears around the 10-11 second mark in the video  
  > **username_1**: Syntax is malformed, it should be: `ffmpeg -f v4l2 -thread_queue_size 5000 -framerate 25 -video_size 640x480 -i /dev/video0 -thread_queue_size 5000 -f alsa -i hw:1,0 -c:v libx264 -ac 1 -ar 44100 -c:a aac -y ~/Desktop/ffmpegTesting/money.mp4`  
  > **username_0**: The error I am getting now is :  cannot set channel count to 2 (Invalid argument) hw:1,0: Input/output error  
  > **username_0**: Ok i fixed problem by setting hw:1,0 to plughw:1,0  
  > **username_0**: ffmpeg -f v4l2 -thread_queue_size 5000 -framerate 25 -video_size 640x480 -i /dev/video0 -thread_queue_size 5000 -f alsa -i plughw:1,0 -c:v libx264 -ac 2 -ar 44100 -c:a aac -y ~/Desktop/ffmpegTesting/money.mp4  
  > **username_0**: The audio still times out before the video ends  
  > **username_0**: After further testing it appears the audio always times out a 4 - 5 seconds before the video ends no matter the length of video. Im starting to belive it has somehting to do when I stop the process. Maybe there is a lag between the video being compressed and adding the audio to it.  
  > **username_1**: How are you ending the process?  
  > **username_0**: Either by pressing Q or Ctrl C  
  
  ---
  
  ## 0 answers
  
  