Modify Nemo context menu
I'm running Linux Mint 19.3 and would like to add an action to the context menu. I want to be able to select multiple image files and convert them to a mp4 file.I know this is possible by creating a nemo_action file in the /home/$USER/.local/share/nemo/actions folder.
I'm able to do this action via the command line with this command Code:
ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -vf scale=500:300 out.mp4 -framerate 1 = this will change the image in the mp4 file every 1 second -pattern_type glob = this to to be able to select multiple images '*.jpg' = selects the files I want -vf scale=500:300 = sets the video size to 500 by 300 out.mp4 = name of the output file I created an action file to try to perform this task with this information Code:
%F = insert path list of selection The Nemo action does show up in the context menu and I can select images to convert. But the action does not create the out.mp4 file. I think its failing because of the %F but I not sure how to select the files with out using %F. Thank you in advance for your help. |
%F is not a glob, it's a list of files separated by spaces. You probably should wrap the ffmpeg command in a shell script:
Code:
#!/bin/bash Code:
Exec=bash -c "'exec ffmpeg -framerate 1 \\${@/#/-i } -vf scale=500:300 out.mp4'" _ %F |
It looks like I'm half way there. I created a shell script and added your recommendations. The out.mp4 file does get created but none of the images reside in the out.mp4 file. Just a blank out.mp4 file.
My new nemo_action file Code:
I also tried your 2nd sugestion but I was not able to create the out.mp4 file |
in case your file names have spaces (from the arch wiki):
Quote:
Quote:
|
Thanks to cordx I see now that Nemo actions are not the same as .desktop as I assumed first. So the weird quoting rules for Exec= in .desktop may not apply here. Try it like this
Code:
Exec=bash -c 'exec ffmpeg -framerate 1 ${@/#/-i } -vf scale=500:300 out.mp4' _ %F |
Shruggy - the shell script works half way. It creates the out.mp4 file, but the file does not contain the images. Yes the script is executable.
Cordx - I verified there is not any spaces in the names of the image files, but I still added the Quote=double just in case I select files with spaces in the future. Still no joy. The out.mp4 is blank I thank you both for your input. I'm not sure why it creates a blank out.mp4 file. |
what about setting selection to Any?
it also looks like there might be a couple different ways to try and debug. mind you, i don't use mint or nemo so i can't test run them, but these are options from the sample action in the repo: Quote:
Quote:
|
Cordx
Below is the output I get when running the context action in debug mode Code:
# watch_established: "/org/gnome/terminal/legacy/" (establishing: 0) |
i don't see anything that seems particularly helpful there unfortunately.
|
The shell script from shruggy will add one of the images to the out.mp4 file. Even though I select multiple images, only the last image selected gets inserted into the out.mp4 file. Does anyone know how to add all of the selected images to the out.mp4 file?
Code:
#!/bin/bash |
Untested but I think you may need to create a string with the files names so the command format is like:
exec ffmpeg -framerate 1 -i file1 -i file2 -vf scale=500:300 out.mp4 Code:
infile="" When you select the files in nemo are they all highlighted? You can add some debug code to see what files are actually being selected. Code:
echo "$@" >> /home/username/selected_files.dat |
michaelk
I added your code and the out.mp4 file did not get created. But it did create the dat file with the below information. Quote:
|
Forget my loop code...
Well at least the action is working correctly and multiple files are being sent to your script. Lets try a few more tests From your /home/mike/Videos directory (just to make things simple) does the basic ffmpeg command work from the command line? ffmpeg -framerate 1 -i acaproni_maldives.jpg -i adeole_yosemite.jpg -i agucklhorn-lake_brienz.jpg -vf scale=500:300 out.mp4 If that does not work it is a ffmepg syntax error and we need to go back to the man page... If that works then try adding some more debug code to your script. echo "${@/#/-i }" >> /home/mike/selected_files.dat |
I also added a | less after the out.mp4 and received an error in the open terminal. It gave the full path to the first file I selected then with the error of "No such file or directory" I wasn't able to copy the output. As soon as I clicked on the terminal it when blank.
Code:
exec ffmpeg -framerate 1 $infile -vf scale=500:300 out.mp4 | less |
Forget nemo for the moment. Lets see if ffmpeg works as expected.
From the terminal try running Code:
cd ~/Videos |
All times are GMT -5. The time now is 10:15 AM. |