lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
543 stars 24 forks source link

Best way to approach this folder structure #144

Closed joeblack2k closed 2 years ago

joeblack2k commented 2 years ago

Hello,

Right now this is my situation:

Movie files are on a NAS with the structure /Movies/movie/movie.mkv From my Macbook (M1 Pro) that would translate into /Volume/Movies/movie/movie.mkv

i'm trying to batch process all sub folders in Movies to get a H265 treatment.

i've tried running "ruby batch.rb" on /Volume/Movies/ but the queue.txt keeps empty (does it even scan for subfolders?)

I also have Windows PC with an RTX 2080TI perhaps that is faster then M1 but then the same question applies

how can i batch process subfolder/file.mkv?

i hope any of you can help me because i'm getting really excited about this tool!

samhutchins commented 2 years ago

With the batch script on the Wiki, you need to fill in queue.txt yourself, with the full path to each file you want to transcode. I'm not sure how to create that file on macOS I'm afraid, hopefully someone with a bit of find-fu can help with that

On Windows you can use PowerShell and do this:

Get-ChildItem -Recurse -Include *.mkv | Select-Object -ExpandProperty FullName | Set-Content queue.txt

samhutchins commented 2 years ago

I think you can do this on macOS:

find "$(pwd -P)" -name "*.mkv" > queue.txt

lisamelton commented 2 years ago

@samhutchins Thanks for your explanation and suggestions, sir! Always appreciated. 👍

@joeblack2k Does that answer your question?

joeblack2k commented 2 years ago

Yes this generates a nice queue.txt!

does the script uses the fullpath as begin? like Z:\movie\other_transcode so that the new file is in the same directory or does it spit all the files from the place you run the ruby command? e.g Z:\ ?

i still can't run it because of an error it throws but i'll make a new issue so that other people can troubleshoot better! thanks!

samhutchins commented 2 years ago

@joeblack2k

If all your source films are in, for example, /Volumes/NAS/Movies/ and you want the transcoded versions to be in /Users/joeblack2k/Movies, you do this:

In Terminal

  1. Switch to target directory cd /Users/joeblack2k/Movies
  2. Create the queue file: find /Volumes/NAS/Movies -name "*.mkv" > queue.txt
  3. Run the batch script: ruby batch.rb

The script automatically finds the queue file.

If you want non-default behaviour from other-transcode you just pass those options into the batch script, like so

ruby batch.rb --hevc

joeblack2k commented 2 years ago

ok, i understand that but what if (because of things like subtitles)

movies are

/Volumes/NAS/Movies/movie1/movie.mkv /Volumes/NAS/Movies/movie2/movie.mkv

i guess you want the script to excecute the other-transcode bin inside the directory

e.g /Volumes/NAS/Movies/movie1/other-transcode so that the output is in the right directory

is there a way to edit the batch.rb to execute the other-transcode with the full path?

joeblack2k commented 2 years ago

ah.. why is this always so complicated 😆

i'm trying something in the line of this:

PS Z:> Get-ChildItem -Path Z:\ | where {$.PsIsContainer} | foreach {$.DirectoryName\other-transcode -hevc -eac3 *.aa1; }

but that gets me nowhere

it just needs to go in each directory and execute i will rename all movie files to something gibberish like .aa1 and then it spits out a mkv and i will delete all .aa1 files afterwards

CaptSonic commented 2 years ago

I use this on Windows with Powershell:

$Pfad = "SourceFolder/" $oldvids = Get-ChildItem -Filter "*.mkv" "SourceFolder/" -Recurse

foreach ($oldvid in $oldvids) { $encodevid = $Pfad + $oldvid

other-transcode $encodevid --1080p --crop auto --main-audio 1 --add-audio 2=surround --hevc --nvenc --10-bit --add-subtitle auto --nvenc-recommended --aac-only --fdk-vbr 5 }

Works like a charme

joeblack2k commented 2 years ago

i understand that script but doesnt that spit out all transcoded movies in one directory ? you drag all 500 files back in to the original folders?

you want other-transcode to run in the folder itself so the file gets created in the right folder..

... if only you could do --output ;)

loshlee commented 2 years ago

If you change to the output directory, then run the command (example: "cd /path/to/output;other-transcode...", that should have the same result as an output option.

samhutchins commented 2 years ago

I guess the challenge is re-creating the folder structure of the source inputs though, right?

If the input is in SOURCE/movie1/movie1.mkv I think the goal is for the output to be in OUTPUT/movie1/movie1.mkv. You'd have to copy any subtitle files in the source version over to output as well

joeblack2k commented 2 years ago

i just want to use the source folder

Y:\Movies\Movie1\movieblabla.mkv Y:\Movies\Movie2\movieblelble.mkv

and that like 500 times its all indexed by things like Plex. so throwing all the files into Y:\Movies\ is going to be a mess

so because other-transcode doesnt do --output

you have to:

cd Y:\movies\movie1\ and then do "other-transcode movieblabla.mkv --1080p --crop auto --main-audio 1 --add-audio 2=surround --hevc --nvenc --10-bit --add-subtitle auto --nvenc-recommended --aac-only --fdk-vbr 5"

then:

cd to Y:\movies\movie2\ and do "other-transcode movieblelble.mkv --1080p --crop auto --main-audio 1 --add-audio 2=surround --hevc --nvenc --10-bit --add-subtitle auto --nvenc-recommended --aac-only --fdk-vbr 5"

so you have to batch the cd Y:\movies\movie1\ cd Y:\movies\movie2\ cd Y:\movies\movie3 and so forth

samhutchins commented 2 years ago

For the record, I think what you're doing isn't the greatest idea. It's usually better to work on your transcodes outside of Plex's library folders, otherwise it may cause issues with Plex constantly scanning.

other-transcode doesn't support --output to help prevent accidental overwrites, and to promote good practice with keeping your source file and transcoded output apart.

However, I have noodled on a powershell script that may help:

$movies = Get-ChildItem -Recurse -Include "*.mkv"

foreach ($movie in $movies)
{
    $folder = $movie.Directory
    $name = $movie.Name
    Set-Location $folder

    $src = Join-Path $folder "src"
    if ( ! (Test-Path $src))
    {
        New-Item -ItemType Directory $src
    }

    $src = Join-Path $src $name

    if ( ! (Test-Path $src))
    {
        Move-Item $movie $src
    }
    else
    {
        "ERROR: file already exists: $src"
    }

    & other-transcode $src
}

It will transcode in place, but it doesn't delete the input file once it's done. Each source file will be left in a "src" subfolder next to the transcoded output

So, if your folder structure is like this:

Y:\movies\movie1\movie1.mkv,
Y:\movies\movie2\movie2.mkv

You'll end up with this after running that script:

Y:\movies\movie1\src\movie1.mkv,
Y:\movies\movie1\movie1.mkv,
Y:\movies\movie2\src\movie2.mkv,
Y:\movies\movie2\movie2.mkv

If you're absolutely certain you no longer want the source files after you're done, the script can be modified to include Remove-Item, but I'll leave that to you. I'd advise against it, and I'd advise transcoding into a separate location before re-importing into Plex

joeblack2k commented 2 years ago

You sir, are a genius.. script is running and fans are spinning.. many many thanks!

lisamelton commented 2 years ago

@joeblack2k Excellent! And many thanks to @samhutchins because he is, indeed, a genius.

So, I will close this issue since I'm assuming it has been resolved.