Script to convert all video files to compatible with DR form

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

Script to convert all video files to compatible with DR form

PostSat Mar 06, 2021 4:56 am

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:
Attachments
davincirecode10.zip
v0.10
(1.58 KiB) Downloaded 298 times
Last edited by Boris Kovalev on Wed Apr 26, 2023 12:45 am, edited 38 times in total.
Offline
User avatar

iddos-l

  • Posts: 803
  • Joined: Sat Mar 30, 2019 7:55 pm
  • Real Name: iddo lahman

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

PostSat Mar 06, 2021 8:46 am

Thanks for sharing!
Will try it out next week.


Sent from my iPhone using Tapatalk
Offline

SwansongMedia

  • Posts: 49
  • Joined: Sat Sep 14, 2019 5:33 pm
  • Location: UK
  • Real Name: Sheriton Swan

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

PostSat Mar 06, 2021 3:23 pm

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.
Resolve Studio 17.1.1
CentOS 7.3
Asus Z87, Intel Core i7-4770 3.4GHz, 24 GB RAM, NVIDIA GeForce GTX 960 (450.66, supports CUDA 11.0). Old system but runs Resolve remarkably well!
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostSun Mar 07, 2021 3:02 pm

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:
Offline
User avatar

Uli Plank

  • Posts: 25454
  • Joined: Fri Feb 08, 2013 2:48 am
  • Location: Germany and Indonesia

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

PostMon Mar 08, 2021 12:35 am

Great! Only one thing: I’d rather de-interlace by QTGMC or use the neural version in DR 17.
My disaster protection: export a .drp file to a physically separated storage regularly.
www.digitalproduction.com

Studio 19.1.3
MacOS 13.7.4, 2017 iMac, 32 GB, Radeon Pro 580 + eGPU
MacBook M1 Pro, 16 GPU cores, 32 GB RAM, MacOS 14.7.2
SE, USM G3
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostMon Mar 08, 2021 2:36 am

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?
Offline
User avatar

Uli Plank

  • Posts: 25454
  • Joined: Fri Feb 08, 2013 2:48 am
  • Location: Germany and Indonesia

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

PostMon Mar 08, 2021 2:55 am

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.
My disaster protection: export a .drp file to a physically separated storage regularly.
www.digitalproduction.com

Studio 19.1.3
MacOS 13.7.4, 2017 iMac, 32 GB, Radeon Pro 580 + eGPU
MacBook M1 Pro, 16 GPU cores, 32 GB RAM, MacOS 14.7.2
SE, USM G3
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostMon Mar 08, 2021 3:03 am

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
Last edited by Boris Kovalev on Mon Mar 08, 2021 4:59 am, edited 1 time in total.
Offline
User avatar

Uli Plank

  • Posts: 25454
  • Joined: Fri Feb 08, 2013 2:48 am
  • Location: Germany and Indonesia

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

PostMon Mar 08, 2021 3:13 am

DR 17 normally is recognising the field order.
My disaster protection: export a .drp file to a physically separated storage regularly.
www.digitalproduction.com

Studio 19.1.3
MacOS 13.7.4, 2017 iMac, 32 GB, Radeon Pro 580 + eGPU
MacBook M1 Pro, 16 GPU cores, 32 GB RAM, MacOS 14.7.2
SE, USM G3
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostMon Mar 08, 2021 4:57 am

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
Offline
User avatar

Uli Plank

  • Posts: 25454
  • Joined: Fri Feb 08, 2013 2:48 am
  • Location: Germany and Indonesia

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

PostMon Mar 08, 2021 5:09 am

Of course, some clips may be flagged incorrectly. Do you have a sample?
My disaster protection: export a .drp file to a physically separated storage regularly.
www.digitalproduction.com

Studio 19.1.3
MacOS 13.7.4, 2017 iMac, 32 GB, Radeon Pro 580 + eGPU
MacBook M1 Pro, 16 GPU cores, 32 GB RAM, MacOS 14.7.2
SE, USM G3
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostMon Mar 08, 2021 5:17 am

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 :!:
Offline
User avatar

Uli Plank

  • Posts: 25454
  • Joined: Fri Feb 08, 2013 2:48 am
  • Location: Germany and Indonesia

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

PostMon Mar 08, 2021 6:25 am

I'm sure the 'neural' version is only in Studio, and it's the only one worth using in DR.
My disaster protection: export a .drp file to a physically separated storage regularly.
www.digitalproduction.com

Studio 19.1.3
MacOS 13.7.4, 2017 iMac, 32 GB, Radeon Pro 580 + eGPU
MacBook M1 Pro, 16 GPU cores, 32 GB RAM, MacOS 14.7.2
SE, USM G3
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostMon Mar 08, 2021 2:58 pm

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!
Offline

hutber

  • Posts: 39
  • Joined: Tue Dec 03, 2019 10:15 pm
  • Real Name: Mr Jamie Hutber

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

PostWed Mar 30, 2022 7:58 pm

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
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostWed Mar 30, 2022 11:58 pm

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
Offline

hutber

  • Posts: 39
  • Joined: Tue Dec 03, 2019 10:15 pm
  • Real Name: Mr Jamie Hutber

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

PostThu Mar 31, 2022 1:29 pm

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
Offline

Boris Kovalev

  • Posts: 151
  • Joined: Fri Sep 08, 2017 6:20 pm

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

PostThu Mar 31, 2022 10:30 pm

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

Return to DaVinci Resolve

Who is online

Users browsing this forum: Bing [Bot], MarnMxxx, panos_mts and 263 guests