Skip to main content
15 events
when toggle format what by license comment
Oct 20, 2022 at 20:04 history edited Rotem CC BY-SA 4.0
added 66 characters in body
Oct 20, 2022 at 19:54 history edited Rotem CC BY-SA 4.0
C++ example
Feb 18, 2022 at 13:55 comment added Rakshit Kothari I stand corrected @Rotem, the code works just as is. The issue was caused due to another logic failing in my code. time.sleep is not required.
Feb 17, 2022 at 22:06 comment added Rakshit Kothari @rotem that's right, I am. Basically I have some sort of loop which goes over a list of videos to be edited and saved using your method. The only modification I've made is I called del process after process.stdin.close(). After deletion, I just time.sleep(2). This fixed the issue for me.
Feb 17, 2022 at 20:09 comment added Rotem @RakshitKothari When I started using the above approach, I thought we may need to add some waiting. Today I know that process.stdin.close() flushes the buffers to the file, and closes the file. process.wait() statement is actually executed after FFmpeg process is already terminated (all threads are safely closed). process.terminate() is not required at all. Are you executing the above code as is, and getting 0 frames?
Feb 17, 2022 at 18:28 comment added Rakshit Kothari There is a chance you may get X265 encodes 0 frames. This is most likely because the threads initiated by ffmpeg aren't safely closed. It helps to add time.sleep(2) post video write out.
Feb 17, 2022 at 14:03 comment added Rakshit Kothari Thank you so much! I think I am going to resort to your approach as default to write out videos! <3
Oct 12, 2020 at 13:59 review Suggested edits
Oct 12, 2020 at 19:00
Jul 1, 2020 at 20:48 history edited Rotem CC BY-SA 4.0
shlex.split instead of split
Jul 1, 2020 at 20:03 comment added GlabbichRulz .split() will break file paths that contain spaces if they are quoted like this '... -crf 24 "{output_filename}"', that's why i would prefer the shlex solution, but you are right that in many cases .split() will suffice.
Jul 1, 2020 at 16:38 comment added Rotem Thank you, I updated the post for Linux support. Instead of shlex.split(...), you may also use '...'.split()
Jul 1, 2020 at 16:35 history edited Rotem CC BY-SA 4.0
Updates for Linux execution
Jul 1, 2020 at 15:07 comment added GlabbichRulz Great Code! For anyone getting "file not found: ffmpeg...", try using import shlex and shlex.split(...) around the command string, this will split the string at spaces while preserving quoted parts of the strings like the filepath, also writing /usr/bin/ffmpeg instead of ffmpeg helps against the execution path issue.
Apr 18, 2020 at 0:09 vote accept CommunityBot
Apr 17, 2020 at 22:10 history answered Rotem CC BY-SA 4.0