Issue when combining 2 video files [after matching

2019-07-02 01:09发布

Basically I got a .mp4 and a .flv file which I want to concatenate (the .mp4 should be the intro).

So after having asked a previous question regarding this I went ahead and converted the intro video to an .flv with matching specifications of the second video.

First I got the specifications of the second (.flv) video using ffprobe. This was the output:

{
    "streams": [
        {
            "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/50",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "width": 646,
            "height": 364,
            "coded_width": 656,
            "coded_height": 368,
            "has_b_frames": 2,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "323:182",
            "pix_fmt": "yuv420p",
            "level": 30,
            "chroma_location": "left",
            "refs": 5,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/1000",
            "start_pts": 80,
            "start_time": "0.080000",
            "bit_rate": "400000",
            "bits_per_raw_sample": "8",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_time_base": "1/44100",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/1000",
            "start_pts": 241,
            "start_time": "0.241000",
            "bit_rate": "96000",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0
            }
        }
    ],
    "format": {
        "filename": "vid2.flv",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "flv",
        "format_long_name": "FLV (Flash Video)",
        "start_time": "0.080000",
        "duration": "371.920000",
        "size": "23876671",
        "bit_rate": "513587",
        "probe_score": 100,
        "tags": {
            "audiosize": "4476626",
            "canSeekToEnd": "true",
            "datasize": "23876671",
            "videosize": "19004263",
            "hasAudio": "true",
            "hasCuePoints": "false",
            "hasKeyframes": "true",
            "hasMetadata": "true",
            "hasVideo": "true",
            "lasttimestamp": "372",
            "metadatacreator": "flvtool++ (Facebook, Motion project, dweatherford)",
            "totalframes": "9298",
            "encoder": "Lavf56.36.100"
        }
    }
}

Here's my command:

-i prefix.mp4 -b:v 400k -b:a 96k -r 25 -ar 44100 -acodec aac -vf scale=646:364 -strict -2 prefix.flv.

This produces the following output (as well as the video file):

ffmpeg version N-76137-gb0bb1dc Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  4.100 / 55.  4.100
  libavcodec     57.  7.100 / 57.  7.100
  libavformat    57.  8.102 / 57.  8.102
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 12.100 /  6. 12.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'prefix.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.8.102
  Duration: 00:00:05.31, start: 0.000000, bitrate: 1589 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1205 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 384 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, flv, to 'prefix.flv':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.8.102
    Stream #0:0(und): Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 646x364 [SAR 2912:2907 DAR 16:9], q=2-31, 400 kb/s, 25 fps, 1k tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc57.7.100 flv
    Stream #0:1(und): Audio: aac ([10][0][0][0] / 0x000A), 44100 Hz, 5.1, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc57.7.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> flv1 (flv))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame=   79 fps=0.0 q=10.7 size=     381kB time=00:00:03.43 bitrate= 908.7kbits/frame=  132 fps=0.0 q=10.1 Lsize=     548kB time=00:00:05.31 bitrate= 844.1kbits/s
video:479kB audio:62kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.161623%
[aac @ 0000021aa893eae0] Qavg: 177.292

I then run the outputted video file and it runs just like the old one.

I then concatenate the ouputted intro file with my main video file using the following command (tmp.txt contains the 2 files):

-f concat -i tmp.txt -c copy newvid.flv

This produces the following output:

ffmpeg version N-76137-gb0bb1dc Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  4.100 / 55.  4.100
  libavcodec     57.  7.100 / 57.  7.100
  libavformat    57.  8.102 / 57.  8.102
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 12.100 /  6. 12.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, concat, from 'tmp.txt':
  Duration: N/A, start: 0.000000, bitrate: 496 kb/s
    Stream #0:0: Video: flv1, yuv420p, 646x364, 400 kb/s, 25 fps, 25 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: aac (LC), 44100 Hz, 5.1, fltp, 96 kb/s
[flv @ 00000257b5f0e180] Codec for stream 0 does not use global headers but container format requires global headers
[flv @ 00000257b5f0e180] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, flv, to 'newvid.flv':
  Metadata:
    encoder         : Lavf57.8.102
    Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 646x364, q=2-31, 400 kb/s, 25 fps, 25 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: aac ([10][0][0][0] / 0x000A), 44100 Hz, 5.1, 96 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[flv @ 00000257b56947e0] Packet mismatch 486539264 7424
[flv @ 00000257b56947e0] Auto-inserting h264_mp4toannexb bitstream filter
[flv @ 00000257b5f0e180] Non-monotonous DTS in output stream 0:0; previous: 5263, current: 5255; changing to 5263. This may result in incorrect timestamps in the output file.
frame= 6359 fps=0.0 q=-1.0 size=   15906kB time=00:04:14.30 bitrate= 512.4kbits/frame= 9428 fps=0.0 q=-1.0 Lsize=   23835kB time=00:06:17.05 bitrate= 517.8kbits/s
video:19016kB audio:4403kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.777447%

When I try to run the final video (newvid.flv) it plays like this:

It starts off playing the intro just fine. However, when the intro is finished the video freezes while the sound of the actual video continues for the entire duration of the video.

Thus in conclusion what is lacking is the video of the second vid (the audio is fine).

I'm new at using ffmpeg but I've tried my best to solve this, which is why I'm asking for your help.

I'd certainly appreciate if someone could help me out.

标签: video ffmpeg flv
0条回答
登录 后发表回答