Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Solution-Bash] Automating condense over all files with custom input and output DIRs #15

Open
825i opened this issue Jan 31, 2025 · 4 comments

Comments

@825i
Copy link

825i commented Jan 31, 2025

Hey,

I just want something simple like:

  1. ~/impd/newvideos
  2. ~/impd/newaudio

Where impd takes videos from folder 1 and throws the audio in folder 2, both of which I can have synced automatically.

Unfortunately at the moment it looks like I have to move the file again from immersionpod/whatever because it's in a painful location.

EDIT: Wew lad, I got carried away...

@825i
Copy link
Author

825i commented Jan 31, 2025

Nevermind, bash to the rescue I guess.

This script takes all files from impd/newvideos and rips the audio into impd/newaudio
It doesn't spam the terminal, but still shows which files are done and which is still in progress.

If I do say so myself, it is quite clean. Try it yourself and see.

process.sh

#!/bin/bash

# Check for existing .ogg files
if ls newaudio/*.ogg >/dev/null 2>&1; then
    echo "WARNING: Audio files already exist in newaudio folder!"
    echo "Please remove or move existing .ogg files before running this script."
    echo "Press 'q' to exit..."
    
    while read -r -n1 key; do
        if [[ $key == "q" ]]; then
            echo
            exit 0
        fi
    done
fi

# Initialize counter
count=1

# Count total files
total=$(ls -1 newvideos/* | wc -l)

echo "Starting audio extraction for $total files..."
echo "-------------------------------------------"

# Process each video file
for video in newvideos/*; do
    # Get first 10 chars of filename
    basename=$(basename "$video")
    prefix=${basename:0:10}
    
    # Create output filename
    outfile="newaudio/${prefix}${count}.ogg"
    
    # Show progress (using carriage return to stay on same line)
    printf "\rProcessing file %d of %d: %s -> %s" "$count" "$total" "$basename" "${prefix}${count}.ogg"
    
    # Run impd command with progress output
    impd condense -i "$video" -o "$outfile" 2>&1 | while read -r line; do
        printf "\r\033[K%s" "$line"
    done
    
    # Print completion message for this file
    echo -e "\rDONE $basename"
    
    # Increment counter
    ((count++))
done

echo "-------------------------------------------"
echo "All files processed successfully!"
echo "Press 'q' to exit..."

# Wait for 'q' key
while read -r -n1 key; do
    if [[ $key == "q" ]]; then
        echo
        break
    fi
done

I can test the script now and autorun the script later without the "q" prompt when new video files are detected in newvideos and the files in newaudio are synced to my phone for Antenna pod. Case closed.

@825i 825i changed the title How to change default output DIR when using add/rotate? [Solution-Bash] Automating condense over all files with custom input and output DIRs Jan 31, 2025
@825i
Copy link
Author

825i commented Jan 31, 2025

It is important to mention that this obviously just runs condense -i etc. on each file and assumes that your video's only/first audio track is a RAW Japanese track. I only download/watch RAWs with no other audio tracks. Though I think the script could be easily customized to do pretty much anything at this point.

@tatsumoto-ren
Copy link
Member

The problem here is that likely most people aren't going to use impd the way you specifically designed it. I get why you made it the way you did, but I just don't need all the rotate/archive/etc.

It is designed with mpd and ncmpcpp in mind. Basically, impd assumes that you're going to listen to condensed audio using ncmpcpp and makes it easy to integrate with it. But it's totally fine to use it any other way.

@tatsumoto-ren
Copy link
Member

So how do I change the output directory?

The config file supports the music_dir setting. However, as I understand it, you need something different. How about we introduce immersionpod_dir instead? Then it would be able to point to any location and won't create additional folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants