Какую команду FFmpeg я использую для передачи FLV в MP4?

5782
user338034

У меня есть несколько загруженных файлов FLV, которые я хотел бы преобразовать в MP4. Они уже находятся в правильном формате, поэтому мне сказали, что все, что мне нужно сделать, - это смешать видео и аудио потоки в контейнере MP4, используя копирование / пропуск.

Я на Windows 7 64-битной и уже есть FFmpeg как часть get_iPlayer.

Я пытаюсь выработать командную строку для этого, пожалуйста?

Также возможно ли пакетную обработку нескольких файлов FLV таким же образом?

5
Возможно [this] (http://superuser.com/q/624565/148285) или [this] (http://superuser.com/q/483597/148285) могли бы помочь? BenjiWiebe 10 лет назад 0

2 ответа на вопрос

5
JP de la Torre

It should be something like:

ffmpeg -i yourvideo.flv -codec copy output.mp4 

You can use FOR command to loop through files (it recurses down your tree):

FOR /R C:\dir\ %%F IN (*.flv) do ffmpeg -i "%%F" -codec copy "%~nF.mp4" 

Just to clarify, %~nF returns only the name portion of the filename (without the extension).

4
Octavian Naicu

They are already in the correct format

.flv videos are complex files that can contain many types of audio and video. To check a .flv file's audio and video codecs you can use:

1.ffmpeg

ffmpeg -i video.flv 

which (in your case) should output something along the lines of:

Input #0, flv, from 'video.flv': Duration: 00:05:01.20, start: 0.000000, bitrate: 66 kb/s Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 66 kb/s, 29.92 tbr, 1k tbn, 2k tbc Stream #0.1: Audio: aac, 22050 Hz, stereo, s16 

or

2.VLC's Media Information window: VLC's Media Information window for a flv file with AAC and H.264

This .flv file contains H.264 video and AAC audio which happens to be the correct formats/codecs for the .mp4 container.

Here's the structure of such an .mp4 file:

mp4 file containing AAC audio and H.264 video

*Image courtesy of Converting FLV to MP4 With FFmpeg The Ultimate Guide

So when transocding flv to mp4, depending on the codecs in the original .flv file, we have 4 cases:

1) Converting .flv files with H.264 video and AAC audio

If the audio and video codecs in the .flv files are supported by the .mp4 container (AAC + H.264) then you can just copy the streams into an mp4 file without transcoding:

ffmpeg -i video.flv -codec copy video.mp4 

Such .flv files are very rare.

This process is MASSIVELY faster than decoding and reencoding the entire audio and video data.

2) Converting .flv files with H.264 video and Nellymoser/Speex audio

If one or more of the videos have H.264 video and Nellymoser ASAO/Speex audio (very common with .flv files) then you need to copy video (-vcodec instead of -codec) and transcode (just) the audio:

ffmpeg -i video.flv -vcodec copy video.mp4 

3) Converting .flv files with Spark/VP6 video and Nellymoser/Speex audio

If flv's video and audio data are not encoded with the correct codecs for .mp4 (Spark & VP6 video codecs were very common) then you need to force both AAC and H.264:

ffmpeg -i video.flv video.mp4 

4) Converting .flv files with Spark/VP6 video and AAC audio

It would be vary rare to come across a .flv file with AAC audio and video other than H.264, but just in case, here's how to transcode it to .mp4 in the most efficient way (copy the audio data):

ffmpeg -i video.flv -acodec copy video.mp4 

Похожие вопросы