Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Articles published on the website

  • Download HLS ( HTTP ) Stream video using python

    27 January, by LeDerp

    I need to download a streaming video(from a URL) using python the command line argument would be:

    ffmpeg -i URL stream.mp4
    

    I know I can use the subprocess command

    subprocess.call('ffmpeg -i '+ URL +' stream.mp4', shell=True)
    

    Is there any alternative like a API that I can use instead of using subprocess command

  • FFmpeg didn't compress file, it increased it instead

    27 January, by RandoUser104

    I tried using ffmpeg on Mac OS to compress a video file.

    ffmpeg -i [FILENAME].mp4 -c:v h264_videotoolbox -b:v [BITRATE]k -c:a aac [OUTPUTFILENAME].mp4
    

    But instead of it compressing my video file, it increased the size by a tiny bit.

  • Flutter FFmpeg moov atom not found whilst running ffmpeg command during recording

    27 January, by GILO

    Hi am currently trying to retrieve 3 second clips of an audio file whilst it is recording in flutter. I am using the recording module flutter sound and flutter ffmpeg.

    I record the audio file with default codec (.aac). The file is saved to the cache getTemporaryDirectory()

    I then copy the file using this flutter ffmpeg code

    List arguments = ["-ss", start.toString(), "-i", inPath, "-to", end.toString(), "-c", "copy", outPath];
    
    await flutterFFmpeg.executeWithArguments(arguments);
    

    Start: start time (e.g. 0) and End: end time (e.g. 3)

    It then returns this error

    FFmpeg exited with rc: 1 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x748964ea00] moov atom not found

    Helpful information:

    1. A moov atom is data about the file (e.g timescale,duration)
    2. I know the inPath exists because I check that before executing ffmpeg command
    3. The outPath is also format .aac
    4. This ffmpeg function is being ran whilst the recording is still occurring
    5. Example inPath uri looks like this /data/user/0/com.my.app/cache/output.aac
    6. I have no problems when running on iOS, only on android

    I would be grateful for help, I have spent many days trying to fix this problem. If you need anymore info please leave a comment. Thanks

  • Why is ffmpeg's hstack so much slower than overlay and pad?

    27 January, by cgenco

    I'm using ffmpeg to stitch together two videos of people chatting into a video with each of them side-by-side, like this:

    left.mp4 + right.mp4 = out.mp4

    Here's the command I'm currently using to get this done, which runs at ~2.5x on my 13" M1 MacBook Pro:

    ffmpeg -y -i left.mp4 -i right.mp4 -filter_complex "
      [0:v] crop=w=in_w/2 [croppedLeft];
      [1:v][1:v] overlay=x=overlay_w/4 [shiftedRight];
      [shiftedRight][croppedLeft] overlay [vout];
      [0:a][1:a] amix [aout]
    " -map "[vout]" -map "[aout]" -ac 2 out.mp4
    

    This command crops the left video to half of its original width (cropping so the video is centered), then shifts the right video a quarter of its width to the right, then overlays the left video on the left half of the output merged with the shifted right video.

    One day on my weekly fun-time read-through the FFmpeg filters documentation I stumbled on a filter named hstack, which is described as being "faster than using overlay and pad filter to create same output."

    My ex wife can affirm that there are few higher priorities in my life than going faster, so I altered my ffmpeg script to use hstack instead of two overlays:

    ffmpeg -y -i left.mp4 -i right.mp4 -filter_complex "
      [0:v] crop=w=in_w/2 [croppedLeft];
      [1:v] crop=w=in_w/2 [croppedRight];
      [croppedLeft][croppedRight] vstack [vout];
      [0:a][1:a] amix [aout]
    " -map "[vout]" -map "[aout]" -ac 2 out.mp4
    

    ...but that command runs painfully slowly, like 0.1x. It takes multiple minutes to render a single second.

    So uhhh what's going on here? Why is hstack taking so long when it's supposed to be faster?

    I've tried this on both the M1 native build from OSXExperts (version N-99816-g3da35b7) and the standard ffmpeg from brew and hstack is just as slow on each.

  • Multithreading / Multiprocessing python for loop

    27 January, by 1nspy

    I would like to use multiprocessing / or multithreading : do not know which is the best for my use case : converting mp4 file to mp3 file (guess multiprocessing ?).

    Main problem is that the function which I want to iterate (conv_all_files) has a loop and I do not know how to multiprocess it...

    Here is the code :

    def conv_file(input,output):
        subprocess.run(["ffmpeg","-i",input,output + ".mp3","-loglevel","quiet"])
    
    def conv_all_files():
        for i in os.listdir(MP4_Path):
            conv_file(MP4_Path + "\\" + i,MP3_Path + "\\" + i)
    

    Any ideas ?