Moviepy: no audio in written videofile when running on heroku - heroku

I am making videos with moviepy. Created locally, the final videofile has audio. When I run the same code on heroku, the final video has no audio.
First, I thought not using the /tmp directory on heroku might be the issue. I also followed advice to add audio parameters to write_videofile. Both didn't solve the problem.
I am using the heroku ffmpeg buildpack.
#Make soundtrack
soundtrack = AudioFileClip('https://storage.googleapis.com/ABC/music.mp3')
soundtrack = soundtrack.set_duration(final_clip.duration)
#Add soundtrack
final_clip = final_clip.set_audio(soundtrack)
#Write videofile
final_clip.write_videofile('tmp/video/combined_movie.mp4',
codec='libx264',
audio_codec='aac',
temp_audiofile='tmp/video/soundtrack-temp-audio.m4a',
remove_temp=False,
fps=10)
#Storing on google cloud
try:
upload_blob('ABC','tmp/video/combined_movie.mp4','tmp/video/combined_movie.mp4')
except:
print('error when uploading final video file to google storage.')
In the console is see:
Moviepy - Building video tmp/video/combined_movie.mp4.
MoviePy - Writing audio in %s
MoviePy - Done.
Moviepy - Writing video tmp/video/combined_movie.mp4
Moviepy - Done !
Moviepy - video ready tmp/video/combined_movie.mp4
Google Cloud Storage upload successful.
Help is appreciated!

Found a solution!
I forked the same buildpack and changed the DOWNLOAD variable to ffmpeg version 4.1.3 (same version installed on my localhost).
Just run this command on your terminal:
heroku buildpacks:add https://github.com/merwane/heroku-buildpack-ffmpeg-latest.git

Related

HEROKU ImageMagick not detected

I'm working on MoviePy to burn subtitles into video. Using TextClip
subData = processSrtFormatData(request.json['subData'])
subtitles = SubtitlesClip(subData, styleForText)
def styleForText(txt):
return TextClip(txt, font='Arial', fontsize=12, color='white')
and when deploy to Heroku. It throws error like in image below
IMG_URL: https://i.ibb.co/0DLMvtc/Untitled.png
I tried to use different buildpacks on Heroku, include:
https://github.com/DuckyTeam/heroku-buildpack-imagemagick
https://github.com/ello/heroku-buildpack-imagemagick
But only
https://github.com/ello/heroku-buildpack-imagemagick
works.
The problem is the 'ello' use imagemagick 6.9 and failed to work with unicode (as shown here). However on local run with imagemagick 7.1, it worked perfectly.
My question is how can I set the buildpack 7.1 on heroku or is there any other way to work with my MoviePy TextClip on unicode
IMG_URL: https://i.ibb.co/xHNmGcz/Untitledsd.png
Many thanks! (sorry for the images, dont have 10 reputation to include inside the question)

How do I install FFMPEG in Heroku and use it?

I would like to use FFMPEG for my bot that I want to host on Heroku. For this I installed the following buildpack: https://elements.heroku.com/buildpacks/jonathanong/heroku-buildpack-ffmpeg-latest.
I added some checks in my source code to check the FFMPEG path:
source = discord.PCMVolumeTransformer(
discord.FFmpegPCMAudio(song.stream_url, executable=FFMPEG_PATH, before_options=beforeArgs),
volume=state.volume)
and the path is:
FFMPEG_PATH = parser.get('MUSIC', 'ffmpeg-path')
In a config file I then have the following:
ffmpeg-path : /usr/bin/ffmpeg
But this does not seem to be the correct path. So how do I get the path of the buildpack at Heroku?
To get the FFMPEG working on Heroku you have to install the following packs:
https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest - FFMPEG.
https://github.com/xrisk/heroku-opus - Avoids OpusNotLoaded() errors.
You can add them under Settings/Buildpacks.
The default path, if needed, is ffmpeg.
You can then launch the bot.

nReco.Video Converter ffMpeg Error

I am using Nreco Video Converter for take video thumbnail on my MVC project. App is working correctly on local but it shows error on live host
Error is
Access to the path 'C:\Inetpub\vhosts********\httpdocs\bin\ffmpeg.exe' is denied.
I did search this file in my code and host bin folder but I can't found. NReco's site says
Simple and easy to use video conversion .NET library: all you need is one assembly (FFMpeg is embedded)
There is no ffmpeg.exe file in local and host bin folder or anywhere.
How can i fix this?
Thanks.
VideoConverter is a .net wrapper for ffmpeg tool (I'm an author of this library) and ffmpeg.exe is extracted into app bin folder (default location) on first use. On your live host asp.net process cannot write to app bin folder; this may be fixed by specifying another location, for example:
var ffmpeg = new FFMpegConverter();
ffmpeg.FFMpegToolPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");

Parse CLI won't upload non-js files

I'm trying to send iOS push notifications using my Cloud Code (I can't use Parse's Push APIs as my app is built using ionic and all their docs expect native).
I have it working as a standalone script locally using nodejs, but when I go to upload it to parse, I get:
Uploading source files
Note that the following files will not be uploaded:
parse_cloud_code/cloud/cloud/cert.pem
parse_cloud_code/cloud/cloud/key.pem
Uploading recent changes to scripts...
The following files will be uploaded:
parse_cloud_code/cloud/cloud/cloud.js
parse_cloud_code/cloud/cloud/cloud_test.js
parse_cloud_code/cloud/cloud/credentials.js
parse_cloud_code/cloud/cloud/fs.js
parse_cloud_code/cloud/cloud/push-notification.js
parse_cloud_code/cloud/cloud/push-notifications_test.js
parse_cloud_code/cloud/cloud/tls.js
Finished uploading files
Error: Failed to load cloud/cert.pem with: Could not find file cloud/cert.pem
at Object.exports.readFile (cloud/fs.js:24:17)
at readFile (cloud/push-notification.js:45:8)
at body (cloud/push-notification.js:56:5)
at cloud/push-notification.js:147:3
at cloud/push-notification.js:156:3
at cloud/cloud.js:5073:5
at cloud/cloud.js:5082:3
at main.js:1:13
How can I get the .pem files into the cloud code? I tried renaming them to .js but then Parse wanted them to actually be syntactically JS files. Imagine that.
I found a workaround for this situation, as I had a similar problem. Any non-js file that I must upload I would rename to .ejs. So the parse CLI will upload it and them you can use it inside your cloud code.

How to stream MP4 files from subdirectories with Flowplayer?

I am using Wowza Media Server to enable streaming of MP4 files and as video player I use Flowplayer.
To get some structure for my content I use sub directories within the configured StorageDir for my Wowza application.
The problem I have is that no matter what URL-format I use, Wowza keep looking for the file in the root storage directory.
I've tried using the URL format specified by Wowza here, but with no luck:
rtmp://[wowza-ip-address]/myapp/_definst_/mp4:mysubdirectory/sample.mp4
I also tried everything suggested in posts on the Wowza forum:
https://www.wowza.com/community/questions/327/mp4-streaming-from-application-sub-directory.html
https://www.wowza.com/community/questions/215/subfolders-in-application-content-folder.html
But Wowza keeps looking in the root storage directory, throwing exceptions like these:
404 b0c9be70-a33c-41ce-9692-199e3a1caccf.mp4
open: java.io.FileNotFoundException:
C:\Program Files (x86)\Wowza Media Systems\Wowza Media Server 3.6.2\content\b0c9be70-a33c-41ce-9692-199e3a1caccf.mp4.flv
(The system cannot find the file specified)
Somehow Wowza thinks it should look for an FLV file in the root storage directory, even though the URL specify that it is an MP4 file in a subdirectory. Why is that?
After spending hours looking into this, I finally found this post on the Wowza forum.
The problem:
Apparently there is an issue with some flash-based video players (like Flowplayer that I use), that accept a single string for the RTMP connection and stream name. Some of these players do not separate the RTMP connection and stream name properly when using sub directories.
When breaking this URL apart:
rtmp://[wowza-address]:1935/vod/_definst_/mp4:subfolder/sample.mp4
The player will use this as the RTMP connection:
rtmp://[wowza-address]:1935/vod/_definst_/mp4:subfolder
The player will then try to play sample.mp4 instead of subfolder/sample.mp4 which will fail.
The solution:
To remedy this problem, there is a plugin for Wowza that fixes the URL, available for download here:
http://www.wowzamedia.com/downloads/forums/collection/WowzaServerAddOnCollection.zip
Unzip the package and copy the JAR file into your Wowza /libs directory, then add this to your /conf/[app-name]/Application.xml configuration file:
<Module>
<Name>ModuleFixStreamPath</Name>
<Description>ModuleFixStreamPath</Description>
<Class>com.wowza.wms.plugin.collection.module.ModuleFixStreamPath</Class>
</Module>
Doing so got it all working for me!
I fix this problem by creating symlinks using PHP code before output video component template
$relativeVideoLink = str_replace("/", "__", $videoFileRelativePath);
if (!file_exists($wowzaDir . $relativeVideoLink)) {
symlink($wowzaDir . $videoFileRelativePath, $wowzaDir . $relativeVideoLink);
}
After creating symlink i put it to tag
<video src="http://00.00.00.00:1935/vod/mp4:<?=$relativeVideoLink?>/manifest.mpd"></video>

Resources