Resizing Video with FFmpeg
TODO: collapasable, copyable, download, etc
With ffmpeg, how can i resize video down? Please be breif and offer 380p, 420p, 720p examples (LD, SD, HD)With FFmpeg, you can resize a video using the -vf
flag followed by the scale
video filter. Here's a brief example for each resolution you mentioned:
- 380p (Low Definition):
ffmpeg -i input_video.mp4 -vf "scale=-1:380" output_video_380p.mp4
- 480p (Standard Definition):
ffmpeg -i input_video.mp4 -vf "scale=-1:480" output_video_480p.mp4
- 720p (High Definition):
ffmpeg -i input_video.mp4 -vf "scale=-1:720" output_video_720p.mp4
In these examples, -1
is used as the width value, which automatically calculates the width based on the specified height to maintain the aspect ratio. Replace input_video.mp4
with your source video file name and output_video_<resolution>p.mp4
with your desired output file name.Did you make 380p up? What are the common formats? I see 320Apologies for the confusion. You are correct; 380p is not a standard video resolution. I misunderstood your original question. Here are the common video resolutions:
- 240p (Low Definition):
ffmpeg -i input_video.mp4 -vf "scale=-1:240" output_video_240p.mp4
- 360p (Standard Definition):
ffmpeg -i input_video.mp4 -vf "scale=-1:360" output_video_360p.mp4
- 480p (Standard Definition):
ffmpeg -i input_video.mp4 -vf "scale=-1:480" output_video_480p.mp4
- 720p (High Definition):
ffmpeg -i input_video.mp4 -vf "scale=-1:720" output_video_720p.mp4
Replace input_video.mp4
with your source video file name and output_video_<resolution>p.mp4
with your desired output file name.If I run file on the output, it says that the resolution is 1920x1080. How would you fix that?If the output video resolution is not as expected, it is possible that FFmpeg did not correctly scale the video. To ensure that the resolution is changed properly, you can try specifying both width and height while maintaining the aspect ratio. First, you need to determine the input video's aspect ratio. You can do this using ffprobe:
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input_video.mp4
This command will output the video's width and height, separated by an "x". For example: "1920x1080".
Once you have the aspect ratio, calculate the width for each desired height while maintaining the aspect ratio. For instance, if your input video is 1920x1080 (16:9 aspect ratio), you can calculate the width for each resolution as follows:
- 240p (Low Definition): 426x240
- 360p (Standard Definition): 640x360
- 480p (Standard Definition): 854x480
- 720p (High Definition): 1280x720
Now you can use the calculated width and height in the FFmpeg command:
ffmpeg -i input_video.mp4 -vf "scale=426:240" output_video_240p.mp4
ffmpeg -i input_video.mp4 -vf "scale=640:360" output_video_360p.mp4
ffmpeg -i input_video.mp4 -vf "scale=854:480" output_video_480p.mp4
ffmpeg -i input_video.mp4 -vf "scale=1280:720" output_video_720p.mp4
Replace input_video.mp4
with your source video file name and output_video_<resolution>p.mp4
with your desired output file name. After running these commands, the output video should have the correct resolution.I run a Jitsi server. Anyway for me to know what resolution of webcam streams are being sent to my server?Yes, you can check the resolution of the webcam streams being sent to your Jitsi server by looking at the WebRTC statistics available in the browser. Here's how to do it in Google Chrome:
- Join a Jitsi conference using Google Chrome.
- Right-click on the web page and select "Inspect" to open the Developer Tools.
- Click on the "⋮" (three vertical dots) button in the top-right corner of the Developer Tools, then go to "More tools" and select "WebRTC Internals."
- In the WebRTC Internals tab, you'll see detailed information about the WebRTC connections.
- Look for a section titled "ssrc_XXXXXXXXXX_recv," where "XXXXXXXXXX" represents a random number. This section contains the statistics for the incoming streams.
- Find the "googFrameHeightReceived" and "googFrameWidthReceived" fields to see the current resolution of the incoming video streams.
Please note that the WebRTC Internals tab shows real-time statistics, so the resolution might change over time as the client's network conditions or video settings change. For other browsers, the process might be slightly different, but they should also provide access to the WebRTC statistics.
Keep in mind that this method provides information about the video streams received by your specific client. To gather information about all the streams being sent to your server, you might need to implement additional server-side logging or monitoring.linux cli, how would I use cut
to get the second field in a tab delimited output. Be briefTo extract the second field in a tab-delimited output using the cut
command in Linux, use the following command:
cut -f2 input_file.txt
Replace input_file.txt
with the name of the file containing the tab-delimited data. The -f2
flag specifies that you want to extract the second field.In bash, how would i make an easy to use alias, command, or whatever so that I can update two environment variables.
Example:
switch-user 42
would have the side-effect of export TEST_USER=test42
and export [email protected]
?You can create a Bash function and add it to your .bashrc
or .bash_profile
file to achieve this. Here's how:
- Open your
.bashrc
or.bash_profile
file in a text editor. You can find this file in your home directory. If it doesn't exist, create it.
nano ~/.bashrc
- Add the following function to the file:
switch-user() {
export TEST_USER="test$1"
export TEST_EMAIL="[email protected]"
}
Save the file and exit the editor.
Reload the
.bashrc
or.bash_profile
file to apply the changes:
source ~/.bashrc
Now, you can use the switch-user
command followed by a number, like this:
switch-user 42
This command will set the TEST_USER
and TEST_EMAIL
environment variables as you described:
TEST_USER=test42
[email protected]
```On linux using the CLI, how can I make a .wav file smaller?To make a .wav file smaller on Linux using the command line, you can use the `ffmpeg` tool to reduce its bitrate, sample rate, or convert it to a more efficient audio format, such as MP3 or OGG.
First, ensure you have `ffmpeg` installed on your system. If you don't have it, install it using the package manager for your Linux distribution. For example, on Ubuntu or Debian-based systems:
sudo apt update sudo apt install ffmpeg
Here's how to make a .wav file smaller by reducing the bitrate and sample rate:
```bash
ffmpeg -i input.wav -ab 64k -ar 22050 output.wav
Replace input.wav
with your source WAV file and output.wav
with the desired output file name. In this example, the output file will have a bitrate of 64 kbps (-ab 64k
) and a sample rate of 22,050 Hz (-ar 22050
). Adjust these values to balance file size and audio quality as needed.
Alternatively, you can convert the .wav file to a more efficient format like MP3:
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 2 output.mp3
In this example, the -codec:a libmp3lame
flag specifies the MP3 codec, and -qscale:a 2
sets the quality level (lower values mean higher quality; 2 is a good balance between quality and file size).Sorry, how do I do it and keep .wav as the output format?Apologies for the confusion. To make a .wav file smaller while keeping the .wav format, you can reduce the sample rate, bitrate, or both using ffmpeg
. Here's an example that reduces both the sample rate and the bitrate:
ffmpeg -i input.wav -ar 22050 -acodec pcm_s16le -ac 1 -b:a 64k output.wav
Replace input.wav
with your source WAV file and output.wav
with the desired output file name. In this example:
-ar 22050
sets the sample rate to 22,050 Hz.-acodec pcm_s16le
sets the output codec to 16-bit PCM (pulse-code modulation) to reduce the file size. You can also trypcm_s8
for 8-bit PCM, which will further reduce the file size but may result in lower audio quality.-ac 1
sets the output to mono (1 channel) instead of stereo (2 channels) to save space. Remove this flag if you want to keep the stereo channels.-b:a 64k
sets the output bitrate to 64 kbps.
You can adjust these values as needed to balance file size and audio quality. Keep in mind that reducing the sample rate, bitrate, or bit depth will result in lower audio quality.I got the error pcm_s8 codec not supported in WAVE format
I apologize for the oversight. The pcm_s8
codec is indeed not supported in WAVE format. Instead, you can use the pcm_s16le
codec (16-bit PCM) to make the file smaller while retaining compatibility with the .wav format.
Here's the modified command:
ffmpeg -i input.wav -ar 22050 -acodec pcm_s16le -ac 1 output.wav
Replace input.wav
with your source WAV file and output.wav
with the desired output file name. In this example:
-ar 22050
sets the sample rate to 22,050 Hz.-acodec pcm_s16le
sets the output codec to 16-bit PCM (pulse-code modulation) to reduce the file size.-ac 1
sets the output to mono (1 channel) instead of stereo (2 channels) to save space. Remove this flag if you want to keep the stereo channels.
You can adjust the sample rate or channel count to balance file size and audio quality. Note that lowering these values may result in a loss of audio quality.in bash, how do I unset or remove a variable I export
?To unset or remove an exported environment variable in Bash, use the unset
command followed by the variable name. For example, if you want to unset a variable named MY_VARIABLE
, run the following command:
unset MY_VARIABLE
This command will remove the variable from the environment, and it will no longer be accessible in the current shell or its child processes.
Resizing Video with FFmpeg created at Tue Jan 20 1970 10:52:11 GMT+0000 (Coordinated Universal Time)Related Chats
Converting MP4 to WAV 0.484
FFmpeg Video Segment Extraction 0.443
Custom LaTeX Template. 0.308
Control Window Size: VisionOS 0.303
Edit Videos in iMovie 0.292
Convert M4A to WAV/MP3 0.266
Record Snapchat Lens MP4. 0.257
RGB to Hex Conversion 0.252
Scale Data to New Range 0.232