
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Sur d’autres sites (1907)
-
How to generate video as fast as possible with subtitles and audio on node.js + ffmpeg ?
12 septembre 2018, par DSereginIntro :
We receive from the site some pieces of text
Pieces arrive to node.js-serverAt the output we need to get a video, merged from all the pieces of text, voiced by the machine voice, with the added subtitles and audio substrate. So that user could be share this video in the social networks. MKV format doesn`t supported by VK.com
The options that we have tried :
1. Get all the text at once, generate the entire speech, create a file with subtitles, burn subtitles in the video .mp4 (vk.com does not support the .mkv container). It took 12 seconds of operations for a 45-second video on the local computer.
2. Generate audio and video files for each piece of text (with added subtitles). It took one second for one piece of text. At the final request, we merge all pieces together. The last request (merging) took 2-3 seconds, which is already bearable.The second variant looks acceptable in terms of speed, but if you run 50 clients at the same time, then the computer (tested on a MacBook PRO 2013, 2.4 GHz i7, 8gb 1600 Mhz DDR3, SSD 256gb) processed only 1 piece from 1 client in 60 seconds (60 times slower), then the computer hung tight.
- Generation of audio is done through Amazon Polly
- Generate subtitles via https://github.com/gsantiago/subtitle.js#readme
- From node.js we call ffmpeg using https://github.com/fluent-ffmpeg/node-fluent-ffmpeg
- Resolution for video - 1280x720
The commands we used :
- Burn video subtitles and trim up to conditional 6 seconds (in the code send unix timestamp)
ffmpeg -i import / back.mov -i export_0 / tmp.srt -scodec mov_text -t 6 export_0 / output.mov
- Merging all audio
ffmpeg -i audio1.mp3 .... -i audio15.mp3 merged.mp3
- Overlay audio-substrate on the text
ffmpeg -i merged.mp3 -i back.mp3 -filter_complex amerge -ac 2-c: a libmp3lame -q: a 4 -shortest audio.mp3
- Merging all videos
ffmpeg -i video.txt -f concat -c copy video.mp4
- Overlay audio on video
ffmpeg -i audio.mp3 -i video.mp4 -i test.mp4 -i export / output.mp3 -c: v copy -c: a aac -map 0: v: 0 -map 1: a: 0 -shortest output .mp4
Questions that torment :
-
Is it faster ?
-
Can I use other codecs or methods of gluing without re-encoding ?
-
Try to call ffmpeg directly without a wrapper ? (in fact, it gives 50-100 ms of speed)
-
Try not to save to disk, and write data to Stream and have them glue together in the end ?
-
avformat/avienc : Expand master ODML index when its end is reached
19 mars 2015, par Michael Niedermayer