Possible to re-encode videos and keep same name?
-
Hello,
My arcade mp4 video previews were ok on the Pi3 but not on the Pi4, I’ve used Handbrake to re-encode a few and they work after, but Handbrake renames the files slightly different so my gamelist.xml gets mismatched so the videos don’t play as they are looking for a slightly different name for each video. I can’t go and edit 100s of lines of code or rename all the videos.
I tried to change some of the output save settings in Handbrake but none would keep the original source name as it’s save new name.
My current gamelist.xml has all the right names and cover art working, I just need to sort the video names.
Any ideas?
Thanks
-
@g0nz0uk If your videos are saved uniformly or if you're handy with regular expressions, you could try Bulk Rename Utility after Handbraking.
-
Thanks that tool looks good.
I have over 1000 files like this below that have the word video at the end:
1941Video.mp4
I need to rename all so there is a hyphen between the name and the word video like this:
1941-Video.mp4
I just can't figure it out yet.
-
It's pretty easy to only change a hyphen. Navigate to your files. Put the change you want in box 3 'Replace' (step 1). You can ignore everything else. Select the files to which you want to apply the change in the list above (probably all of them in your case) and then hit Rename (step 2).
Please note if you have any files that already have the hyphen and you apply this change to them as well, they will end up with doubled up hyphens, like
--video
, so exercise caution. -
You are brilliant! Thanks.
I did a test and my videos are now showing in Retropie after re-encoding them and then renaming.
What snipping/screen grab tool is that, I like the green arrow.
-
-
Nice, a trickier question I have is can I make the first letter lowercase instead of uppercase?
-
Think I've done, what a great tool.
-
Wouldn't know from memory. Probably box 4 'case', right?
-
Ultimately, Handbrake is "just" a frontend for a couple of encoding libraries like libavcodec from the FFmpeg project. If you just want to convert all videos in a given directory with the same options, you could also use ffmpeg directly to do that.
Here's an example for the Retropie's command shell
bash
that you could use directly on your Pi, another Linux machine or any OS with a compatible command shell.mkdir -p output; for video in *.mp4; do ffmpeg -i "$video" output/"${video%.*}".mkv; done
This will create the subdirectory
output
if it is not already present, convert any.mp4
files in the current directy into.mkv
files, and save them to theoutput
directory, choosing any video and audio codecs that are compatible with mkv containers automatically. They will keep their names except for the mp4 extension. In that example,video
is a variable that contains the video filename of the current for…do…done loop,$video
recalls that variable, and${video%.*}
recalls it without the file extension (i.e..mp4
). The quotation marks are important if the videos' filenames contain any special characters like spaces, brackets, slashes and so on.You can use this as a baseline for any other
ffmpeg
invocation, there are many guides on the net about that, like these to more recent ones:Just as an alternative answer to the topic's title question, for you or anyone else who stumbles upon this thread. 😊
-
@Clyde wow this is great thanks. I wished I'd done this first it would of save a lot of time.
-
My pleasure. Such one-liners are a good way to automate things with relatively little syntax research needed. 😎 (They're actually multiple commands separated by semicolons.)
That said, they also can be a source for agonizing frustration if they don't do what you want – until they do, eventually. 😉
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.