Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • duration change after transcode ts

    25 décembre 2017, par Feilong Luo

    i have a problem about transcode with ffmpeg

    i want to cover m3u8 to mp4, so i transcode every ts file first, and then concat them to a mp4, but i found that the duration will be bigger than source file.

    source file is : http://oc7iy3eta.bkt.clouddn.com/src_20.ts

    after transcode, test file is: http://oc7iy3eta.bkt.clouddn.com/test_20.ts

    i use the command as bellow to change to 5fps, and 400k bitrate:

    sudo ffmpeg -analyzeduration 2147483647 -probesize 2147483647 -nostdin -y -v warning -i ./src_20.ts -threads 3 -movflags faststart -metadata:s:v rotate=0 -chunk_duration 520000 -video_track_timescale 25000 -pix_fmt yuv420p -copytb 1 -vcodec libx264 -b:v 400000 -minrate 400000 -maxrate 400000 -bufsize 500k -force_key_frames "expr:gte(t,n_forced*2)" -vsync 1 -r 5 -s 544*960 -acodec libfaac -async 1 ./test_20.ts

    i use ffprobe command to see video info:

    source file info:

    Duration: 00:00:01.26, start: 28.346989, bitrate: 921 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 23 kb/s Stream #0:1[0x101]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 544x960, 10.67 tbr, 90k tbn, 180k tbc

    test file:

    Input #0, mpegts, from 'test_20.ts': Duration: 00:00:01.62, start: 1.576778, bitrate: 447 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 544x960, 5 fps, 5 tbr, 90k tbn, 10 tbc Stream #0:1[0x101]: Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 5 kb/s

    =======================================================================

    question

    so , we can see that the duration of src file is 1.26s , but after transcode, the test file is 1.62s.

    why? can anybody help

  • How to render YUV420P frames using DirectX ?

    25 décembre 2017, par TTGroup

    I'm using FFMPEG C++ to decode a video file.

    I decoded the frames under YUV420P format in System Memory.

    Next step, I want to render these frames by using DirectX.

    I searched many times, and I know that I have to use the texture2D, but there is not any code sample for my case.

    How to create a texture2D from YUV420 (or RGB instead) from System Memory and render it to the screen.

    And the performance is also important, so I need the best way to do it. Someone can show me the sample code?

    Many Thanks!

  • FFmpeg, MPEG4 video rotate and Windows

    25 décembre 2017, par user3768884

    I have this kind of video recorded in some Samsung Galaxy phone (info from: "ffprobe -v error -show_format -show_streams filename.mp4")

    [STREAM]
    index=0
    codec_name=h264
    codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    profile=High
    codec_type=video
    codec_time_base=7048499/423000000
    codec_tag_string=avc1
    codec_tag=0x31637661
    width=1920
    height=1080
    coded_width=1920
    coded_height=1080
    has_b_frames=0
    sample_aspect_ratio=0:1
    display_aspect_ratio=0:1
    pix_fmt=yuv420p
    level=40
    color_range=unknown
    color_space=unknown
    color_transfer=unknown
    color_primaries=unknown
    chroma_location=left
    field_order=unknown
    timecode=N/A
    refs=1
    is_avc=true
    nal_length_size=4
    id=N/A
    r_frame_rate=30/1
    avg_frame_rate=211500000/7048499
    time_base=1/90000
    start_pts=0
    start_time=0.000000
    duration_ts=7048499
    duration=78.316656
    bit_rate=17010472
    max_bit_rate=N/A
    bits_per_raw_sample=8
    nb_frames=2350
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:rotate=90
    TAG:creation_time=2017-12-17T13:42:14.000000Z
    TAG:language=eng
    TAG:handler_name=VideoHandle
    [SIDE_DATA]
    side_data_type=Display Matrix
    displaymatrix=
    00000000:            0       65536           0
    00000001:       -65536           0           0
    00000002:            0           0  1073741824
    
    rotation=-90
    [/SIDE_DATA]
    [/STREAM]
    [STREAM]
    index=1
    codec_name=aac
    codec_long_name=AAC (Advanced Audio Coding)
    profile=LC
    codec_type=audio
    codec_time_base=1/48000
    codec_tag_string=mp4a
    codec_tag=0x6134706d
    sample_fmt=fltp
    sample_rate=48000
    channels=2
    channel_layout=stereo
    bits_per_sample=0
    id=N/A
    r_frame_rate=0/0
    avg_frame_rate=0/0
    time_base=1/48000
    start_pts=0
    start_time=0.000000
    duration_ts=3772416
    duration=78.592000
    bit_rate=126154
    max_bit_rate=128000
    bits_per_raw_sample=N/A
    nb_frames=3684
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:creation_time=2017-12-17T13:42:14.000000Z
    TAG:language=eng
    TAG:handler_name=SoundHandle
    [/STREAM]
    [FORMAT]
    filename=original_galaxy.mp4
    nb_streams=2
    nb_programs=0
    format_name=mov,mp4,m4a,3gp,3g2,mj2
    format_long_name=QuickTime / MOV
    start_time=0.000000
    duration=78.592000
    size=167808936
    bit_rate=17081528
    probe_score=100
    TAG:major_brand=isom
    TAG:minor_version=0
    TAG:compatible_brands=isom3gp4
    TAG:creation_time=2017-12-17T13:42:14.000000Z
    [/FORMAT]
    

    Since all my media players does not support rotate-knowledge, I have turned the video over again, and at the same time slightly decreased the resolution of command "ffmpeg -i "input.mp4" -vf "scale=720:1280,transpose=0,transpose=0" -c:a copy "output.mp4""

    [STREAM]
    index=0
    codec_name=h264
    codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    profile=High
    codec_type=video
    codec_time_base=1/60
    codec_tag_string=avc1
    codec_tag=0x31637661
    width=720
    height=1280
    coded_width=720
    coded_height=1280
    has_b_frames=2
    sample_aspect_ratio=0:1
    display_aspect_ratio=0:1
    pix_fmt=yuv420p
    level=31
    color_range=unknown
    color_space=unknown
    color_transfer=unknown
    color_primaries=unknown
    chroma_location=left
    field_order=unknown
    timecode=N/A
    refs=1
    is_avc=true
    nal_length_size=4
    id=N/A
    r_frame_rate=30/1
    avg_frame_rate=30/1
    time_base=1/15360
    start_pts=0
    start_time=0.000000
    duration_ts=1203717
    duration=78.366992
    bit_rate=2570692
    max_bit_rate=N/A
    bits_per_raw_sample=8
    nb_frames=2351
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:language=eng
    TAG:handler_name=VideoHandler
    [/STREAM]
    [STREAM]
    index=1
    codec_name=aac
    codec_long_name=AAC (Advanced Audio Coding)
    profile=LC
    codec_type=audio
    codec_time_base=1/48000
    codec_tag_string=mp4a
    codec_tag=0x6134706d
    sample_fmt=fltp
    sample_rate=48000
    channels=2
    channel_layout=stereo
    bits_per_sample=0
    id=N/A
    r_frame_rate=0/0
    avg_frame_rate=0/0
    time_base=1/48000
    start_pts=0
    start_time=0.000000
    duration_ts=3772416
    duration=78.592000
    bit_rate=126154
    max_bit_rate=126154
    bits_per_raw_sample=N/A
    nb_frames=3684
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    DISPOSITION:timed_thumbnails=0
    TAG:language=eng
    TAG:handler_name=SoundHandler
    [/STREAM]
    [FORMAT]
    filename=from_ffmpeg.mp4
    nb_streams=2
    nb_programs=0
    format_name=mov,mp4,m4a,3gp,3g2,mj2
    format_long_name=QuickTime / MOV
    start_time=0.000000
    duration=78.592000
    size=26503544
    bit_rate=2697836
    probe_score=100
    TAG:major_brand=isom
    TAG:minor_version=512
    TAG:compatible_brands=isomiso2avc1mp41
    TAG:encoder=Lavf57.41.100
    [/FORMAT]
    

    This works very well in VLC, for example. However, Windows Media Player or Samsung TV does not play it. Windows Explorer does not even show a video thumbnail, so the video file is broken by Windows.

    Is not FFmpeg able to produce a standard MPEG4 file, or what the hell is this about? I've tried all the alternatives presented, such as "-fflags +genpts", "-fflags genpts", "-movflags faststart", "-movflags +faststart", "pix_fmt=yuv420p" etc. but nothing worked.

    The sound I copied directly.

  • Camera2 API switching camera during recording

    24 décembre 2017, par Max Efimov

    I'm working with Camera2 API and in my app it's important to switch the camera during recording. After each camera switch I save video fragment to disk, and after stopping the recording I merge videos into one using -f concat -safe 0 -i listPath -c copy finalPath command of FFmpeg for Android. When I open a separate video fragment, it looks correct, but when I open the merged video, videos recorded on the back camera are rotated 180 degrees. The problem is only in the merged video.

    In meta-tag of videos if video recorded on back camera, then "rotate" tag has 90 degrees, otherwise 270 degrees.

    As I understood when ffmpeg merges a videos it automatically rotates the video if it has different "rotate" tag in he's metatags.

    How I can solve this problem?

    P.S Also I tried to use MP4Parser Library for merging, but it has the same problems.
    P.P.S. -noautorotate param for ffmpeg does not help me.

  • Combine two or more images that partially overlap

    24 décembre 2017, par Smeterlink

    Having two or more images that partially overlap, like in this screenshot, I want to combine/merge them into one:

    overlapping images

    The coloured squares would be the source images, in lossless format, and no rotation is required.

    The result I want is like using the "Auto-Blend Layers" command from Adobe Photoshop, so auto-align and auto-blend is performed automatically:

    https://helpx.adobe.com/photoshop/using/combine-images-auto-blend-layers.html