Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Pushing data while downloading to ffmpeg

    5 avril 2019, par Nguyễn Thành Đạt

    I have try to relivestream video to facebook with source from youtube.

    I use the ytdl to download video from youtube. I want to during the video download process, i will livestream

    When i run my source in blow by nodejs then the error appears:

    var url = 'https://www.youtube.com/watch?v=CTL_5dqDOyc';
    var ffmpeg = spawn('ffmpeg', ['-re', '-i', 'pipe:0', '-i', 'logo.png',' acodec', 'libmp3lame',  '-ar', '44100', '-b:a', '128k', '-profile:v', 'baseline', '-s', '854x480', '-bufsize', '6000k', '-vcodec', 'libx264', '-preset', 'veryfast', '-g', '30', '-r', '30', '-f', 'flv', 'rpmt link']);
    ytdl(url).pipe(ffmpeg.stdin);
    
  • Android javacv FFMpeg overlay animated gif over video

    5 avril 2019, par Diego Perez

    I'm developing an Android app that creates a video (from an image plus an mp3 file) with javacv and FFMpeg and the video generation part is working fine, but my problem comes now that I would like to overlap a transparent background animated gif over the video, and I'm really stuck with it and I have no success on every attempt so far.

    To be honest it is being my first experience with javacv and FFMpeg, so I have little knowledge on how to work with filters.

    I'll paste my complete video creation method below and let's see if anyone can help me. Again, my problem is overlapping the animated gif, the video (removing the filter part) is being created just fine. The most I was able to achieve is overlapping a static (one frame) small gif (with no transparency) on the top left corner of video, but what I'd like to achieve is a transparent gif with the same dimensions of video over it.

    Maybe you will see nonsense code, but remember this is due to my lack of knowledge with javacv and FFMpeg filters.

    I hope anyone can help me.

    Thanks.

    PS. I have read this post: javaCV Android, Strange colors on overlay while streaming to rtmp server

    of @schw4ndi but I wasn't able to do anything with it.

    static String recordVideo(JSONObject objJSON) {
    
        try {
            fileName = objJSON.has("file_name") ? String.valueOf(objJSON.getString("file_name")) : "";
            videoPath = objJSON.has("video_path") ? String.valueOf(objJSON.getString("video_path")) : "";
        } catch (JSONException e) {
            ExceptionHandler.logException(e);
        }
    
        String strReturn = Enum.Result.OK;
    
        if (!fileName.equals("") && !videoPath.equals("")) {
            try {
                String outputFilename = videoPath + "/" + fileName;
                //video grabber
                FrameGrabber grabber1 = new FFmpegFrameGrabber(outputFilename + ".jpg");
                //audio grabber
                FrameGrabber grabber2 = new FFmpegFrameGrabber(outputFilename + ".mp3");
    
                grabber1.start();
                grabber2.start();
    
                FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputFilename + ".mp4", 1080, 1920,2);
    
                //video
                recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
                recorder.setVideoOption("tune", "zerolatency");
                recorder.setFrameRate(30);
                recorder.setVideoBitrate(128000);
                recorder.setVideoOption("crf", "28");
                recorder.setVideoQuality(0); //highest quality
                recorder.setVideoOption("preset", "fast");
                recorder.setFormat("mp4");
    
                //audio
                recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
                recorder.setSampleRate(44100);
                recorder.setAudioBitrate(128000);
                recorder.setAudioOption("crf", "0"); //no variable bitrate audio (constant rate factor)
                recorder.setAudioQuality(0); //highest quality
    
                FFmpegFrameFilter filter = null;
                try{
                    filter = new FFmpegFrameFilter("movie=" + videoPath + "/anim01.gif [logo];[in][logo]overlay=0:0:format=yuv420 [out]",1080, 1920);
                    filter.start();
                }catch (FrameFilter.Exception e){
                    e.printStackTrace();
                }
    
                recorder.start();
    
                Frame frame1, frame2 = null, frame3 = null;
    
                while ((frame1 = grabber1.grabFrame()) != null ||
                        (frame2 = grabber2.grabFrame()) != null) {
                    if (frame1 != null) filter.push(frame1);
                    frame3 = filter.pull();
                    //recorder.record(frame1);
                    recorder.record(frame3, avutil.AV_PIX_FMT_YUV420P);
                    recorder.record(frame2, avutil.AV_PIX_FMT_YUV420P);
                }
    
                recorder.stop();
                grabber1.stop();
                grabber2.stop();
                filter.stop();
    
            } catch (Exception e) {
                strReturn = Enum.Result.KO;
                ExceptionHandler.logException(e);
            }
        }
    
        return strReturn;
    }
    
  • Adding chapters to MP4 files, and being identified on iOS 12 podcast app

    5 avril 2019, par Craig Francis

    I have an MP4 file, where I've added chapters via ffmpeg.

    But in the iOS 12 Podcasts app, from Apple, the chapters don't appear. This should happen, as noted by idownloadblog.com

    Preview of how Chapters should look in iOS

    In comparison, when using QuickLook on MacOS, the list of chapters can be seen by clicking the chapters button (in the bottom right hand side of the window).

    Preview of QuickLook in MacOS

    And opening in QuickTime Player, while there isn't a list of chapters to view, you can use the "View > Next Chapter" menu item.

    So I'm assuming this is a bug in iOS... but I'm wondering if there is another way to add chapters? or if I've made a mistake?


    My current process is to create a "ffmetadata" file, as noted in the ffmpeg documentation:

    ;FFMETADATA1
    title=Example
    
    [CHAPTER]
    TIMEBASE=1/1000
    START=0
    END=221913
    title=Chapter 1
    
    [CHAPTER]
    TIMEBASE=1/1000
    START=221913
    END=1169241
    title=Chapter 2
    

    https://ffmpeg.org/ffmpeg-formats.html#Metadata-1

    Then I've tried each of the following commands:

    ffmpeg -i 2019-01-02.mp4 -i 2019-01-02.meta -map_metadata 1 -codec copy 2019-01-02-chapters.mp4
    ffmpeg -i 2019-01-02.mp4 -i 2019-01-02.meta -map_metadata 1 2019-01-02-chapters.mp4
    ffmpeg -i 2019-01-02.mp4 -i 2019-01-02.meta -map_metadata 1 2019-01-02-chapters.mp3
    
    • The first one is from the ffmpeg documentation, where -codec copy means the audio file is not re-encoded.
    • The second one takes longer, while it re-encodes the audio data.
    • The third one requires re-encoding to convert it into an MP3 file (which uses ID3 tags for the chapter data).

    On a slightly unrelated note, the third party app "RSSRadio" does list the chapters, but the feature added in version 4 that allows you to "skip directly to the start of the next chapter", if the next chapter starts within the next 3 minutes, does not seem to work.

  • recive klv data from a ffmpeg multicast

    5 avril 2019, par diego

    I am trying to get the klv data from a .mpeg.

    I tried this command and it works perfectly:

    ffmpeg -i video.mpg -map data-re -codec copy -f data data.klv

    (This first command has "data-re" which just works on linux, but it is the only way I found to get the .klv I need)

    Now I would like to open two CMD and transfer it by multicast, how could I do this? i tried many comands like next ones, but I do not get the same .klv

    sender: ffmpeg -i video.mpeg -c copy -f mpegts udp://239.1.1.1:49410

    receiver: ffmpeg -i udp://239.1.1.1:49410 -map 0 -codec copy -f data data.klv

    I am new with ffmpeg and I do not know exactly what I need to change to get exactly whay I get in the first command.

    Thanks

  • How to fix ffmpeg & mencoder pushing Persian (RTL) subtitles reversed ?

    5 avril 2019, par sheshkovsky

    I'm trying to build an application to burn subtitles on videos. The specific task to do is burning Persian (Right-to-left language) subtitles. But I have a problem with it.

    When I got several words simuntaneously without any "Enter" between them, the ffmpeg or mencoder push the lines to up. for example if I have three lines, the third lines comes on first line, then the second line, and then the first line prints on the screen.

    I have attached two screenshot to be clear about it. As you may see in the second one, there are 9 lines of persian subtitle which should be aligned from 1 on top to 9 on the bottom, but the 9th line appears on the first line on top.

    enter image description here

    enter image description here

    I'm using this code at the moment to burn the subtitles on mp4 videos:

    mencoder video.mp4 -sub subtitle.srt -utf8  -o output.mp4 -oac pcm -ovc lavc