Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gohny committed Dec 22, 2023
0 parents commit a6bea08
Show file tree
Hide file tree
Showing 6 changed files with 889 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.aur
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## v0.1.0
**Release date: 2023-12-22**
- First release
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
all:
@echo "Installing: sudo make install"
@echo "Uninstalling: sudo make uninstall"

install:
@chmod 755 davinconv
@cp davinconv /usr/bin/davinconv
@echo "Davinconv has been installed"

uninstall:
@rm -rf /usr/bin/davinconv
@echo "Davinconv has been uninstalled"
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Davinconv - video converter for Davinci Resolve on Linux
Simple script written in bash to convert videos using `ffmpeg` to the format supported by Davinci Resolve for Linux.

I recommend watching [tihs video](https://www.youtube.com/watch?v=WLcW4UWPC5Y) before using the script.
## Installing
### Install Davinconv manually with `make`
- First, download and install `git` and `make` usnig your **package manager**.
- Then, clone the repo:
```
git clone https://github.com/gohny/davinconv
```
- Change current directory to `davinconv`:
```
cd davinconv
```
- Install:
```
sudo make install
```
### Install Davinconv with AUR
https://aur.archlinux.org/packages/davinconv
#### Using AUR helper such as `yay` or `pikaur`
- Simply install the `davinconv` package using your **AUR helper**.
- ##### `yay`:
```
yay davinconv
```
- ##### `pikaur`:
```
pikaur -S davinconv
```
#### Manually, using `makepkg` script
- Install `git`:
```
sudo pacman -S git
```
- Clone the repo from **AUR**:
```
git clone https://aur.archlinux.org/davinconv.git
```
- Change current directory to `davinconv`:
```
cd davinconv
```
- Install:
```
makepkg -si
```
## Uninstalling
### Using `make`
- If you're missing repo files, clone it again:
```
git clone https://github.com/gohny/davinconv
```
- Change current directory to `davinconv`:
```
cd davinconv
```
- Uninstall:
```
sudo make uninstall
```
### AUR
- Uninstall `davinconv` with `pacman`:
```
sudo pacman -Rsnu davinconv
```
## Usage
```
Usage: davinconv [-c|C|e|E|h|R]
Options:
{-c} [file] - Convert video to the MJPEG codec that can be read by Davinci Resolve.
{-C} - Convert all videos in current directory to the MJPEG codec that can be read by Davinci Resolve.
{-e} [file] - Export converted video back to the H264 codec.
{-E} - Export all converted videos stored in ~/Videos/davinconv/converted back to the H264 codec.
{-h} - Display this message.
{-R} - Remove all converted videos stored in ~/Videos/davinconv/converted. - Remove all converted videos stored in ~/Videos/davinconv/converted.
```
### Files
**Converted** videos are stored in: `~/Videos/davinconv/` <br/>
***
Created by Gohny
116 changes: 116 additions & 0 deletions davinconv
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#! /bin/bash
VERSION=0.1.0
USERNAME=$(whoami)
VIDDIR=/home/"$USERNAME"/Videos/davinconv
WHEREAMI=$(pwd)

if [ ! -d "$VIDDIR" ]; then
mkdir -p "$VIDDIR"
mkdir -p "$VIDDIR"/converted
mkdir -p "$VIDDIR"/exported
fi

Help() {
echo ""
echo " ............................................................"
echo " . Davinconv - video converter for Davinci Resolve on Linux ."
echo " . v0.1.0 by Gohny ."
echo " ............................................................"
echo ""
echo "Usage: davinconv [-c|C|e|E|h|R]"
echo ""
echo "Options:"
echo " {-c} [file] - Convert video to the MJPEG codec that can be read by Davinci Resolve."
echo " {-C} - Convert all videos in current directory to the MJPEG codec that can be read by Davinci Resolve."
echo " {-e} [file] - Export converted video back to the H264 codec."
echo " {-E} - Export all converted videos stored in $VIDDIR/converted back to the H264 codec."
echo " {-h} - Display this message."
echo " {-R} - Remove all converted videos stored in $VIDDIR/converted."
echo ""
echo "All converted and exported videos are stored in: ~/Videos/davinconv"
echo ""
echo "It is recommended to watch https://www.youtube.com/watch?v=WLcW4UWPC5Y before using the script."
echo ""
echo "LICENSE: GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007"
echo "https://github.com/gohny/davinconv"
}

Convert() {
ffmpeg -i "$i" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov "$VIDDIR"/converted/${i%.*}.mov
}

ConvertAll() {
for i in *.mp4 *.mkv; do
ffmpeg -i "$i" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov "$VIDDIR"/converted/${i%.*}.mov
done
}

Export() {
ffmpeg -i "$VIDDIR"/converted/"$i" -c:v libx264 -preset ultrafast -crf 0 "$VIDDIR"/exported/${i%.*}.mp4
}

ExportAll() {
cd "$VIDDIR"/converted
for i in *.mov; do
ffmpeg -i "$i" -c:v libx264 -preset ultrafast -crf 0 "$VIDDIR"/exported/${i%.*}.mp4
done
cd "$WHEREAMI"
}

RemoveAll() {

while true; do

echo "You are about to remove ALL converted videos stored in $VIDDIR/converted."
read -p "Do you want to continue? (y/n) " yn

case $yn in
[yY] )
echo ""
echo "please wait..."
echo ""
sleep 1
rm -rf "$VIDDIR"/converted/*
break;;

[nN] )
echo "No changes have been made."
exit;;

* )
echo "Error: please input y or n";;
esac
done
}

while getopts ":c:Ce:EhR" OPTION; do
case $OPTION in
c)
i=${OPTARG}
Convert
exit;;
C)
ConvertAll
exit;;
e)
i=${OPTARG}
Export
exit;;
E)
ExportAll
exit;;
h)
Help
exit;;
R)
RemoveAll
exit;;
*)
echo "Error: Invalid option or argument not provided!"
echo "For help use: davinconv -h"
exit;;
esac
done

Help
exit

0 comments on commit a6bea08

Please sign in to comment.