MLT XML: specifying codec for input data - mlt

I'd like to change the codec ffmpeg inside MLT is using to decode the producer file from native opus to libopus.
The FFmpeg command should be like: ffmpeg -acodec libopus -i 851515232352539900.mkv....
How can I specify that codec via MLT XML? Using acodec doesn't seem to work:
<producer id="producer1">
<property name="resource">test.mp4</property>
<property name="aspect_ratio">1</property>
<property name="mlt_service">avformat</property>
<property name="acodec">libopus</property>
</producer>
Thanks!

You do not mention your MLT version. But if it is recent enough, you should be able to use "acodec" to specify a codec to use:
https://github.com/mltframework/mlt/blob/master/src/modules/avformat/producer_avformat.c#L2852
consider running
melt -query audio_codecs
to see if MLT is aware of libopus

Related

FFmpeg-wasm colorbalance filter always create washed out image, how to fix this?

I'm using FFmpeg wasm in the browser (React.js).
When I want to adjust the colors of a video using the colorbalance videofilter it always produces a washed out image.
await ffmpeg.run("-i", "test.mov", "-vf", "colorbalance=-0.4:-0.2:0.2:-0.4:-0.2:0.2:0:0:0.0", "-pix_fmt", "yuv420p", "test.mp4");
I'm usig the exact same command as in FFmpeg in my terminal (where it works correctly)
ffmpeg -i test.mov -vf colorbalance=-0.4:-0.2:0.2:-0.4:-0.2:0.2:0:0:0.0 -pix_fmt yuv420p output02.mp4
Has someone experienced the same issue?
Washed-out image attached

klish/clish: set startup timeout tag using internal VAR

I'm trying to set klish startup timeout tag using a defined internal VAR but it's not working.
<VAR name="IDLE_TIMEOUT"
help="idle timeout value"
dynamic="true">
<ACTION>
echo -n "60"
</ACTION>
</VAR>
<STARTUP view="myview"
timeout="${IDLE_TIMEOUT}">
<ACTION>
cat /etc/banner
</ACTION>
</STARTUP>
It seems that the variable it not evaluated before calling clish_shell__set_timeout function.
The timeout tag is working fine if I use a fixed value instead of a variable, e.g.
<STARTUP view="myview"
timeout="60">
<ACTION>
cat /etc/banner
</ACTION>
</STARTUP>
I'm running klish 1.7.1.
https://src.libcode.org/pkun/klish/src/2.2/doc/klish.md
Do you have any suggestion or any workaround to make it work?
Thank you!
It seems that the timeout field is not implemented to be set dynamically, it's static and supports digits only.
For more reference take a look at the related issue on the official repository:
http://libcode.org/issues/30

Remove Thumbnail from MP3 FILE - from yt-audio

When using yt-audio, how can you remove the thumbnail image (artwork / screenshot) that comes with the downloaded mp3 file?
Best would be to have a way of doing it by adding an additional argument to the command, but looping through the downloaded files works too if someone knows how to do that.
Just in case, this is the description of the yt-audio usage:
usage: yt-audio [OPTIONS] REQUIRED_ARGS
A simple, configurable youtube-dl wrapper for downloading and managing youtube audio.
Required Arguments (Any/all):
URL[::DIR] Video/Playlist URL with (optional) save directory [URL::dir]
-e, --example1 Example playlist [Custom]
--all All [Custom] Arguments
Optional Arguments:
-h, --help show this help message and exit
-v, --version show version and exit
--use-archive use archive file to track downloaded titles
--use-metadata use metadata to track downloaded titles
--output-format [OUTPUT_FORMAT]
File output format
--ytdl-args [YTDL_ADDITIONAL_ARGS]
youtube-dl additional arguments
Thank you all!!
So in the end, I found the answer to this one myself (quite ashamed of the time it took me though.)
To remove the thumbnail, don't download it.
That sums it up basically.
To not download the thumbnail, I simply needed to edit the common.py file once yt-audio was installed.
The file is in the installation, under: yt_audio/common.py
Editing the common.py file.
In common.py find the Common class, and edit DEFAULT_ARGUMENT_VALUES.
Or simply replace the value assigned to it, with this thumbnail-less version (below).
DEFAULT_ARGUMENT_VALUES = {
'download_command': 'youtube-dl -x -q --print-json --audio-format mp3 --audio-quality 0 '
'--add-metadata -o "$OUTPUT$" $URL$',
'playlist_info_command': 'youtube-dl --flat-playlist -J $PLAYLIST_URL$',
'output_format': '%%(title)s.%%(ext)s',
'ffprobe_command': 'ffprobe -v quiet -print_format json -show_format -hide_banner "$PATH$"',
'output_directory': str(PurePath(Path.home(), "Music"))
}
That's it.

How to access local env variables from ANT file

I have this ANT file that calls a batch file to set the environment variables, before these environment variables are referred to in the ANT script.
So my batch file (set_env.bat) contains:
REM ------ ECLIPSE ------
SET DIR_ECLIPSE=C:\Eclipse
SET DIR_ECLIPSE_MARS=%DIR_ECLIPSE%\eclipse-dsl-mars-2-win32
SET DIR_DEST=C:\mydsl\generated
Then my ANT script will call it like this:
<target name="setvars" >
<exec executable="cmd">
<arg value="/c"/>
<arg value="set_env.bat"/>
<arg value="-p"/>
</exec>
</target>
<property environment="env"/>
<property name="tool" value="${env.DIR_ECLIPSE_MARS}" />
<property name="destDir" value=${env.DIR_DEST}" />
<target name="create_run_jar">
<copy file="${env.DIR_ECLIPSE_MARS}/plugins/org.eclipse.xtext_2.9.1.v201512180746.jar"
todir="${destDir}/myDsl_lib" />
</target>
I keep on getting an error saying the file cannot be found and when I print the log via , I get "[echo] ${env.DIR_ECLIPSE_MARS}". So this means that the env vars are not set.
During copy, it displays this log:
D:\mydsl\antbuild.xml:129: Warning: Could not find file D:\mydsl\${env.DIR_ECLIPSE_4_5_2}\plugins\org.eclipse.xtext_2.9.1.v201512180746.jar to copy.
I execute the setvars target first followed by the create_run_jar.

List of files located in text file to be send as parameter to WinSCP in script mode

I've to create solution that is based on WinSCP and windows batch script. Below are tasks the script has to do:
Save list of files from remote directory, to file located on machine where batch script is run.
Run WinSCP in command mode (/command) using WinSCP script passed as parameter (/script=name_of_script_file.txt) and get files (get command) from previously generated list.
The most important is to get file list, save it and pass names of files located in created file to WinSCP to get them.
How to implement this?
There's no easy way to implement this using WinSCP scripting only. It's possible, see the very end of my answer, but it may not be an ideal solution.
Why do you do this in two steps? Why don't you directly download the directory?
winscp.com /command ^
"option batch abort" ^
"option confirm off" ^
"open scp://user:password#example.com/" ^
"get /path/*" ^
"exit"
If you really need the list (e.g. for some further processing), you can instead of getting a list of files in the directory, get a list of actually downloaded files.
Enable the XML logging, and get the list from the XML log.
winscp.com /xmllog=log.xml /command ^
....
You get a log like:
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="user#host" start="2015-01-30T06:45:57.008Z">
<download>
<filename value="/path/file1.txt" />
<destination value="C:\path\file1.txt" />
<result success="true" />
</download>
<download>
<filename value="/path/file2.txt" />
<destination value="C:\path\file2.txt" />
<result success="true" />
</download>
</session>
If you need a plain-text list, you can use the XSLT to convert it (e.g. download.xslt):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:winscp="http://winscp.net/schema/session/1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match='winscp:download[winscp:result[#success="true"]]/winscp:filename'>
<xsl:value-of select="#value"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
To process it, use any XSLT processor:
Microsoft msxsl.exe (deprecated, but available from Internet Archive)
msxsl.exe log.xml download.xslt
Libxml2 xsltproc.exe:
xsltproc.exe download.xslt log.xml
And you get:
/path/file1.txt
/path/file2.txt
See Transforming XML Log to Text Output Using XSLT Transformation.
To answer your actual question. If you really insist on getting a file list and downloading files according to it, I suggest you use the WinSCP .NET assembly from a PowerShell script.
Use the Session.ListDirectory to retrieve a contents of a remote directory.
See the Session.ListDirectory documentation and its example code.
For recursive listing, you can also use the Session.EnumerateRemoteFiles.
Iterate the results and call the Session.GetFiles for every file.
See the Session.GetFiles documentation and its example code.
If the simple scripting is your preference:
The only way to obtaining a plain text list of remote files reliably, is to use the XML logging to capture an output of the ls scripting command:
winscp.com /xmllog=log.xml /command ^
"option batch abort" ^
"option confirm off" ^
"open scp://user:password#example.com/" ^
"ls /path" ^
"exit"
You get a log like:
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="user#host" start="2015-01-30T07:08:27.749Z">
<ls>
<destination value="/path" />
<files>
<file>
<filename value="." />
<type value="d" />
<modification value="2014-07-28T07:06:49.000Z" />
<permissions value="rwxr-sr-x" />
</file>
<file>
<filename value=".." />
<type value="d" />
<modification value="2015-01-23T12:22:44.000Z" />
<permissions value="rwxr-xr-x" />
</file>
<file>
<filename value="file1.txt" />
<type value="-" />
<size value="1306091" />
<modification value="2015-01-29T23:58:12.000Z" />
<permissions value="rw-rw-rw-" />
</file>
<file>
<filename value="file2.txt" />
<type value="-" />
<size value="88" />
<modification value="2007-11-17T22:40:43.000Z" />
<permissions value="rw-r--r--" />
</file>
</files>
<result success="true" />
</ls>
</session>
Again, use the XSLT to convert the XML log to a plain-text list of files:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:winscp="http://winscp.net/schema/session/1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match='winscp:file[winscp:type/#value="-"]/winscp:filename'>
<xsl:value-of select="#value"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
You get:
file1.txt
file2.txt
To get WinSCP script to download files according to a plain-text list, see scripting example Uploading a list of files. It's for an upload, but just replace the put with the get and reverse an order of arguments to turn it to a download.
Note that the /command parameter does not enter a "command" (scripting?) mode. It's for passing scripting commands on a command line (as used in my answer). You are using a script file (/script). There's no point adding an empty /command parameter to it.
See the documentation of WinSCP scripting command-line parameters.

Resources