Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to timestamp video with seconds and milliseconds with ffmpeg ? [closed]

    10 février, par JulianJ

    I am trying to timestamp an .mp4 video with seconds and milliseconds using ffmpeg. I can timestamp with hours, minutes, seconds and milliseconds using the code below but just can't figure out how to print seconds and milliseconds.

    ffmpeg -i input.mp4 -vf "drawtext=:text='%{pts\:s}':rate=25:start_number=0:x=(w-tw)/2:y=h-(3*lh):fontcolor=white:fontsize=50,drawtext=:text='%{pts\:hms}':rate=25:start_number=0:x=(w-tw)/2:y=h-(2*lh):fontcolor=white:fontsize=50" output.mp4
    
  • How to hide the output of yt-dl in CMD ? python

    10 février, par Qais Albeaiz

    I'm coding program that download mp3 audio from youtube videos but I have an issue that yt-dl show some output in console

    my code:

    with open('Links.txt') as f:
        content = f.readlines()
        for links in content:
    
            ydl_opts = {
                'format': 'bestaudio/best',
                'postprocessors': [{
                    'key': 'FFmpegExtractAudio',
                    'preferredcodec': 'mp3',
                    'preferredquality': '192',
                }],
            }
            with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                ydl.download([links])
    

    photo of output: enter image description here

    and i need the option or some way to hide the output.

  • How to make multiple ffmpeg commands run in parallel [duplicate]

    9 février, par Kim Mỹ

    I'm using the following ffmpeg command to compress video:

    `nice -n 10 ${ffmpegPath} -i "${chunkPath}" -c:v libx264 -preset fast -crf 28 "${compressedPath}"`
    

    However, when I run two instances of ffmpeg of this command to achieve parallelism:

    Either in two child processes within a single Node.js application or in two separate Node.js applications running at the same time, it seems only one command is processed, and the other is skipped.

    I've noticed that 2 FFmpeg instances are loaded into RAM and both create a starting file for the final compressed video, they finish compression around the same time. However, the total processing time is effectively doubled compared to compressing a single video file alone, which only takes half the time.

    I also try to pass the -threads argument but it produces same result.

  • Thread count option in FFmpeg for FASTEST conversion to h264 ?

    9 février, par S B

    I need to maximize speed while converting videos using FFmpeg to h264

    • Any input format of source videos
    • User's machine can have any number of cores
    • Power and memory consumption are non-issues

    Of course, there are a whole bunch of options that can be tweaked but this question is particularly about choosing the best -thread option. I am trying to find an ideal thread count as a function of

    • no. of cores
    • input video format
    • h264-friendly values maybe?
    • anything else missed above?

    I am aware the default -thread 0 follows one-thread-per-core approach which is supposed to be optimal. But I am not sure if this is time or space-optimized. Also, on certain testcases, I've seen more threads (say 4 threads on my dual core test machine) finishes quicker than the default.

    Any other direction, say configure options w.r.t. threads, worth pursuing?

  • How to remove a specific segment from an audio file using timestamps ? [closed]

    9 février, par Hilal Khan

    I am working on a C# project where I need to remove a specific segment from an audio file (e.g., WAV, MP3) based on start and end timestamps, while keeping the rest of the audio intact.

    For example, given a 20-minute audio file, I want to remove the section from 17:00 to 19:00 and be left with a new audio file containing only 0:00-17:00 and 19:00-20:00 (i.e., keeping the parts before and after the cut).

    I have used NAudio and FFmpeg to trim a file by cutting from the start or end, but I only get my desired snippet as a separate file which is not what I am looking for as I want it to be removed from the audio itself

    Heres what I have so far:

    static void RemoveSegment(string inputPath, string outputPath, double startTime, double endTime)
    {
        using (var reader = new Mp3FileReader(inputPath))
        {
            var writer = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
    
            int bytesPerMillisecond = reader.WaveFormat.AverageBytesPerSecond / 1000;
            long startPosition = (long)(startTime * 1000) * bytesPerMillisecond;
            long endPosition = (long)(endTime * 1000) * bytesPerMillisecond;
    
            byte[] buffer = new byte[4096];
            int bytesRead;
    
            while ((bytesRead = reader.Read(buffer, 0, buffer.Length)) > 0)
            {
                if (reader.Position < startPosition || reader.Position > endPosition)
                {
                    writer.Write(buffer, 0, bytesRead);
                }
            }
    
            writer.Close();
        }
    
        Console.WriteLine("Segment removed successfully!");
    }