NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Docker amd64 v
« Previous 1 2 3 4 5 … 9 Next »
Docker postprocessing script

 
  • 0 Vote(s) - 0 Average
Docker postprocessing script
aTF6i
Offline

Member

UK
Posts: 136
Threads: 11
Joined: Dec 2021
#1
2024-11-06, 11:26 PM
Hi all

I've been trying to find out where to both put a postprocessing.sh script in docker and finding out how to process transcode my recordings

As far as I am aware, I need to turn off auto record and then stick it in /config/scripts

I'd like to process differently based on resolution - Can someone help me review?

Code:
#!/bin/bash
RECORDING_PATH="$1"
OUTPUT_PATH="$(dirname "$RECORDING_PATH")"

# Get video resolution
RESOLUTION=$(ffmpeg -i "$RECORDING_PATH" 2>&1 | grep -oP '(?<=, )\d+x\d+(?=,)' | head -1)

# Define output file path
OUTPUT_FILE="$OUTPUT_PATH/$(basename "${RECORDING_PATH%.*}").ts"
echo "OUTPUT FILE: $OUTPUT_FILE"

# Remove commercials
comskip "$RECORDING_PATH"

# Check resolution and apply different processing
if [[ "$RESOLUTION" == "1920x1080" ]]; then
    echo "Processing HD video"
    ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset ultrafast -crf 51 -c:a copy "$OUTPUT_FILE"
elif [[ "$RESOLUTION" == "1280x720" ]]; then
    echo "Processing 720p video"
    ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset ultrafast -crf 51 -c:a copy "$OUTPUT_FILE"
else
    echo "Processing SD video"
    ffmpeg -i "$RECORDING_PATH" -c:v libx264 -preset ultrafast -crf 51 -c:a copy "$OUTPUT_FILE"
fi

# Check if transcoding was successful
if [[ $? -eq 0 && -f "$OUTPUT_FILE" ]]; then
    echo "Transcoding successful, removing original file"
    rm "$RECORDING_PATH"
else
    echo "Transcoding failed, keeping original file"
fi

# Send notification
echo "Recording processed: $(basename "$RECORDING_PATH")"
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 53,117
Threads: 957
Joined: May 2006
#2
2024-11-06, 11:41 PM (This post was last modified: 2024-11-06, 11:41 PM by mvallevand.)
I said I wouldn't help with scripts but this might help others too. For Docker and other Linux you would need to install jq and it is useful for scripting and easier than regex.

Code:
ffprobe -v panic -print_format json -show_format -show_streams -select_streams v /media/recordings/Samples/BakeOff.ts | jq -r '.streams[0].width'  returns 1080

for the sample you gave yesterday. this is the output

Code:
{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_tag_string": "[27][0][0][0]",
            "codec_tag": "0x001b",
            "width": 1920,
            "height": 1080,
            "coded_width": 1920,
            "coded_height": 1080,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 3,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "16:9",
            "pix_fmt": "yuv420p",
            "level": 40,
            "color_range": "tv",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "false",
            "nal_length_size": "0",
            "ts_id": "1",
            "ts_packetsize": "188",
            "id": "0x100",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/90000",
            "start_pts": 152234,
            "start_time": "1.691489",
            "duration_ts": 2257200,
            "duration": "25.080000",
            "bits_per_raw_sample": "8",
            "extradata_size": 51,
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0,
                "multilayer": 0
            }
        }
    ],
    "format": {
        "filename": "BakeOff.ts",
        "nb_streams": 2,
        "nb_programs": 1,
        "nb_stream_groups": 0,
        "format_name": "mpegts",
        "format_long_name": "MPEG-TS (MPEG-2 Transport Stream)",
        "start_time": "1.408000",
        "duration": "25.363489",
        "size": "11231308",
        "bit_rate": "3542511",
        "probe_score": 50
    }
}

Martin
aTF6i
Offline

Member

UK
Posts: 136
Threads: 11
Joined: Dec 2021
#3
2024-11-06, 11:47 PM
That does look easier to read than the regex - I must admit - Copilot has been helping
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 53,117
Threads: 957
Joined: May 2006
#4
2024-11-06, 11:49 PM
If you want less fancy without jq

ffprobe -v panic -select_streams v:0 -show_entries stream=width BakeOff.ts

Martin
aTF6i
Offline

Member

UK
Posts: 136
Threads: 11
Joined: Dec 2021
#5
2024-11-06, 11:50 PM
I guess I'll stick it in that folder and see if it does anything
aTF6i
Offline

Member

UK
Posts: 136
Threads: 11
Joined: Dec 2021
#6
2024-11-07, 12:45 AM (This post was last modified: 2024-11-07, 12:50 AM by aTF6i.)
Are you aware of if the /config/scripts/postprocessing.sh is correct location/filename ?

I have chmod+x, also as stated in the other post



...Just checking the logs . I can see no reference to it running

Auto transcode is also off
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 53,117
Threads: 957
Joined: May 2006
#7
2024-11-07, 01:13 AM
Deja vu https://forums.nextpvr.com/showthread.php?tid=65873 Linux is case sensitive,

Martin
aTF6i
Offline

Member

UK
Posts: 136
Threads: 11
Joined: Dec 2021
#8
2024-11-07, 01:14 AM
Yeah - I tried that already.

Don't think it is that - I've managed to get it once. Could be only triggering on fully completed recordings (not cancelled) - I'll post once I'm sure
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 53,117
Threads: 957
Joined: May 2006
#9
2024-11-07, 01:17 AM
Right the script page on the wiki talks about PostCancel sh and bat.

Martin
aTF6i
Offline

Member

UK
Posts: 136
Threads: 11
Joined: Dec 2021
#10
2024-11-07, 01:18 AM
Aha - That would make sense.

Still testing - That will certainly help!
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  Migrating from Windows to Docker? boringgit 2 208 2025-06-09, 07:58 PM
Last Post: boringgit
  Comskip segfaults with comskip embedded in amd64 docker SickBoy 6 647 2025-02-24, 11:18 PM
Last Post: SickBoy
  Issues with Session Handling Behind Caddy Reverse Proxy in Docker: invalid session user001 5 625 2025-01-10, 08:23 PM
Last Post: sub
  Docker container becomes unresponsive overnight wapkaplet 6 853 2025-01-10, 04:47 PM
Last Post: wapkaplet
  Docker image upgrade ceejayemm 9 1,150 2025-01-07, 11:27 PM
Last Post: pkscout
  Current guide for NextPVR docker on Unraid? wapkaplet 1 950 2024-12-20, 02:40 AM
Last Post: wapkaplet
  NextPVR with Docker and Fritzbox icompas 9 866 2024-12-12, 02:50 PM
Last Post: icompas
  Can't get postprocessing.sh to run themarf 3 558 2024-11-18, 02:41 PM
Last Post: themarf
  XMLTV folder for Docker stevil 1 491 2024-09-25, 06:56 PM
Last Post: mvallevand
  Add Intel iHD Driver to Docker Image for NextPVR thelanofvilles 8 1,484 2024-06-16, 08:10 PM
Last Post: thelanofvilles

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode