doc:appunti:linux:video:ffmpeg_stack_horizontally
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:appunti:linux:video:ffmpeg_stack_horizontally [2021/10/28 09:23] – niccolo | doc:appunti:linux:video:ffmpeg_stack_horizontally [2021/10/28 09:43] (current) – niccolo | ||
---|---|---|---|
Line 15: | Line 15: | ||
The script can take into account that the videos may be **out of sync**: it is possible to pass **two timestamps** referring at the same instant captured into both videos. The script will **shift the videos presentation time** each-other, so that both will be synced. | The script can take into account that the videos may be **out of sync**: it is possible to pass **two timestamps** referring at the same instant captured into both videos. The script will **shift the videos presentation time** each-other, so that both will be synced. | ||
+ | |||
+ | The script has some constraints. It requires the **Bash shell**, because it uses the **%%((expression))%%** to do arithmetic evaluation. The script requires also the **Python** interpreter, | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | # Take the central part of two videos and stack them horizontally. | ||
+ | # Audio from the first video is merged into the left channel of the | ||
+ | # resulting video, audio from the second video goes to the right. | ||
+ | # Two lables are overlayed on the bottom left and right corners. | ||
+ | |||
+ | # https:// | ||
+ | # https:// | ||
+ | # https:// | ||
+ | |||
+ | # Left and right videos. | ||
+ | # | ||
+ | # | ||
+ | VIDEO_1=" | ||
+ | VIDEO_2=" | ||
+ | |||
+ | # Two timestamps which should be synced. | ||
+ | # | ||
+ | # | ||
+ | TIME_1=" | ||
+ | TIME_2=" | ||
+ | |||
+ | # Labels to be superimposed on the two halves. | ||
+ | # | ||
+ | # | ||
+ | LABEL_1=" | ||
+ | LABEL_2=" | ||
+ | |||
+ | # | ||
+ | OUTPUT=" | ||
+ | |||
+ | if [ -z " | ||
+ | -z " | ||
+ | -z " | ||
+ | -z " | ||
+ | echo | ||
+ | echo " | ||
+ | echo | ||
+ | echo " | ||
+ | echo | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | # Do the math, etc... | ||
+ | if (( $(echo " | ||
+ | TO_1=" | ||
+ | TO_2=' | ||
+ | else | ||
+ | TO_1=' | ||
+ | TO_2=" | ||
+ | fi | ||
+ | |||
+ | # Font and style for labels. | ||
+ | FONT=' | ||
+ | STYLE=' | ||
+ | # Labels placement. | ||
+ | L1X=' | ||
+ | L2X=' | ||
+ | L1Y=' | ||
+ | L2Y=' | ||
+ | |||
+ | ffmpeg -ss " | ||
+ | -filter_complex \ | ||
+ | " | ||
+ | [1: | ||
+ | [left][right]hstack=shortest=1[vs]; | ||
+ | [0: | ||
+ | [vs]drawtext=${FONT}text=' | ||
+ | -map ' | ||
+ | " | ||
+ | </ |
doc/appunti/linux/video/ffmpeg_stack_horizontally.txt · Last modified: 2021/10/28 09:43 by niccolo