Newest 'ffmpeg' Questions - Stack Overflow

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

Articles published on the website

  • Why is ffmpeg modifying my 5.1 channel layout?

    10 June, by dongle

    I have an AC3 sound file in 5.1 surround, and an MOV file with no sound. I am using FFMPEG to add the sound to the MOV file, and although it works succesfully, for some reason it is modifying the layout of the sound channels, and looking at the audio waveforms it even looks as though it may be mixing them, which is very worrying.

    The layout of audio channels in the AC3 file is: L, R, C, LFE, Ls, Rs.

    Here is the command I am using to combine them:

    ffmpeg -i [path to MOV] -i [path to AC3] -c:v copy -c:a copy -map 0:v:0 -map 1:a:0 [path to output MOV]
    

    When I look at the final MOV (with sound added) in Mediainfo, the layout of audio channels has changed to: L, C, R, Ls, Rs, LFE. And again, as I shared above when I look at the waveform of the 6 audio channels in the new MOV not only are they out of order, but one of them looks unfamilliar compared to the original AC3 file, which leads me to believe it may even be doing some mixing?

    What am I doing wrong? Do I need to add more specificity to my command to preserve the audio's integrity?

  • Mapping streams by language in FFmpeg

    9 June, by ffmpeg123

    I have lots of files with multiple audio and subtitle languages, however the track numbers aren't consistent (the English audio stream isn't always the first) so using a command such as:

    ffmpeg -i "input.mkv" -map 0 -map -0:a:1 -c:v copy -c:a copy "output.mkv"
    

    doesn't yield expected results. After searching around I discovered it was possible to map streams based on language with this command:

    ffmpeg -i "input.mkv" -map 0 -map -0:m:language:eng -c:v copy -c:a copy "output.mkv"
    

    However -map -0:m:language:eng will remove all tracks with the English language flag. To keep the subtitle tracks you can use -map 0:s this is a good solution however, I want to know if it's possible to only map audio streams based on language. I.e.,

    I want to remove English audio while retaining all other streams without using stream IDs.

  • Restartable HLS encoding in ffmpeg

    9 June, by TheGreatRambler

    I'm trying to encode a HLS video in a restartable way so that it can be run on a preemptive VM. It's possible with the segment muxer in FFmpeg to create HLS files with mpegts that can be restarted (Using the -ss [time], -segment_start_number [num], -mpegts_copyts 1, segment_list_type csv and -segment_list_flags live flags and a bit of coding) but I cannot find equivalent "live" writing for the hls muxer specifically.

    Either I need a solution that allows for writing fmp4 fragments using the segment muxer or live writing for the hls muxer.

  • How to record video and audio with ffmpeg and pipe only audio to python process

    9 June, by urico12

    I have an ffmpeg command recording video and audio as one output and I'm trying to add a second output to pipe out only the raw audio to python so that I can run additional processing on the audio chunks.

    from subprocess import Popen, PIPE, STDOUT
    
    record_audio_video_command = f"ffmpeg -i small_bunny_1080p_60fps.mp4 \ 
                                 -vcodec libx264 output.mp4 -f s16le pipe:1"
    
    record_command = Popen(record_audio_video_command, 
                            shell=True, 
                            stdout=PIPE, 
                            stderr=STDOUT)
    
    f = open("output.txt", "w")
    data = record_command.stdout.read(320)
    f.write(str(data))
    while len(data) > 0:
        data = record_command.stdout.read(320)
        f.write(str(data))
    

    Is there a way to have ffmpeg pipe out only the raw audio bytes as one output, while still recording video and audio as the other output?

  • FFmpegKit wav compression in android

    9 June, by bovietvidai

    I am using arthenica/ffmpeg-kit in android Min version. I want to implement a command that convert and compress a wav file to mp3 using lamemp3 intergrated in that library I need a command for it