Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFmpeg android video processing does not return error message

    25 août 2018, par Дмитрий Мельчин

    friends. I am creating a program that puts the sound and picture to video. I'm using the ffmpeg library https://github.com/bravobit/FFmpeg-Android. The command looks like this:

    String command = "-i /data/user/0/com.radpony.vhs.camcorder/files/RADVHS/camcorder_video.mp4 -i /data/user/0/com.radpony.vhs.camcorder/files/RADVHS/watermark_png.png -i /data/user/0/com.radpony.vhs.camcorder/files/RADVHS/playarrow.png -filter_complex [0]crop=720:720[croped];[1]scale=w=143:h=50[tmp];[croped][tmp]overlay=x=577:y=10[overlayed];[overlayed][2]overlay=x=150:y=10[overlayed2];[overlayed2]drawtext=fontfile=/data/user/0/com.radpony.vhs.camcorder/cache/VCR_OSD_MONO_1_001.ttf:text='PM 11\:06Aug..25 2018':fontcolor=white:fontsize=48:x=50:y=600[withdate];[withdate]drawtext=fontfile=/data/user/0/com.radpony.vhs.camcorder/cache/VCR_OSD_MONO_1_001.ttf:text='Play':fontcolor=white:fontsize=48:x=50:y=30 -codec:a copy -c:v libx264 -preset ultrafast /data/user/0/com.radpony.vhs.camcorder/files/RADVHS/rendered_video.mp4";
    

    It works great for Android 6, but on the Samsung devices with Android 7 while processing of video ffmpeg just stops without displaying an error message. If someone knows the solution to this problem, help, please

  • ffmpeg sync issue when muxing audio and video

    25 août 2018, par tweecore

    I have an issue with ffmpeg. I am not a pro user so I'm on a constant trial & error mode. I would need a little help from this community that helped me countless time before.
    I downloaded separate audio and video segments of a video stream. Both audio and video were shown in the Network tab as being .m4s files, but the .m3u8 playlist gave me .ts files for both. So then I downloaded the whole audio batch and concatenated it into a single .ts file. I did the same with video, but using a .mp4 output.

    EDIT: When merging the audio .ts files, I encounter this issue:

    [mpegts @ 0x7f88cb805600] Non-monotonous DTS in output stream 0:0; 
    previous: 1077120, current: 1073280; changing to 1077121. This may 
    result in incorrect timestamps in the output file.
    

    UPDATE: Just noticed that when I examine the .ts audio file with MediaInfo, the frame rate is 41.667 fps (1152 SPF).

    So now I have two files: a working single .ts with audio and a working single .mp4 with video. Only when I tried to merge them, however, I noticed that audio and video resulted as out of sync. This is because audio has a different length from video (don't know why, they were the same amount of segments: 750).
    Audio info:

    Input #0, mpegts, from 'output.ts':
    Duration: 01:14:12.11, start: 1.400000, bitrate: 434 kb/s
    Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 384 kb/s
    

    I can see that for some reason, it starts at 1.4s.

    Video info:

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
    Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
    Duration: 01:14:57.84, start: 0.000000, bitrate: 2425 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2423 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    

    Video and audio are synced at the beginning (somehow the 1.4 start makes sense) but audio starts drifting and goes out of sync after a while. How do I solve the issue?

  • How to grab laptop webcam video with ffmpeg in windows

    25 août 2018, par Ofer Sadan

    I have a small python program that works very well to capture short videos from webcams in linux (at least for laptops that have built-in webcams) using a sub-process with ffmpeg.

    Now i'm trying to write the same program to capture webcams in windows, and i know i can't use the generic "/dev/video0" that works pretty well in linux, but i thought something like naming it "Integrated Camera" should be enough, but it fails.

    Here's my linux code (that works):

        import sys
        from subprocess import call
        from datetime import datetime
        def record_webcam(seconds):
            cam = '/dev/video0'
            timestamp = datetime.now().strftime('%Y%m%d-%H%M%S')
            filename = timestamp + 'something.mkv' #generated with more complexity in the actual code, but that isn't important
            ffmpeg_cmd = 'ffmpeg -t {} -an -i {} -c:v libx264 -preset veryslow -crf 25 {}'.format(seconds, cam, filename).split()
            p = call(ffmpeg_cmd)
            return filename if p == 0 else False
    
        if __name__ == '__main__':
            record_webcam(sys.argv[1])
    

    I have looked at the documentation for ffmpeg and tried to search for solution but so far i'm lost...

    I know that "Integrated Camera"s are only available on some laptops and not others, and that it won't capture other cameras connected, but it's enough for my use case... but if you want a challenge I would also like to know how to apply it to any windows-pc with a camera regardless of what it's called.

    Also, is it easier or more recommended to do what i'm trying here only with python tools, like OpenCV?

    Thanks in advance! Edit: I answered my own question with a partial solution if anyone is interested based on a comment from @Mulvya, but if anyone can still explain to me the part about OpenCV I would still like to hear it...

    Follow up question here: ffmpeg through python subprocess fails to find camera

  • Is it possible to retrieve the "profile" of one file, and use it to convert another file ?

    25 août 2018, par GDP

    So we have an ancient compiled program that has been converting AVI files to MPEG for television broadcast. The program is pure sorcery, as the original programmer is long gone, but it has created 10's of thousands of MPEG files of a very particular format that our (also ancient) broadcast server uses.

    So...the question is whether or not, we can use FFMPEG to initially "get the details" of one of those MPEG files, and use THAT to convert future MP4 files to that legacy MPEG format?

    In short, we don't know all the intricacies of everything that the program is or may be doing, and want to replace it with FFMPEG, being confident that we're getting exactly the same output that works without a hitch in the fussy broadcast server.

  • Using ffmpeg to watermark a folder of videos

    25 août 2018, par user5947524

    I am using the code below to watermark individual videos one-by-one in a folder:

    ffprobe -v quiet -show_entries stream=width,height -of default=noprint_wrappers=1 dave.mp4
    ffmpeg -i logo.png -y -v quiet -vf scale=width*0.15:-1 scaled.png
    ffmpeg -i dave.mp4 -i scaled.png -filter_complex "overlay=10:main_h-overlay_h-10" dave2.mp4
    

    The first line gets the width and the height of a video, second line scales the watermark for that video, third line creates a new video watermarked.

    How can I make run for a full folder of 1000 videos?

    I tried the code below but it corrupted the videos:

    for %%a in ("C:\Users\Work\Desktop\test2\*.mp4") do (
     ffprobe -v quiet -show_entries stream=width,height -of default=noprint_wrappers=1 "%%a" 
     ffmpeg -i logo.png -y -v quiet -vf scale=width*0.15:-1 scaled.png 
     ffmpeg -i "%%a" -i scaled.png -filter_complex "overlay=10:main_h-overlay_h-10" "C:\Users\Work\Desktop\test2\%%~na.mp4"
    )
    

    The error I get is:

    [mov,mp4,m4a,3gp,3g2,mj2 @ 0000014545aaaa00] stream 0, offset 0x18039: partial file
    [aac @ 0000014545b708c0] Input buffer exhausted before END element found
    Error while decoding stream #0:1: Invalid data found when processing input
    C:\Users\Work\Desktop\test2\dave.mp4: Invalid data found when processing input