Skip to content

Instantly share code, notes, and snippets.

@travis-g
Last active January 26, 2019 05:28
Show Gist options
  • Save travis-g/68ca00cd9e7cfd26814041259fe7f962 to your computer and use it in GitHub Desktop.
Save travis-g/68ca00cd9e7cfd26814041259fe7f962 to your computer and use it in GitHub Desktop.
ffmpeg Conversions
#!/bin/bash
TYPE=${1:-no type provided}

for FILE in $(ls *.${TYPE} | tr -d "'")
do
    # Get 0-based index of English subtitle stream
    INDEX=$(($(ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 $FILE | sed -n '/eng/=')-1))
    # Convert
    ffmpeg -y \
        -i $FILE \
        -filter_complex "[0:v:0]subtitles=${FILE}:si=${INDEX}[v]" \
        -map "[v]" \
        -crf 27 \
        -preset veryfast \
        -map 0:a:0 -c:a copy \
        ${FILE//\.${TYPE}/.mp4}
done

Background Transcoding

‘/usr/lib/plexmediaserver/Plex Transcoder’
‘-codec:#0x100’ ‘h264’
‘-codec:#0x101’ ‘ac3’
‘-ss’ ‘1334’
‘-i’ ‘/media/TV/Ridiculousness/Season 10/Ridiculousness (2011) - S10E02 - 21 Savage.ts’
‘-filter_complex’ ‘[0:#0x100]scale=w=720:h=406[0];[0]format=pix_fmts=yuv420p|nv12[1]’
‘-map’ ‘[1]’
‘-codec:0’ ‘libx264’
‘-crf:0’ ‘21’
‘-maxrate:0’ ‘1686k’
‘-bufsize:0’ ‘3372k’
‘-r:0’ ‘59.939999999999998’
‘-preset:0’ ‘veryfast’
‘-level:0’ ‘5.1’
‘-x264opts:0’ ‘subme=2:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none’
‘-force_key_frames:0’ ‘expr:gte(t,1332+n_forced*3)’
‘-map’ ‘0:#0x101’
‘-metadata:s:1’ ‘language=eng’
‘-codec:1’ ‘aac’
‘-ar:1’ ‘48000’
‘-channel_layout:1’ ‘stereo’
‘-b:1’ ‘162k’
‘-segment_format’ ‘mpegts’
‘-f’ ‘ssegment’
‘-individual_header_trailer’ ‘0’
‘-segment_time’ ‘3’
‘-segment_start_number’ ‘444’
‘-segment_copyts’ ‘1’
‘-segment_time_delta’ ‘0.0625’
‘-segment_list’ ‘http://127.0.0.1:32400/video/:/transcode/session/a5d9ea5d6764d240-com-plexapp-android/dce1839d-397e-4353-8ab0-9cc800285e7d/seglist’
‘-segment_list_type’ ‘csv’
‘-segment_list_size’ ‘2147483647’
‘-max_delay’ ‘5000000’
‘-avoid_negative_ts’ ‘disabled’
‘-map_metadata’ ‘-1’
‘-map_chapters’ ‘-1’
‘media-%05d.ts’
‘-start_at_zero’
‘-copyts’
‘-y’
‘-nostats’
‘-loglevel’ ‘quiet’
‘-loglevel_plex’ ‘error’
‘-progressurl’ ‘http://127.0.0.1:32400/video/:/transcode/session/a5d9ea5d6764d240-com-plexapp-android/dce1839d-397e-4353-8ab0-9cc800285e7d/progress’
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment