RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Possible to re-encode videos and keep same name?

    Scheduled Pinned Locked Moved Help and Support
    reencode
    12 Posts 3 Posters 441 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      g0nz0uk
      last edited by

      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

      WeirdHW 1 Reply Last reply Reply Quote 0
      • WeirdHW
        WeirdH @g0nz0uk
        last edited by

        @g0nz0uk If your videos are saved uniformly or if you're handy with regular expressions, you could try Bulk Rename Utility after Handbraking.

        G 1 Reply Last reply Reply Quote 0
        • G
          g0nz0uk @WeirdH
          last edited by

          @WeirdH

          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.

          1 Reply Last reply Reply Quote 0
          • WeirdHW
            WeirdH
            last edited by WeirdH

            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.

            BRU.png

            1 Reply Last reply Reply Quote 1
            • G
              g0nz0uk
              last edited by

              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.

              WeirdHW 1 Reply Last reply Reply Quote 0
              • WeirdHW
                WeirdH @g0nz0uk
                last edited by

                @g0nz0uk Glad to help.

                I just prinstcreened the program, cropped and added the arrow in Photoshop. Googled it.

                G 1 Reply Last reply Reply Quote 0
                • G
                  g0nz0uk @WeirdH
                  last edited by

                  @WeirdH

                  Nice, a trickier question I have is can I make the first letter lowercase instead of uppercase?

                  1 Reply Last reply Reply Quote 0
                  • G
                    g0nz0uk
                    last edited by g0nz0uk

                    Think I've done, what a great tool.

                    1 Reply Last reply Reply Quote 1
                    • WeirdHW
                      WeirdH
                      last edited by

                      Wouldn't know from memory. Probably box 4 'case', right?

                      1 Reply Last reply Reply Quote 0
                      • ClydeC
                        Clyde
                        last edited by Clyde

                        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 the output 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:

                        • https://catswhocode.com/ffmpeg-commands/
                        • https://www.dedoimedo.com/computers/ffmpeg-guide.html

                        Just as an alternative answer to the topic's title question, for you or anyone else who stumbles upon this thread. 😊

                        G 1 Reply Last reply Reply Quote 1
                        • G
                          g0nz0uk @Clyde
                          last edited by

                          @Clyde wow this is great thanks. I wished I'd done this first it would of save a lot of time.

                          1 Reply Last reply Reply Quote 0
                          • ClydeC
                            Clyde
                            last edited by

                            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. 😉

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post

                            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.