Omxplayer cuts off roughly the last second of sound - mp3

I am using Omxplayer to play a sound file stored as .MP3
The issue I am facing is that on sound files with duration > 1 second, but < 10 appear to have the end (roughly a second) of the file cut off abruptly as if the track had finished.
I am unsure what could be causing this issue as Omxplayer throws no errors and just cuts out to its usual "Have a nice day"
This is on Raspbian on Pi.

Workaround I ended up using was to convert my .mp3 files to .wav, and that stopped them from being cut off. The conversion was easy enough, and it might help down the line since .wav seems to be more acceptable for a variety of tools, e.g. aplay.
I looped through each of them and used the tool lame to convert
sudo apt-get install lame
lame --decode /path/to/file.mp3 /new/path/to/file.wav
Since I happened to be having this problem in Node, I'll share that full solution to convert all .mp3 files in a directory to .wav in a loop. This assumes you have a folder full of only mp3 files, and doesn't check to enforce that:
const fs = require("fs");
const { exec } = require("child_process");
const files = fs.readdirSync("./audio_mp3/");
files.forEach((file) => {
let newFile = file.replace('.mp3', '.wav')
exec(`lame --decode ./audio_mp3/${file} ./audio_wav/${newFile}`);
console.log(`Created ${newFile} in folder ./audio_wav/`);
})

Related

Problem using magenta to generate song: SyntaxError: (unicode error) 'unicodeescape'

I want to generate music with magenta and a neural network model for a project.
I found this simple example and wanted to try it first to understand how it works: https://www.twilio.com/blog/training-a-neural-network-on-midi-music-data-with-magenta-and-python
Apparently i have to modify the type of my inital data (which is midi file) "in note to sequences"
Here is what i have:
convert_dir_to_note_sequences \
--input_dir == 'C:\Users\mista\Downloads\CLEANED_DATA\CLEANED_DATA' \
--output_file = tmp/notesequences.tfrecord \
--recursive
and here is the error i get:
File "C:\Users\mista\AppData\Local\Temp/ipykernel_28328/3757950315.py", line 3
--output_file = tmp/notesequences.tfrecord
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
I saw some people saying that you could use an 'r' before your path to solve this but i've tried many ways, i'm still stuck
I am following the same tutorial and after a couple hours of bashing my head against the keyboard, I managed to run the neural net properly. It seems like the problem is a lot of conflicting dependencies and deprecations, so you may have to play around with what version of Python you're using once you set everything else up properly (I used Python 3.7 and did pip install magenta).
I used Powershell (right click on Windows home button --> run Powershell as admin). You'll want to set up a virtual environment in your current working directory, as the tutorial advises. And now we get to your problem in particular - make sure you're running the command all in one line, as such:
convert_dir_to_note_sequences --input_dir == 'C:\Users\mista\Downloads\CLEANED_DATA\CLEANED_DATA' --output_file = tmp/notesequences.tfrecord --recursive
That should start converting all the midi files to NoteSequences objects. If you have any more trouble, please follow up and I'll see what I can do to help.

How to burn / hardcode subtitle to the downloaded youtube video with youtube-dl

This command downloads the video and embed the auto-generated youtube subtitle to the file
youtube-dl.exe -ci -f "bestvideo[ext=mp4]"+"bestaudio[ext=m4a]" --write-auto-sub --embed-subs --merge-output-format mp4 https://www.youtube.com/watch?v=k4rCdHsdiss
However the subtitle is only embedded. I want it to be burned/hardcoded so that it can be played on non-embed supporting platforms such as treadmill
I am using windows 10
youtube-dl cannot burn the subtitles by itself. You need to use postprocessors like FFmpeg or avconv for it. youtube-dl use them internally for some tasks. As you successfully used bestvideo+bestaudio argument, you already have installed one of these in your system. avconv is a fork of FFmpeg, so they accept mostly the same arguments. I'll show the FFmpeg case here.
youtube-dl has a feature to add arguments to the postprocessors but I can't see how to use it to solve this task.
Other possibility is using --exec flag. Regretfully, I have not a Windows machine now so I wrote only Linux variant.
youtube-dl -f "[height=360][ext=mp4]+bestaudio[ext=m4a]" --write-sub --write-autosub --embed-subs --exec "mkdir temp && ffmpeg -i {} -vf subtitles={}:force_style='FontName=Arial' -acodec copy temp/{} && mv -f temp/{} {} && rm -r temp" --restrict-filenames AO4In7d6X-c
This is a one-line command but it has several flaws:
You must use --restrict-filenames to make it work. No more nice filenames.
I see no way to have more than one option for subtitle style, i. e. font name, font color and font size.
Very cumbersome.
So my best guess is using FFmpeg manually or with a batch script after downloading the video with youtube-dl. Not tested on Windows but it should work well.
ffmpeg.exe -i "input.mp4" -vf subtitles="filename='input.mp4':force_style='FontSize=20,FontName=Arial'" -c:v libx264 -x264-params crf=22 -preset fast -profile:v high "output.mp4"
input.mp4 must be a file with embedded subtitles.
FFmpeg must be compiled with the support of libass. Type ffmpeg.exe without arguments and look for --enable-libass. libx264 is recommended too.
To tune the speed of encoding you may use a different preset. Allowed values are ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Faster presets mean bigger file size.
To tune quality use crf parameter. The smaller the number the better quality but also the bigger file size. Numbers from 16 to 30 are optimal.
If the file fails to play on some old players, you may try to use the profile baseline and lower the level.

Identifying a Programming Language

So I have a software program that for reasons that are beyond this post, I will not include but to put it simply, I'd like to "MOD" the original software. The program is launched from a Windows Application named ViaNet.exe with accompanying DLL files such as ViaNetDll.dll. The Application is given an argument such as ./Statup.cat. There is also a WatchDog process that uses the argument ./App.cat instead of the former.
I was able to locate a log file buried in my Windows/Temp folder for the ViaNet.exe Application. Looking at the log it identifies files such as:
./Utility/base32.atc:_Encode32 line 67
./Utilities.atc:MemFun_:Invoke line 347
./Utilities.atc:_ForEachProperty line 380
./Cluster/ClusterManager.atc:ClusterManager:GetClusterUpdates line 1286
./Cluster/ClusterManager.atc:ClusterManager:StopSync line 505
./Cluster/ClusterManager.atc:ConfigSynchronizer:Update line 1824
Going to those file locations reveal files by those names, but not ending with .atc but instead .cat. The log also indicates some sort of Class, Method and Line # but .cat files are in binary form.
Searching the program folder for any files with the extension .atc reveals three -- What I can assume are uncompiled .cat files -- files. Low and behold, once opened it's obviously some sort of source code -- with copyright headers, lol.
global ConfigFolder, WriteConfigFile, App, ReadConfigFile, CreateAssocArray;
local mgrs = null;
local email = CreateAssocArray( null);
local publicConfig = ReadConfigFile( App.configPath + "\\publicConfig.dat" );
if ( publicConfig != null )
{
mgrs = publicConfig.cluster.shared.clusterGroup[1].managers[1];
local emailInfo = publicConfig.cluster.shared.emailServer;
if (emailInfo != null)
{
if (emailInfo.serverName != "")
{
email.serverName = emailInfo.serverName;
}
if (emailInfo.serverEmailAddress != "")
{
email.serverEmailAddress = emailInfo.serverEmailAddress;
}
if (emailInfo.adminEmailAddress != null)
{
email.adminEmailAddress = emailInfo.adminEmailAddress;
}
}
}
if (mgrs != null)
{
WriteConfigFile( ConfigFolder + "ZoneInfo.dat", mgrs);
}
WriteConfigFile( ConfigFolder + "EmailInfo.dat", email);
So to end this as simply as possible, I'm trying to find out two things. #1 What Programming Language is this? and #2 Can the .cat be decompiled back to .atc. files? -- and vice versa. Looking at the log it would appear that the Application is decoding/decompiling the .cat files already to interpret them verses running them as bytecode/natively. Searching for .atc on Google results in AutoCAD. But looking at the results, shows it to be some sort of palette files, nothing source code related.
It would seem to me that if I can program in this unknown language, let alone, decompile the existing stuff, I might get lucky with modding the software. Thanks in advance for any help and I really really hope someone has an answer for me.
EDIT
So huge news people, I've made quite an interesting discovery. I downloaded a patch from the vendor, it contained a batch file that was executing ViaNet.exe Execute [Patch Script].atc. I quickly discovered that you can use Execute to run both .atc and .cat files equally, same as with no argument. Once knowing this I assumed that there must be various arguments you can try, well after a random stroke of luck, there is one. That being Compile [Script].atc. This argument will compile also any .atc file to .cat. I've compiled the above script for comparison: http://pastebin.com/rg2YM8Q9
So I guess the goal now is to determine if it's possible to decompile said script. So I took a step further and was successful at obtaining C++ pseudo code from the ViaNet.exe and ViaNetDll.dll binaries, this has shed tons of understanding on the proprietary language and it's API they use. From what I can tell each execution is decompiled first then ran thru the interpreter. They also have nicknamed their language ATCL, still no idea what it stands for. While searching the API, I found several debug methods with names like ExecuteFile, ExecuteString, CompileFile, CompileString, InspectFunction and finally DumpObjCode. With the DumpObjCode method I'm able to perform some sort of dump of script files. Dump file for above script: http://pastebin.com/PuCCVMPf
I hope someone can help me find a pattern with the progress I made. I'm trying my best to go over the pseudo code but I don't know C++, so I'm having a really hard time understanding the code. I've tried to seperate what I can identify as being the compile script subroutines but I'm not certain: http://pastebin.com/pwfFCDQa
If someone can give me an idea of what this code snippet is doing and if it looks like I'm on the right path, I'd appreciate it. Thank you in advanced.

Why are my files smaller after I FTP them using this Python program?

I'm trying to send some files (a zip and a Word doc) to a directory on a server using ftplib. I have the broad strokes sorted out:
session = ftplib.FTP(ftp.server, 'user','pass')
filewpt = open(file, mode)
readfile = open(file, mode)
session.cwd(new/work/directory)
session.storbinary('STOR filename.zip', filewpt)
session.storbinary('STOR readme.doc', readfile)
print "filename.zip and readme.doc were sent to the folder on ftp"
readfile.close()
filewpt.close()
session.quit()
This may provide someone else what they are after but not me. I have been using FileZilla as a check to make sure the files were transferred. When I see they have made it to the server, I see that they are both way smaller or even zero K for the readme.doc file. Now I'm guessing this has something to do with the fact that I stored the file in 'binary transfer mode' <--- whatever that means.
This is where my problems lie. I have no idea at all (yet) what is meant by binary transfer mode. Is it simply that I have to use retrbinary to return the files to their original state?
Could someone please explain to me like I'm a two year old what has happened to my files? If there's any more info required, please let me know.
This is a fantastic resource. Solved most of my problems. Still trying to work out the intricacies of FTPs, but I guess I will save that for another day. The link below builds a function to effortlessly upload files to an FTP without the partial upload problem that I've seen experienced by more than one Stack Exchanger.
http://effbot.org/librarybook/ftplib.htm

Unable to find audio stream

I'm trying to adapt a code in order to add a sound capture feature (on a live stream), with the help of ffmpeg and directshow.
When i try to play with ffplay the AVIsynth file, everything works perfectly i've got the audio and video. But when i open this input file by code i only find the video stream.
The Avs file :
V = DirectShowSource("Decklink_HDMI.grf", fps=10, framecount=1000000000, seek=false, audio=false)
A = DirectShowSource("Decklink_Audio.grf", fps=1, framecount=1000000000, video=false)
AudioDub(V, A)
The opening code :
ffmpeg::AVInputFormat * ifmt;
ifmt = ffmpeg::av_find_input_format("avs");
// Open input file
if(ffmpeg::avformat_open_input(&pFormatCtx, filename.toStdString().c_str(), ifmt, NULL) != 0)
When i make a variable lookout on gdb just after the opening.
i'm looking at nb_streams in pFormatCtx->nb_streams and it's at 1
The only stream i can find in pFormatCtx->stream is a video one. And that's why i'm not able to capture the sound.
So i'm asking if i'm doing something wrong with my opening or if i miss something.
Ps : I know the code shown is short but the problem appears at this very step !
Thank you
Kurt
-- EDIT --
I've also noticed that when I dump the AVFormatContext the video stream got a 456x32 size.
And i can find this very same size of the window displayed when i try to launch a corrupted script with ffplay.
The original video format when i play the correct script with ffplay is of 1920x1080
I think my problem is maybe deeper than the simple fact of not being able to get the audio stream.
I'm trying to find out how to know the error message that is displayed on this 456x32 windows
-- EDIT2 --
I Find out what is written on this image and my problem is solved, badly placed avs script an old one was is place.
I'm ashamed.
My bad,
A badly placed avs file was my problem.
Anyway ffmpeg is a bit painful in his way of showing error, being forced to make a snapshot without any error msg or exception raised (or maybe did i failled).