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
+18.4k Golang : Generate thumbnails from images
+11.2k Golang : Delay or limit HTTP requests example
+12.2k Golang : Search and extract certain XML data example
+7.2k Golang : How to detect if a sentence ends with a punctuation?
+6.7k Fix sudo yum hang problem with no output or error messages
+5.9k Fontello : How to load and use fonts?
+5.3k Golang : fmt.Println prints out empty data from struct
+18.6k Golang : convert int to string
+23k Golang : Print out struct values in string format
+8.3k Golang : How to check if input string is a word?
+5.6k Get website traffic ranking with Similar Web or Alexa
+4.6k Golang : How to pass data between controllers with JSON Web Token