Is there any way to set default views to 'add' and export the resultant movie using rv commands

I am working on shotgrid RV player, where I am trying to import two different .mov files and overlapp them and then export the resultant .mov file.

I am providing more context here below:

Script which I am using is as follows :

import subprocess

def open_shotgun_rv_player(file_path_1, file_path_2, export_path):
    rv_executable = 'C:/Program Files/ShotGrid/RV-2022.3.1/bin/rv.exe'  # Replace with the actual path to the 'rv' executable
    # command = [rv_executable,'-help']
    command = [rv_executable, file_path_1,file_path_2,'view %s'%('add')] #  # Add the export option to the command
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = process.communicate()
    stdout_lines = stdout.decode().splitlines()
    stderr_lines = stderr.decode().splitlines()

    print("Standard error:")
    for line in stderr_lines:
        print(line)

file_path_1 = 'C:/...../dummy_0200_layout_v01.mov'
file_path_2 = 'C:/..../dummy_0300_animatic_v05.mov'
export_path = 'Q:/..../export.mov'
open_shotgun_rv_player(file_path_1, file_path_2, export_path)

I am getting this following error :

ERROR: Open of 'view add' failed: unsupported media type.

Now to get idea from the software perspective I am trying to do the following operations.


I haven’t added the export path yet as I tried few things but I was getting errors well. So any help on these issues would be really helpful.

Thanks & Regrads

A couple things:
subprocess needs a list of args, so something like this won’t work:
'view %s'%('add')
it breaks subprocess with that space after view. You could add the arg, shell=True, but then you would use a string and not a list.
It still wouldn’t matter, because the next thing is that arg isn’t correct for your needs.
I think you want something like this:
[rv_executable, file_path_1,file_path_2, '-comp', 'add', '-view', 'defaultStack']
-view” defines the viewable, stack, seq, etc. “-comp” defines your add operation, or over/difference, etc.

That takes care of the first problem. For the export, unfortunately, what you really need is rvio to write a movie. To do that, you’ll need to write a session file with what you want to do and pass it to rvio with something like this to subprocess: ['rvio', 'rvsession.rv', '-o', export_path]

I couldn’t attach an rv session file, so go here and save as ‘template.rv’

then use the modified code below. I left in a color correction to take each element down a stop or you’ll have your comp overexposed, but just monkey with the template however you want to.

import subprocess


def open_shotgun_rv_player(file_path_1, file_path_2, export_path):
    rv_executable = 'rvio'  # Replace with the actual path to the 'rv' executable
    templatefile = 'template.rv'
    rvsessionfile = '/var/tmp/rvsession.rv'
    
    with open(templatefile) as fd:
       template = fd.read()
    
    rvsession = template % (file_path_1, file_path_2)
    with open(rvsessionfile, 'w') as fd:
        fd.write(rvsession)
    
    # command = [rv_executable,'-help']
    command =  ['rvio', rvsessionfile, '-v', '-o', export_path]
    process = subprocess.Popen(command)


file_path_1 = '/u/dm4/Users/OFF/Files/image/DM4/S0600/P0120/Compo_Movie/DM4_S0600_P0120-L-Compo_Movie.mov/.flags/current/DM4_S0600_P0120-L-Compo_Movie.mov'
file_path_2 = '/u/dm4/Users/OFF/Files/image/DM4/S0600/P0130/Compo_Movie/DM4_S0600_P0130-L-Compo_Movie.mov/.flags/current/DM4_S0600_P0130-L-Compo_Movie.mov'

export_path = 'export.mov'

open_shotgun_rv_player(file_path_1, file_path_2, export_path)

cheers -
jrab

Thanks alot @jrab , that really helped me getting better understanding.

Thanks for solutions before, but I am facing one issue during the implementation :

  1. when I am trying to execute your script I am getting this following error :

I just executed the script you’ve given with only path modifications:

import subprocess

def open_shotgun_rv_player(file_path_1, file_path_2, export_path):
    rv_executable = 'C:/Program Files/ShotGrid/RV-2022.3.1/bin/rv.exe'  # Replace with the actual path to the 'rv' executable
    templatefile = 'Q:/....../template.rv'
    rvsessionfile = 'Q:/......./rvsession.rv'
    
    with open(templatefile) as fd:
       template = fd.read()
    
    rvsession = template % (file_path_1, file_path_2)
    with open(rvsessionfile, 'w') as fd:
        fd.write(rvsession)
    
    # command = [rv_executable,'-help']
    command =  [rv_executable, rvsessionfile, '-v','-o', export_path]
    process = subprocess.Popen(command)
    stdout, stderr = process.communicate()
    # stdout_lines = stdout.decode().splitlines()
    stderr_lines = stderr.decode().splitlines()

    # print("Standard output:")
    # for line in stdout_lines:
    #     print(line)

    print("Standard error:")
    for line in stderr_lines:
        print(line)

file_path_1 = 'Q:/.../layout_v01.mov'
file_path_2 = 'Q:/.../animatic_v05.mov'

export_path = 'Q:/.../export.mov'

open_shotgun_rv_player(file_path_1, file_path_2, export_path)

Thanks & Regards

note: it is using rvio to enable an export, not rv.
rv does not have a ‘-v’ argument
the ‘-v’ is for verbose, so you can monitor the export as it is created.

So for this do i need separate lisence for rvio or it can be work around as I was trying to follow this solution from the forum :

https://community.shotgridsoftware.com/t/how-to-use-rvio-with-your-included-rv-license/612

will it work in my case as for now I am getting few errors so just trying to be sure is this the right approach to go ahead with or should I opt some alternatives.

Check with your system guys about how you are licensed. Without knowing the errors, it could be anything, but I’m guessing if the errors say something about licensing, update your script the way the thread suggests. ‘-v’ should be spitting out some useful info, if you are not getting a python traceback.
If you have a separate rvio license, the above should work (it did for me). You could have path errors or permissions issues, also. Try updating the paths to ‘./thefiles…’ so it’s all happening at the same directory your are working in. At least you know you have write permissions if you can save your files there!

Also - just for grins, copy the template and update the copy’s ‘%s’ with your paths and test it all out on a normal command line.

rvio copiedtemplate.rv -o myexport.mov -v

at least you could verify that the template is doing what you want. You could also use rv and try the menu’s export.

a license error is something else to deal with - good luck!

Well yeah error is related to the rvio and not any other like permission error ,actually I am getting error in ‘rv’ module itself ( i opted the way in the other solution thread as i don’t have rvio license )
some python environment issue, thanks for your inputs tho ,it helped me alot.