Here’s how to reduce a MP4 video using H.265 format.
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4 |
I was able to reduce a video file from 550MB to 26MB without much quality loss.
cloud engineer
Here’s how to reduce a MP4 video using H.265 format.
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4 |
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4
I was able to reduce a video file from 550MB to 26MB without much quality loss.
If you have video files that are formatted in MPEG-2, video files with a .m2ts extension, you can convert them to MP4 using ffmpeg.
ffmpeg -i input.ts -c:v libx264 -c:a aac output.mp4 |
ffmpeg -i input.ts -c:v libx264 -c:a aac output.mp4
The video is encoded using open format H.264, while audio is encoded using AAC.
FFMPEG is the jack of all trades utility for both audio and video files. You can record, convert, and even live stream an audio or video file in just about any file format. In this example, I will be sending a RTMP stream of a MP4 file to a Wowza streaming server. I can easily send the same stream to YouTube, Facebook or any streaming server that accepts a RTMP source. In this example, I created simple Bash script called play.sh, with all the options needed to live stream to Wowza Streaming server.
Here are the options in play.sh.
ffmpeg -re -i $1 -acodec libmp3lame -ar 44100 -b:a 128k \ -pix_fmt yuv420p -profile:v baseline -s 1280x720 -bufsize 6000k \ -vb 1200k -maxrate 1500k -deinterlace -vcodec libx264 \ -preset veryfast -g 30 -r 30 -f flv \ -flvflags no_duration_filesize \ "rtmp://username:password@yourserver:1935/live/backup" |
ffmpeg -re -i $1 -acodec libmp3lame -ar 44100 -b:a 128k \ -pix_fmt yuv420p -profile:v baseline -s 1280x720 -bufsize 6000k \ -vb 1200k -maxrate 1500k -deinterlace -vcodec libx264 \ -preset veryfast -g 30 -r 30 -f flv \ -flvflags no_duration_filesize \ "rtmp://username:password@yourserver:1935/live/backup"
To launch, run the script.
bash play.sh filename.mp4 |
bash play.sh filename.mp4