Golang : ffmpeg with os/exec.Command() returns non-zero status
Problem:
You want to use ffmpeg
with os/exec.Command() and Run() to create your video files.
However, it keeps bombing out with the error message:
exit status 1
You are able to execute the command with the supplied parameters and flags just fine on your terminal.
What's going on? How to fix this?
Solution:
Golang's os/exec.Command()
function does not have the shell=true
feature like Python did. ffmpeg is very sensitive to white spaces when running from another program. To fix the problem, simply remove whitespaces by using ,
instead of +
to assemble the flags and parameters to ffmpeg.
For example,
cmd := exec.Command("ffmpeg", "-r "+recordedFPSstring+" -i "+videoFileName+" -r 6 temp_"+videoFileName)
to
cmd := exec.Command("ffmpeg", "-r", recordedFPSstring, "-i", videoFileName, "-r", "6", "temp_"+videoFileName)
See also : Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
By
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+14k Golang : Get current time
+12.4k Golang : Simple client-server HMAC authentication without SSL example
+6k Facebook : How to force facebook to scrape latest URL link data?
+11.4k Golang : How to flush a channel before the end of program?
+28.6k Golang : Change a file last modified date and time
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+16k Golang : Get current time from the Internet time server(ntp) example
+13.1k Golang : List objects in AWS S3 bucket
+5.3k Responsive Google Adsense
+15.1k Golang : Search folders for file recursively with wildcard support
+20.5k Swift : Convert (cast) Int to int32 or Uint32