Recherche avancée

Médias (91)

Sur d’autres sites (147)

  • Node.js child_process TypeError : Cannot read property '_writableState' of undefined

    15 mai 2018, par functorial

    I am trying to wrap a piece of ffmpeg’s functionality in a Node.js API, using the child_process library, but when I attempt to send any data to ffmpeg’s stdin pipe, I get an error TypeError: Cannot read property '_writableState' of undefined.

    import {spawn} from "child_process"

    export default frames => {
       // Spawn ffmpeg process
       const ffmpeg = spawn("ffmpeg", ["-f", "image2pipe", "-i", "-", "output.mkv"])
       // Send frames to ffmpeg as stdin
       frames.forEach(ffmpeg.stdin.write)

       // Listen for output and errors
       return new Promise((resolve, reject) => {
           const chunks = []

           ffmpeg.stdout.on("data", chunks.push)
           ffmpeg.stderr.on("data", reject(data))
           ffmpeg.on("close", code =>
               resolve(Buffer.concat(chunks))
           )
       })
    }

    Error :

    TypeError: Cannot read property '_writableState' of undefined
       at Writable.write (_stream_writable.js:270:20)
       at Array.forEach (<anonymous>)
       at exports.default (/home/fiendfan1/workspace/nodejs/declare/dist/app/common/encodeVideo.js:21:12)
       at _callee$ (/home/fiendfan1/workspace/nodejs/declare/dist/app/tests/video.js:34:84)
       at tryCatch (/home/fiendfan1/workspace/nodejs/declare/node_modules/regenerator-runtime/runtime.js:65:40)
       at Generator.invoke [as _invoke] (/home/fiendfan1/workspace/nodejs/declare/node_modules/regenerator-runtime/runtime.js:303:22)
       at Generator.prototype.(anonymous function) [as next] (/home/fiendfan1/workspace/nodejs/declare/node_modules/regenerator-runtime/runtime.js:117:21)
       at Generator.tryCatcher (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/util.js:16:23)
       at PromiseSpawn._promiseFulfilled (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/generators.js:97:49)
       at Promise._settlePromise (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/promise.js:574:26)
       at Promise._settlePromise0 (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/promise.js:614:10)
       at Promise._settlePromises (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/promise.js:693:18)
       at Async._drainQueue (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/async.js:133:16)
       at Async._drainQueues (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/async.js:143:10)
       at Immediate.Async.drainQueues [as _onImmediate] (/home/fiendfan1/workspace/nodejs/declare/node_modules/bluebird/js/release/async.js:17:14)
       at runCallback (timers.js:696:18)
    </anonymous>
  • ffmpeg generate video starting from startdate.jpg ending enddate.jpg

    12 février 2014, par John J

    How would I go about using ffmpeg to generator a video from x to y in the directory. I have a startdate image.jpg and an enddate image,jpg which are timestamped. There are thousands of other images in the directory but I just want to create a clip from startimage to endimage with all the images in-between.

    Is it possible to cross fade the images on creation to prevent jirkyness

    One last thing, is there an easy way to return the file name when its created, or should this be specified before ?

    Thanks

  • Handling multiple line subtitles of Right aligned languages(arabic) in Moviepy

    24 décembre 2023, par Stanger Danger

    I am trying to add Arabic subtitles on a video using Moviepy. The issue I'm facing is related to alignment of Arabic text, as it progresses from right to left, instead of left to right in English language.

    &#xA;

    enter image description here

    &#xA;

    As text length gets more and more, Moviepy trims the words from both ends, this issue can be resolved if we break the text into multiple lines. This works well for English language but for Arabic, the first line becomes the last line because of the (Right-Left)alignment.

    &#xA;

    enter image description here

    &#xA;

    The text on Second line should come first on the first line at the start, while end chuck of first text towards the left corner should render on the second line, but it is getting rendered as English language, Left to right alignment.

    &#xA;

    Here is my code :

    &#xA;

    def add_subtitles(address_subtitles, address_video):&#xA;  video = VideoFileClip(address_video)&#xA;  generator = lambda txt: TextClip(txt, font=&#x27;Arial&#x27;, fontsize=22, color=&#x27;black&#x27;, stroke_width=2, method=&#x27;caption&#x27;, align=&#x27;south&#x27;, size=video.size)&#xA;  subtitles = SubtitlesClip(address_subtitles, generator)&#xA;  #print()&#xA;&#xA;  result = CompositeVideoClip([video, subtitles.set_pos((&#x27;center&#x27;,&#x27;bottom&#x27;))])&#xA;  result.write_videofile("arabic_with_hardcoded_subtitles_3.mp4", fps=video.fps, temp_audiofile="temp-audio.m4a", remove_temp=True, codec="libx264"&#xA;  , audio_codec="aac")&#xA;

    &#xA;