Page 1 of 1

Script to convert all video files to compatible with DR form

PostPosted: Sat Mar 06, 2021 4:56 am
by Boris Kovalev
Hi! Since DR on linux lacks some codecs and variable framerate is still a thing, i made a little script to prepare all video files in a given folder to be used by DR.

Usage:
Make sure to install ffmpeg and mediainfo packages (tested with Debian 10 and 11)
unzip davincirecode10.zip, give it a "chmod a+x" or something, go to folder with videos, run the script.

What it does:
If the media file has variable framerate (VFR) - reencode to fixed 24 fps (change this by touching framerate variable inside the script)

In case of unsupported by DR on linux audio codec - reencode audio

Interlaced video - Use "deinterlace=true" to de-interlace using yadif (via ffmpeg) or let DR handle it (for studio users)
There are 3 options inside DR to de-interlace: Normal (worked fine for me), High (also good) and Neural engine (slow on my setup)
Also at times DR detects interlaced videos as progressive, in that case you may set the Field Dominance by hand inside Clip Attributes

All the files in current dir will output to .MKV container
You can change this inside the script, but note that not any audio codecs may fit into some containers

There is a variable "folderprefix", to specify an export directory (default is "exportedvideo")

Would be cool:
To make use of framerate in VFR videos (at times you have minimum and maximum values, but not always)
Starting with Resolve 18.5b1 we now have AC3 decoding :D I should reflect this change in the script one day

Notes
You may also want to add an alias for this script like this:
echo "alias davincirecode='/path/to/davincirecode10.sh'" >> ~/.bashrc
Please feel free to make this script better! Hope this is only temporal solution and we will get all the codecs soon :roll:

Re: Script to convert all video files to compatible with DR

PostPosted: Sat Mar 06, 2021 8:46 am
by iddos-l
Thanks for sharing!
Will try it out next week.


Sent from my iPhone using Tapatalk

Re: Script to convert all video files to compatible with DR

PostPosted: Sat Mar 06, 2021 3:23 pm
by SwansongMedia
That's great, Boris - thank you!

I'd written a more basic version but didn't know about mediainfo so couldn't implement useful conditional things like you have. The only thing I did a bit differently was to put all the output files in a different folder to keep them separate for easier import.

Re: Script to convert all video files to compatible with DR

PostPosted: Sun Mar 07, 2021 3:02 pm
by Boris Kovalev
SwansongMedia wrote:That's great, Boris - thank you!

I'd written a more basic version but didn't know about mediainfo so couldn't implement useful conditional things like you have. The only thing I did a bit differently was to put all the output files in a different folder to keep them separate for easier import.


Yes, i thought about a separate folder, like FFmpeg Batch AV Converter does. Will make a folder option next :idea:

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 12:35 am
by Uli Plank
Great! Only one thing: I’d rather de-interlace by QTGMC or use the neural version in DR 17.

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 2:36 am
by Boris Kovalev
Uli Plank wrote:Great! Only one thing: I’d rather de-interlace by QTGMC or use the neural version in DR 17.

Can you point me to some linux guide on QTGMC? My goal is to make it usefull for newbies, if it's too complex to install, i'd rather keep the current ffmpeg transcoding. In DR17 in order to deintrerlace i needed to specify the field order, is there a better way?

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 2:55 am
by Uli Plank
While I'm not a Linux person at all, if your clip is a camera original, you can normally tell the field order from the flags or the format.

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 3:03 am
by Boris Kovalev
Uli Plank wrote:While I'm not a Linux person at all, if your clip is a camera original, you can normally tell the field order from the flags or the format.

Yes, there is a variable/flag to tell you field order, but i need to manually specify that inside DR. So if you have several clips, it's tedious. Yadiff does a good job as far as i can tell. This script is not intended for professional use really. I'm sure this reencoding will lose bitrate at times, it's only to get the job done fast i'd say

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 3:13 am
by Uli Plank
DR 17 normally is recognising the field order.

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 4:57 am
by Boris Kovalev
Uli Plank wrote:DR 17 normally is recognising the field order.

That is strange, i had automatic detection failure at the begining, so what i did was:
Added the clip to a bin > Right click > Clip attributes > Field Dominance and set it to upper manually
Now without changing anything (as far as i'm concern), deinterlacing works flawlessly.
Will do some more testing

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 5:09 am
by Uli Plank
Of course, some clips may be flagged incorrectly. Do you have a sample?

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 5:17 am
by Boris Kovalev
Uli Plank wrote:Of course, some clips may be flagged incorrectly. Do you have a sample?

Unfortunately i had all my interlaced clips flagged as "auto-progressive" at some point.
After restarting DR17, the problem is gone, and i have "Upper Field" now, which is correct. So i'm unable to reproduce the problem.
Using DR16 lite on windows, i always had to de-interlace using ffmpeg, since de-interlacing is only available in studio version (not sure about DR17).
I will make a switch for de-interlacing using yadif for lite version users :!:

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 6:25 am
by Uli Plank
I'm sure the 'neural' version is only in Studio, and it's the only one worth using in DR.

Re: Script to convert all video files to compatible with DR

PostPosted: Mon Mar 08, 2021 2:58 pm
by Boris Kovalev
Uli Plank wrote:I'm sure the 'neural' version is only in Studio, and it's the only one worth using in DR.

I found the option now :) sure, must be a great way to de-interlace. Will skip de-interlacing by default now.
For lite users i'll leave a flag to do it with ffmpeg. Thanks!

Re: Script to convert all video files to compatible with DR

PostPosted: Wed Mar 30, 2022 7:58 pm
by hutber
Brilliant!! This will litterally save my guts and make it possible to actually use DC!!

One question is it possible to support h265? Having changed the videocodex=h265. I guess there is more to it than that!

Code: Select all
hutber@hutber:~/Videos/aa$ ./da.sh
mkdir: cannot create directory ‘exportedvideo/’: File exists
case 3 - da.sh : Converting audio only mkv
da.sh: Invalid data found when processing input
case 4 - vlc-record-2022-02-20-21h21m26s-GX030005.mp4 : Converting audio and constant framerate h264 mkv
[hevc @ 0x5574185b74c0] Could not find ref with POC 29

Re: Script to convert all video files to compatible with DR

PostPosted: Wed Mar 30, 2022 11:58 pm
by Boris Kovalev
hutber wrote:Brilliant!! This will litterally save my guts and make it possible to actually use DC!!

One question is it possible to support h265? Having changed the videocodex=h265. I guess there is more to it than that!

Code: Select all
hutber@hutber:~/Videos/aa$ ./da.sh
mkdir: cannot create directory ‘exportedvideo/’: File exists
case 3 - da.sh : Converting audio only mkv
da.sh: Invalid data found when processing input
case 4 - vlc-record-2022-02-20-21h21m26s-GX030005.mp4 : Converting audio and constant framerate h264 mkv
[hevc @ 0x5574185b74c0] Could not find ref with POC 29


Thanks! Yes, you can use any codec supported by your ffmpeg installation:

ffmpeg -codecs -hide_banner | grep h265

Should give you something, otherwise you need to get a suitable ffmpeg for that

Re: Script to convert all video files to compatible with DR

PostPosted: Thu Mar 31, 2022 1:29 pm
by hutber
Humm interesting, it doesn't actually exist.

Thanks very very much for the insight though. I will try to work this out. Its too late now, but I would have just recorded in h264 had I known this would be such an issue :D

Re: Script to convert all video files to compatible with DR

PostPosted: Thu Mar 31, 2022 10:30 pm
by Boris Kovalev
hutber wrote:Humm interesting, it doesn't actually exist.

Thanks very very much for the insight though. I will try to work this out. Its too late now, but I would have just recorded in h264 had I known this would be such an issue :D


Glad to help! As an example, in my gopro 6 i can't change the codec.
It automatically selects the one it likes depending on video mode.
I did some adjustments yesterday, so now this script must reencode some older codecs better.
Will try to update it if there is a need to fix something else