Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFmpeg-Python command too long because of drawtext

    18 mai, par Xascoria

    I have a FFmpeg-Python program that puts subtitles into a video, pseudocode below:

    for i in range(10000):
        video= video.filter(
            'drawtext', fontfile=FONT_FILE, text=cur_string, x='(w-text_w)/2', y='(h-text_h)/2',
            fontsize=FONT_SIZE, fontcolor=FONT_COLOR, borderw=2, bordercolor=FONT_OUTLINE_COLOR,
            enable=f'between(t,{i},{i+1})')
    
    video.output(PATH).run()
    

    The code above gives the following error:

    FileNotFoundError: [WinError 206] The filename or extension is too long
    

    My questions are:

    (1) Is there anyway to check when the ffmpeg command is going to exceed the cmd length limit (8191/28878? not actually sure which one is in effect) in code?

    (2) How do I fix this in code?

  • How to stream lossy audio in chunks ?

    18 mai, par Adam

    On the client side, I'm collecting periodically received audio slices into a circular buffer during the playback to avoid having to receive the entire file at once, only a small portion of its size.

    On server side I tried splitting MP3/M4A/OGG into frames, but even with ffmpeg, a gap is created in the chunk (usually at the beginning/end), which prevents me from validly concatenating them on the client side. Not even when I encoded the MP3 to PCM beforehand and then split the WAV file into MP3 chunks. Of course, split to WAV chunks there is no gap, but one slice is larger than the entire MP3 file. MP3 gap

    I also tried copying and encoding:

    ffmpeg -i input.mp3 -ss 0 -t 30 -c:a copy -f mp3 pipe:1
    ffmpeg -i input.mp3 -ss 0 -t 30 -c:a libmp3lame -f mp3 pipe:1
    
  • how to creating V210 encoder in pure c/c++ code

    18 mai, par mans

    I am trying to implement V210 video encoding by writing the encoder by myself in c/c++ and not using any library.

    To achieve this, I am trying to see how I can create frame data and then use FFMPEG to put the frames in a video container using this command

    ffmpeg -s 1280x720 -f v210 -i frames.bin -c:v copy sample_video.mkv
    

    to create the frames.bin, I am creating a list of blocks based on the specifications that I found above.

    The code that I am using to pack YUV to the block is as follows:

    #pragma pack (push,1)
    class V210Block
    {
    public:
        void Init(uint16_t y[], uint16_t u[], uint16_t v[])
        {
            Init(y[0], u[0], v[0],
                y[1], u[1], v[1],
                y[2], u[2], v[2],
                y[3], u[3], v[3],
                y[4], u[4], v[4],
                y[5], u[5], v[5]
                );
        }
    
        void Init(uint16_t y0, uint16_t u0, uint16_t v0,
            uint16_t y1, uint16_t u1, uint16_t v1,
            uint16_t y2, uint16_t u2, uint16_t v2,
            uint16_t y3, uint16_t u3, uint16_t v3,
            uint16_t y4, uint16_t u4, uint16_t v4,
            uint16_t y5, uint16_t u5, uint16_t v5
        )
        {
            PackValuesToBlockbe(u0, y0, v0, 0);
            PackValuesToBlockbe(y1, u2, y2, 1);
            PackValuesToBlockbe(v2, y3, u4, 2);
            PackValuesToBlockbe(y4, v4, y5, 3);
        }
    private:
        uint32_t block[4] = { 0 };
        inline void PackValuesToBlockle(uint16_t value1, uint16_t value2, uint16_t value3, int blockNo)
        {
            // Little-endian packing (least significant bits to lower memory addresses)
            block[blockNo] = (value1 << 20) | ((value2 & 0x3FF) << 10) | (value3 & 0x3FF);
        }
        inline void PackValuesToBlockbe(uint16_t value1, uint16_t value2, uint16_t value3, int blockNo)
        {
            // big-endian packing (most significant bits to lower memory addresses)
            block[blockNo] = (value3 << 20) | ((value2 & 0x3FF) << 10) | (value1 & 0x3FF);
        }
    
    };
    #pragma pack (pop)
    

    I tested both versions of PackValuesToBlock (big endian and little endian) and I got the same result.

    In my test, I put Y=128 and u and V to zero for all pixels in a frame and all frames in the video. When I play the video, I can see that all pixels have values of R=0, G=173, B=0

    Why is this happening?

    Is there can I can extract a file similar to frames.bin from a video that is already encoded in this format, so I can check the binary data and find what is wrong with my encoding?

    Is there any sample c code that tries to encode one or a series of images into this format?

    How can I do this using OpenCV then I can check the binary data or generated bin foe with mine to find what is the problem with my code.

  • how to merge two mp4 files (audio & video) with ffmpeg using script ? [closed]

    18 mai, par mayor

    I need a script (in win 10) that will do the following thing:

    1. Retrieve the name of the directory it is in.
    2. In this directory are placed two mp4 files - video and audio separately. The files have different names.
    3. Script will merge them using ffmpeg into one mkv (ffmpeg -i ... - i ... -c copy “the name of the directory in which the script and files.mkv”)
    4. end

    The idea is that I put myself this script in some directory, run it and have the job done without typing the command manually.

    Thank you.

  • play encrypted movies in vlc by decrypting them by ffmpeg "on the fly"

    17 mai, par doctor

    I would like to play encrypted movies in vlc by decrypting them by ffmpeg like below on macOS. The size of my movie is, say, 200-1000MB. (hundreds of files)

    My problem is that it is too slow to decrypt; it takes 5mins for 300MB movie before it starts to play. My guess is that ffmpeg first decrypts the whole content of 300MB and then VLC plays it. My question: Is it possible to play the movie "on the fly" while decrypting it? (play the decrypted chunk once it is decrypted, Not wait until the whole movie is decrypted before it plays, so that it starts to play in, say, 10 secs delay.)

    
    ffmpeg -decryption_key 0 -i "movie.locked.mp4" -f matroska | /Applications/VLC.app/Contents/MacOS/VLC - --fullscreen --quiet --play-and-exit
    

    Thank you very much! Have a nice day!