Does someone have a script that converts all videos files from 264 to 265 and changes the name?

Even an attempt at it would be appreciated

looks like I will not convert anything at all.

It is definitely not worth converting x264, even less x265, to av1, if you are the only consumer. Just think about it. To get any “significant” space gains, while keeping a close to original quality (you will inevitably lose some detail), you need to spend maybe at least 3-4x more time encoding than the actual total video length, probably more, maybe 5x. Taking an average of 3GB/hour, 2TB is about 650 hours. x5 that’s like 3250 hours. An 8 core ryzen will have like 150W total system load encoding av1. 3250h * 0.15 kWh =~ 500 kWh. 500 kWh * 0.15$/kWh (I took an optimistic electricity cost for these days, might be a lot more depending where you live) = $75 in electricity costs. Setting encodes, moving files around, will also take up some significant amount of time. You will gain maybe 1TB, if compressing audio to opus as well, less than that you will have significant video quality losses. 1TB of hdd space is worth $15 these days. And you don’t waste time/electricity+money/video quality.

So it’s only worth to get existing published encodes of the material you own, of if you are planning on publishing yourself. Or just for fun, if you want to experiment and encode one movie to see what’s the best you can get out of av1.

source: https://www.reddit.com/r/AV1/comments/ymrs5v/id_like_to_encode_my_entire_library_to_av1/

  • beta_tester@lemmy.mlOP
    link
    fedilink
    English
    arrow-up
    38
    arrow-down
    1
    ·
    10 months ago

    What about

    #!/bin/bash
    
    find . -type f -name '*.mp4' -exec sh -c 'ffmpeg -i "$0" -c:v libx265 "${0%.mp4}-conv.mp4""' {} \;
    
    • alphacyberranger@lemmy.world
      link
      fedilink
      English
      arrow-up
      14
      arrow-down
      1
      ·
      10 months ago

      Kind of. But this is encoded using CPU and will be time consuming. Search for FFMPEG GPU acceleration. The installation (building) will take some time but the time saved during mass conversion of videos will be worth it. I believe FFMPEG supports RCOM on Amd and Cuda on Nvidia . So any gpu should be fine.

      • SmoothLiquidation@lemmy.world
        link
        fedilink
        English
        arrow-up
        12
        ·
        10 months ago

        I generally think that for storage/archiving you should use CPU encoding and only use GPU for things like transcoding where real-time results are crucial.

        GPU encoding is a lot worse quality than CPU, and you can’t change the settings to what you want. Better to just accept the extra time requirement to get a better result.

        • desentizised@lemm.ee
          link
          fedilink
          English
          arrow-up
          5
          ·
          10 months ago

          This. Also unless you have raw BluRay sources recompressing already compressed video isn’t exactly a great idea either way. The space savings will never be worth the loss in visual quality. If you were to retain the quality the space used would probably be similar even with a more efficient / newer codec.

        • db2@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          10 months ago

          GPU decoding is the way to go, it frees up the CPU to do the encoding so you’re still cutting down time without adding GPU weirdness to the output.

        • alphacyberranger@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          10 months ago

          I agree with you. With GPU encoding the options to tweak are less and the quality drop is noticeable if the source ain’t that great. But if you try to encode a full movie on a weak CPU it’s going to take ages.

          • SmoothLiquidation@lemmy.world
            link
            fedilink
            English
            arrow-up
            2
            arrow-down
            1
            ·
            10 months ago

            I personally would not use it for anything that is being saved on your drive. Using cpu encoder is slower but I just let it run over night or whatever and it will be done later.

            Save GPU encoding for when you need it smaller right now like when you are transcoding on the fly.

    • navigatron@beehaw.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      10 months ago

      That looks promising. Just keep in mind that this will take a very long time to run. I believe there is a *arr out there that can manage this / show progress, but the name escapes me

    • alphacyberranger@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      10 months ago

      Or use A FFMPEG script to sort all the x264 videos and keep it in a separate folder and use handbrake with GPU and mass convert all the videos in that particular folder. AV1 is also good but as some other user said, your hardware needs to support it.

  • arthurpizza@lemmy.world
    link
    fedilink
    English
    arrow-up
    33
    ·
    10 months ago

    Just keep in mind you’re going to lose quality. Any time you compress something in a lossy format is going to get worse.

    Another note, if you’re not worried about quality loss, you might look into AV1 over h265. Much better compression. Though, that might not work with your setup.

      • Eldritch@lemmy.world
        link
        fedilink
        English
        arrow-up
        8
        arrow-down
        1
        ·
        edit-2
        10 months ago

        Short answer yes. Much longer. More complex answer. Mostly. If you’re planning on your devices being able to support hardware decoding and large resolutions/ high frame rates. Sit-top boxes and appliances are not quite there right now. I believe the newer Chromecast HD absolutely supports av1. But most of the older Chromecast including Chromecast TV do not support it directly. So it will have to be re-encoded to be streamed.

        That said, the codec itself is fantastic. As an example for animated content, especially. I have some super high quality rips of the old old cartoon from the '80s of the Ghostbusters franchise. We’re talking nearly a gigabyte encoded in h264 for a 22 minute episode. At SD resolution. Upscaling them to 720p and encoding them with av1. And a constant rate factor of about 40. They’ve been coming in between 80 and 200 MB in episode depending upon how much movement there is etc. The one thing with av1 is That as it degrades it sort of smooths everything which works out perfectly for animation most of the time. It can work for live action etc. As well. But you will encounter smoothing as detail is lost. But overall, it is much more preferable to the H style codex so far

  • snekerpimp@lemmy.world
    link
    fedilink
    English
    arrow-up
    10
    ·
    edit-2
    10 months ago

    I use a handbrake container and a watch folder. Just move what you want converted to the watch folder and handbrake does the rest.

    • UberMentch@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      Agreed. I’ve converted my library all to 265 using Tdarr, I’m up to 11.5 TB of saved space. I like having all my media be uniform for my Plex server, and Tdarr is a nice and easy tool to achieve it

    • beta_tester@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      2
      ·
      10 months ago

      I did that a long time ago and I was more pleased with unmanic but I’ve got one job and that’s just to convert 264 to 265 which should be straightforward and easy and many people should want this as ee all have limited storage

  • Mechanite@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    10 months ago

    I use tdarr for my large scale conversions to AV1 but I use shutterencoder for everything else. It’s like handbrake but friendly for working in large batches and the UI is really nice https://www.shutterencoder.com/en/ It will add H265 to the end of the name too

    • beta_tester@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      Thx, I guess I move to av1 then since many recommend it and say it’s ready for prime time

      • Mechanite@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        10 months ago

        If whatever you’re doing works with av1 then I’d say go for it. I do AV1 for Plex since all of my devices can hardware decode, however I keep my own videos at h264 software encoded (for smaller filesizes) since Synology photos doesn’t support AV1.

  • alphacyberranger@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    10 months ago

    Maybe a script using ffmpeg can be made. For further time saving, do it using ffmpeg hardware acceleration using gpu.

    • beta_tester@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      edit-2
      10 months ago

      Like this? https://lemmy.ml/comment/7587233

      I can’t use hardware acceleration as I’ve got an nvidia card and I wasted already many hours on it. Buying another card and smashing the old one against the wall would be better

      • Vinny_93@lemmy.world
        link
        fedilink
        English
        arrow-up
        5
        ·
        10 months ago

        Why exactly can’t you use hardware acceleration with an nvidia card? We have Arch Linux with a Quadro P400 and using the nvidia driver Tdarr runs super smoothly. The way to get all your content in x265 is just by decoding and encoding, which Tdarr, Handbrake etc can do. But it’s one stream per nvenc/nvdec at a time so it takes time.

        • beta_tester@lemmy.mlOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          10 months ago

          Thx, this whole thread tells me to have another look into it. It may have been just me or the wrong guides but I was desperatly searching for a way and couldn’t find one.

  • Faceman🇦🇺
    link
    fedilink
    English
    arrow-up
    5
    ·
    10 months ago

    I have several media libraries so I set up file flows to only perform compression based on a few specific rules. I never used to compress, but 2 years ago I ran out of space and had no money to upgrade disks, so I started compressing, intending for it to be temporary until I could add space. but it became part of my servers automatic setup and it works great.

    TV show episodes between 3 and 5gb that aren’t already H265 get compressed with RF21 H265, but files over 5gb get RF22. only files older than 6 weeks get compressed to give people a chance to watch them in original quality. the compression flow also includes making a stereo aac downmix audio track for added compatibility. so anything that is already H265 or low bitrate is left untouched to avoid unnecessary compression.

    Movies get a similar treatment and H264 files under 5gb are ignored, 5-20gb gets RF21 and 20gb plus gets RF22. All of this is done with 10bit H265 as it tends to look a little better. the amount of compression I;m doing is pretty small, a 3gb TV show for example might end up being 2gb or so, and a 30gb movie will usually end up around 12-15gb at most. I could push harder, particularly for movies but I don’t see a need as i’ve saved 13TB so far with this setup.

    If sonarr/radarr download new versions of something (a TV show gets released on bluray for example) it will go back into the loop and get compressed again, but now it will be a higher quality.

    4K shows and movies are always left untouched, they are in a separate library and are only accessible to certain clients.

  • Kevnyon@kbin.social
    link
    fedilink
    arrow-up
    4
    ·
    10 months ago

    I use ffmpeg batch AV converter, you can convert multiple files automatically, its great for that.

      • db2@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        10 months ago

        Got one ready made for that but I’m not where the script is atm, I’ll post it later tonight. It can be used directly or as a gnome/cinnamon context menu script, one or many files at once.