Make sure ffmpeg is already installed on your system (download here). Outputs are placed inside output
directory and creates itself if it does not exist.
Action | Script | Usage |
---|---|---|
Convert video or audio | converter.sh |
./converter.sh input.mkv output_converted.mp4 |
Rescale video | rescale_video.sh |
./rescale_video.sh input.mp4 360 output_rescale.mp4 |
Trim video | trim_video.sh |
./trim_video.sh 00:03:26 input.mp4 00:05:46 output_trimmed.mp4 |
Concatenate MP4 videos | Multiple scripts | Refer to the details |
Convert GIF to web-optimized MP4 and WEBM | gif_to_video.sh |
./gif_to_video.sh input.gif output_web |
Convert video to WEBM | webm_converter.sh |
./webm_converter.sh input.mp4 output |
./converter.sh <1> <2>
1
: File to convert2
: The file with expected format
./converter.sh input.mkv output_converted.mp4
# What it does
ffmpeg -i input.mkv output/output_converted.mp4
Rescales video while maintaining its aspect ratio
./rescale_video.sh <1> <2> <3>
1
: file to convert2
: expected height in pixels3
: output file
./converter.sh input.mp4 360 output_rescaled.mp4
# What it does
ffmpeg -i input.mp4 -vf scale=-2:360 output/"output_rescaled.mp4"
./trim_video.sh <1> <2> <3> <4>
1
: seek start with HH:MM:SS.mmm* format2
: input file3
: seek end with HH:MM:SS.mmm* format4
: output file
*H: hours, M: minutes, S: seconds, mmm (optional): miliseconds
./trim_video.sh 00:03:26 input.mp4 00:05:46 output_trimmed.mp4
# What it does
ffmpeg -ss 00:03:26 -i "input.mp4" -to 00:05:46 -c copy -copyts output/"output_trimmed.mp4"
Do the following:
./mp4_to_intermediate_ts.sh <1> <2>
1
: MP4 input file2
: output name (without extension)
./mp4_to_intermediate_ts.sh input.mp4 output_intermediate
# What it does
ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts output/output_intermediate.ts
./concat_ts.sh <1> <2>
1
: transport streams to concacenate, separated with "|". Example:"intermediate_1.ts|intermediate_2.ts"
2
: output file
./concat_ts.sh "intermediate_1.ts|intermediate_2.ts|intermediate_3.ts" output_concatenated.mp4
# What it does
ffmpeg -i "concat:intermediate_1.ts|intermediate_2.ts|intermediate_3.ts" -c copy -bsf:a aac_adtstoasc output/output_concatenated.mp4
This action creates two different files; MP4 and WEBM. Implementation: Replace animated GIFs with video for faster page loads
./trim_video.sh <1> <2>
1
: GIF input file2
: output name (without extension)
./gif_to_video.sh input.gif output_web
# What it does
ffmpeg -i input.gif -b:v 0 -crf 25 -f mp4 -vcodec libx264 -pix_fmt yuv420p output/output_web.mp4
ffmpeg -i input.gif -c vp9 -b:v 0 -crf 41 output/output_web.webm
./webm_converter.sh <1> <2>
1
: input file2
: output name (without extension)
./webm_converter.sh input.mp4 output
# What it does
ffmpeg -i "input.mp4" -vf setsar=1:1 output/output.webm