Converting an entire folder of videos to PSP format?

Started by flyhigh, July 30, 2020, 12:00:16 PM

Previous topic - Next topic

flyhigh

Greetings all,

This converter works great for converting single files. The auto PSP option + Video -> Configure -> PSP setting have successfully converted all videos I have thrown at it to play on a PSP. However, I'm trying to convert hundreds of episodes for PSP view and the guides I found weren't as helpful for batch conversion on the current software. My attempt at batch converting from looking at this post (https://avidemux.org/smif/index.php/topic,19036.0.html) was something like this:

./avidemux_2.7.6.appImage --load /path/to/source --run /path/to/python.py --save /path/to/output/file.mp4 --quit

I made a custom .py file from the PSP auto configuration settings I mentioned at the beginning of the post. However, this code isn't working. Can anyone here provide assistance? Appreciate any support I get here.

eumagga0x2a

Quote from: flyhigh on July 30, 2020, 12:00:16 PM
I made a custom .py file from the PSP auto configuration settings I mentioned at the beginning of the post. However, this code isn't working.

"This code isn't working" conveys no usable information. Do you run your command line in a console or as a part of a shell script? Do you get some sort of an error message in the console? For starters, please let me see the .py file.

eumagga0x2a

Quote from: flyhigh on July 30, 2020, 12:00:16 PM
I'm trying to convert hundreds of episodes for PSP view and the guides I found weren't as helpful for batch conversion on the current software.

Was the topic https://avidemux.org/smif/index.php/topic,19014.msg88315.html among those guides? Methinks it can be easily adapted for the task as long as you don't ask for recursion.

flyhigh

#3
Quote from: eumagga0x2a on July 30, 2020, 08:21:59 PM
Quote from: flyhigh on July 30, 2020, 12:00:16 PM
I made a custom .py file from the PSP auto configuration settings I mentioned at the beginning of the post. However, this code isn't working.

"This code isn't working" conveys no usable information. Do you run your command line in a console or as a part of a shell script? Do you get some sort of an error message in the console? For starters, please let me see the .py file.

Hello. I run my command line in console. Below is the code for my py file

#PY  <- Needed to identify #
#--automatically built--

adm = Avidemux()

adm.clearSegments()
adm.addSegment(0, 0, 8461567000)
adm.markerA = 0
adm.markerB = 8461567000
adm.setPostProc(3, 3, 0)
adm.videoCodec("x264", "useAdvancedConfiguration=True", "general.params=CBR=1000", "general.threads=0", "general.preset=ultrafast", "general.tuning=none", "general.profile=baseline", "general.fast_decode=False", "general.zero_latency=False"
, "general.fast_first_pass=True", "general.blueray_compatibility=False", "general.fake_interlaced=False", "level=30", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=2", "MinIdr=0", "MaxIdr=250", "i_scenecut_threshold=40"
, "intra_refresh=False", "MaxBFrame=2", "i_bframe_adaptive=0", "i_bframe_bias=0", "i_bframe_pyramid=0", "b_deblocking_filter=False", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0", "cabac=True"
, "interlaced=False", "constrained_intra=False", "tff=True", "fake_interlaced=False", "analyze.b_8x8=False", "analyze.b_i4x4=True", "analyze.b_i8x8=False", "analyze.b_p8x8=True", "analyze.b_p16x16=False"
, "analyze.b_b16x16=False", "analyze.weighted_pred=2", "analyze.weighted_bipred=True", "analyze.direct_mv_pred=3", "analyze.chroma_offset=0", "analyze.me_method=0", "analyze.me_range=16", "analyze.mv_range=-1"
, "analyze.mv_range_thread=-1", "analyze.subpel_refine=7", "analyze.chroma_me=True", "analyze.mixed_references=True", "analyze.trellis=1", "analyze.psy_rd=1.000000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True"
, "analyze.dct_decimate=True", "analyze.noise_reduction=0", "analyze.psy=True", "analyze.intra_luma=11", "analyze.inter_luma=21", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=10"
, "ratecontrol.qp_max=51", "ratecontrol.qp_step=4", "ratecontrol.bitrate=0", "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=0"
, "ratecontrol.ip_factor=1.000000", "ratecontrol.pb_factor=1.000000", "ratecontrol.aq_mode=1", "ratecontrol.aq_strength=1.000000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=40")
adm.addVideoFilter("swscale", "width=480", "height=208", "algo=1", "sourceAR=3", "targetAR=1", "lockAR=True", "roundup=False")
adm.addVideoFilter("addBorder", "left=0", "right=0", "top=32", "bottom=32")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"und")
adm.audioAddTrack(0)
adm.audioCodec(0, "LavAAC", "bitrate=160");
adm.audioSetMixer(0, "STEREO");
adm.audioSetResample(0, 48000)
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0, 0)
adm.setContainer("MP4", "muxerType=1", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "rotation=0", "clockfreq=0")


The GUI opens and then reads "Cannot find a demuxer for /path/to/source" (not literally the path, just my path in this case), "Could not open file" and then the software closes.

eumagga0x2a

Quote from: flyhigh on July 31, 2020, 02:19:02 PM
The GUI opens and then reads "Cannot find a demuxer for /path/to/source" (not literally the path, just my path in this case), "Could not open file" and then the software closes.

Thanks, this means that the failure occurs even before the project script gets parsed. Are you able to load the source video using Ctrl+O in Avidemux main window? If yes, the path to this video in your script is wrong. If no, we should look at the file.

Regarding the .py script, you should remove everything except of

adm = Avidemux()
adm.setContainer("MP4", "muxerType=1", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "rotation=0", "clockfreq=0")


as you need just to set the muxer configuration.

flyhigh

I changed the contents of the py file to what you shared in the code. Ctrl + O does open the correct directory. I still get the same "Cannot find a demuxer" error. Is there a way I can create a crash log or something to share?

eumagga0x2a

#6
Quote from: flyhigh on August 01, 2020, 02:24:26 PM
Ctrl + O does open the correct directory.

Well, by default the file dialog will open the last directory from where a file has been loaded. The question is whether Avidemux can load the file.

QuoteI still get the same "Cannot find a demuxer" error.

From GUI or from the command line?

edit: I meant, when opening the file using Ctrl+O or when opening the file using the --load command line option?

QuoteIs there a way I can create a crash log or something to share?

Please redirect the console output of Avidemux to a file, then compress (gzip, zip or 7z) it and attach it to your reply.

/path/to/appImage > ~/admlog.txt 2>&1


flyhigh

Terminal text attached. Also, what were you getting at with this line?

/path/to/appImage > ~/admlog.txt 2>&1

eumagga0x2a

Thanks, Avidemux cannot load a directory with --load, this command probes and on successful identification loads only a single file. You need either the python solution from a topic I linked to or to implement iteration over directory content in shell script.

eumagga0x2a

#9
Quote from: flyhigh on August 01, 2020, 02:54:01 PM
what were you getting at with this line?

The command redirects stdout and stderr from Avidemux to file "admlog.txt" in your home directory. Maybe

COMMAND 2>&1 | tee ~/admlog.txt

would have been better as it would both write the standard output (stdout) and standard error output (stderr) of COMMAND to admlog.txt and print them as usual to the terminal.

flyhigh

flyhigh@pop-os:~$ COMMAND 2>&1 | tee ~/admlog.txt
COMMAND: command not found


Am I still reading this wrong?

flyhigh

Quote from: eumagga0x2a on August 01, 2020, 02:59:48 PM
Thanks, Avidemux cannot load a directory with --load, this command probes and on successful identification loads only a single file. You need either the python solution from a topic I linked to or to implement iteration over directory content in shell script.

Could you please post reference code you're talking about that would likely be more translatable to how I'm trying to batch convert? So I go from

./avidemux_2.7.6.appImage --load /media/flyhigh/5TB/source/ --run /media/flyhigh/5TB/source/source.py --save /mnt/2TB\ Desktop/Videos/PSP


To what code?

eumagga0x2a

Quote from: flyhigh on August 01, 2020, 03:40:56 PM
flyhigh@pop-os:~$ COMMAND 2>&1 | tee ~/admlog.txt
COMMAND: command not found


Am I still reading this wrong?

COMMAND was used as placeholder for whatever command whose terminal output you need to capture.

eumagga0x2a

Quote from: flyhigh on August 01, 2020, 03:42:34 PM
Could you please post reference code you're talking about that would likely be more translatable to how I'm trying to batch convert? So I go from

./avidemux_2.7.6.appImage --load /media/flyhigh/5TB/source/ --run /media/flyhigh/5TB/source/source.py --save /mnt/2TB\ Desktop/Videos/PSP


To what code?

If you choose a shell script based solution and assuming you want to convert all standard *.mp4 files in /media/flyhigh/5TB/source to PSP-compatible mp4 files in /mnt/2TB\ Desktop/Videos/PSP:

for file in /media/flyhigh/5TB/source/*.mp4; do ./avidemux_2.7.6.appImage --load "$file" --run /media/flyhigh/5TB/source/source.py --save "/mnt/2TB Desktop/Videos/PSP/$(basename "$file")" --quit; done

(--quit is necessary, I think, else you will end up with as many Avidemux instances as there are .mp4 files in the source folder).

You would be probably better off with the command-line version of the Avidemux app, not available in the appImage but, of course, available when you build Avidemux from source.

flyhigh

Thank you for the code. Initially, I got a Could not find *.mp4 error, then I changed for file in /media/flyhigh/5TB/source/*.mp4 to for file in /media/flyhigh/5TB/source/ and the new error I started getting on some of the files became Error seeking to 0ms and the files were resaving into my PSP folder without actually changing container to mp4 or becoming smaller at all. I would like to keep using the AppImage as I don't think using an AppImage is why I'm having these problems still and the AppImage is easier to update but will build the source if you think that would be the next troubleshooting step.