Sunday, February 19, 2017

Tutorial 04 - How to use the Crop detection to find the Black border of a video

This document explains how to find the black border around video and trim it during encoding

How to detect black borders


ffmpeg -hide_banner -ss 300 -i <Source_File> -vframes 10 -vf cropdetect -f null -
It will produce output of 10 frames as

[Parsed_cropdetect_0 @ 02d87c20] x1:78 x2:557 y1:60 y2:419 w:480 h:352 x:78 y:64 pts:12000 t:0.133333 crop=480:352:78:64

How to create a new output file without the black border

Find the crop settings from the previous command and use it as a video filter during encoding the video

ffmpeg -i <Source_File> -vf crop=480:352:78:64 -c:a copy output.mp4

Tutorial 03 - How to split the large videos

This document explains how to split the large videos using ffmpeg

CMD:
ffmpeg.exe -hide_banner -y -ss 00:00:00.0 -i <file_name> -vcodec copy -acodec copy -avoid_negative_ts make_zero -map 0 -segment_time <seconds> -f segment output%02d.mp4


-hide_banner Hide the banner during transcoding
-y Overwrite if the output file already exists
--ss Start time from which the video that needs to be splitted
-vcodec copy Copies the source video codec
-acodec copy Copies the source audio codec
-avoid_negative_ts make_zero
-map 0
-segment_time The duration which the video needs to be split
-f segment Produce the segmented output
output%02d.mp4 Output file names will be in this pattern


SAMPLE:
ffmpeg.exe -hide_banner -y -ss 00:00:00.0 -i SourceVideo.mp4 -vcodec copy -acodec copy -avoid_negative_ts make_zero -map 0 -segment_time 300 -f segment output%02d.mp4