Pushing TinyPy implementation beyond it's limits

Started by MrPeach, February 27, 2017, 08:16:42 AM

Previous topic - Next topic

MrPeach

Hi there.

As someone with a huge (20 TB) library of videos, I need something automated to make sure all my videos are of a format I require.

The Python scripting stuff in AviDemux seems like it should easily lend itself to a solution, but digging through the source code was a letdown as it seems some of my required functionality is not present, at least as far as I could tell by a cursory look. If it is, the API functions were not readily apparent.

My intention is to point my script at a directory and have it do all the grunt work I usually do by hand with FFMPEG.
If it's not in MP4 format, repackage it (unless there is a non-text subtitle I want to use).
If a video exceeds my desired dimensions I'd want to rescale it.
If it's not AVC1, I want to transcode it. (I've got to keep the transcode demand on my Synology-based Plex server to a minimum.)
If there are multiple audio tracks I want to be able to pick the desired source, preferring English and AAC, and dump the rest.
If it's not AAC, I want to transcode it.
If there are more than two channels, I want to down-mix it. (None of my playback devices has surround sound.)
If there are subtitle tracks and the audio is not English, I want to select an English one and dump the rest.
If the desired subtitle is text but not timed-text, transcode it.
Lastly I want to create a log file so I can see what all my little monster has been up to.

I can handle the coding (been writing code for 40 years), but if the system functionality isn't present I'm basically screwed. The video stuff seems complete, but the audio stuff seems lacking and the subtitle stuff non-existent.

Can anyone enlighten me on how (or if it's possible) to do the things above that I haven't got a clue about?

Otherwise it's back to manually using FFMPEG, and my hobby becoming a job.
Or perhaps I can add the missing functionality to AviDemux, if allowed. :D
Or I could do what I've been putting off for so long and write an automatic file analyzer (probably use mediainfo if it provides a useful command line) that generates the appropriate FFMPEG command parameters. :p

Thx!


The functional breakdown is as follows:

Prompt the user (me) for the directory to process (does seem present)
Recursively walk directories starting at a particular location (does seem present)

Load a video (does seem present)

Query video Codec (does seem present)
Query video height and width (does seem present)
Set output video codec (does seem present)
set output video scaling (does seem present)
Configure output video codec settings (particularly faststart for MP4) (not sure but it seems like it should be present)

Obtain audio track count (does seem present)
enumerate audio tracks, obtaining codec, channel count, and ISO 639 language (does not seem present)
Select a source audio track to output and ignore the rest (does not seem present)
Set output audio codec (does seem present)
Configure output audio codec settings (particularly down-mix to 2 channel) (does not seem present)

Obtain subtitle track count (does not seem present)
Enumerate subtitle tracks, obtaining codec and ISO 639 source language (does not seem present)
Select a subtitle track (if it's English and the audio is not) and dump the rest (does not seem present)
Set output subtitle codec (if desired source is text but not timed-text) (does not seem present)

Write the file with the desired settings (does seem present)

Perform other file IO like file delete and rename (not sure but it seems like it should be present in the Python implementation)

mean

Only one level of folder parsed, no recurse

Obtain audio track count (does seem present)
enumerate audio tracks, obtaining codec, channel count, and ISO 639 language (does not seem present)
> Not sure
Select a source audio track to output and ignore the rest (does not seem present)
> Is present
Configure output audio codec settings (particularly down-mix to 2 channel) (does not seem present)
> is present

Obtain subtitle track count (does not seem present)
> no subtitle support

Write the file with the desired settings (does seem present)

EEMcGee

If your in running it on windows you can easily use a batch file along with a .py file for the video and audio settings.  Here are some batch files I have made to do what you want.  You just need to avi to whatever input video file type you have, change the name of the .py file to yours, and output file type from .mp4 to whatever you want.  This one runs recursively, processing all sub folders too.  Just take out the /R if you don't want that.  Open text editor(notepad) and copy the two lines below into it(as two lines) then save as the name you want with .bat at the end.  You can also have look and not recode any files that already have a recoded file in the directory.
  Just use
     "" for /R %%f in (*.avi) do if not exist %%f.mp4 %avidemux% --load "%%F" --run "12 FPS Animation.py" --save "%%~dpF%%~nF.mp4" --quit ""

set avidemux="C:\Program Files\Avidemux 2.6 - 64 bits\avidemux.exe"
for /R %%F in (*.avi) do %avidemux% --load "%%F" --run "12 FPS Animation.py" --save "%%~dpF%%~nF.mp4" --quit