基本上我有一个.mp4和.flv文件,我想要连接(.mp4应该是介绍)。
因此,在问previous question regarding this之后,我继续将介绍视频转换为.flv与第二视频的匹配规格。
首先,我使用ffprobe获得了第二个(.flv)视频的规格。这是输出:
{
"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"
}
}
}
这是我的命令:
-i prefix.mp4 -b:v 400k -b:a 96k -r 25 -ar 44100 -acodec aac -vf scale=646:364 -strict -2 prefix.flv
。
这会产生以下输出(以及视频文件):
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
然后我运行输出的视频文件,它就像旧文件一样运行。
然后我使用以下命令将输出的介绍文件与我的主视频文件连接起来(tmp.txt包含2个文件):
-f concat -i tmp.txt -c copy newvid.flv
这会产生以下输出:
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%
当我尝试运行最终视频(newvid.flv)时,它会像这样播放:
开始播放介绍就好了。 但是,当介绍完成后,视频会冻结,而实际视频的声音将持续整个视频的持续时间。
因此总的来说,缺少的是第二个vid的视频(音频很好)。
我很擅长使用ffmpeg,但我已尽力解决这个问题,这就是我寻求帮助的原因。
如果有人可以帮助我,我当然会感激。