Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg converting from mkv to mp4 without re-encoding

Tags:

ffmpeg

I am using ffmpeg to switch container from mkv to mp4 via this command:

ffmpeg -i filename.mkv -vcodec copy 1.mp4

this is the simplest command that I found when converting from mkv container to mp4 without re-encoding. The output stated otherwise (if I am not mistaken)

This is a small screen shot of the the output:

FFmpeg Screenshot

Where it said Stream Mapping, #0:0 (264 (native)) -> 264 (libx264)). Does this mean that it's re-encoding from x264 to libx264? What Did I do wrong?

Any help is appreciated...

like image 527
unknown Avatar asked Oct 17 '16 02:10

unknown


People also ask

Can FFmpeg convert MKV?

FAQ 1: Does converting MKV to MP4 lose quality? Lossless: You are only transferring the video from the mkv container to an mp4 container without modifying the video in the lossless option. This can be achieved by using FFmpeg and doing a copy operation (also called transmuxing).

What is FFmpeg encoding?

ffmpeg is a command-line tool that converts audio or video formats. It can also capture and encode in real-time from various hardware and software sources such as a TV capture card. ffplay is a simple media player utilizing SDL and the FFmpeg libraries.

Can I convert MKV to MP4 with ffmpeg?

You will not get the common MKV to MP4 interface such as "Add File" "Output Format" and other buttons to optimize with. To be more specific, converting .mkv to .mp4 with FFmpeg is faster than common video converters like Audacity, Handbrake and others.

How to convert MKV to MP4 on Mac?

To convert mkv to mp4 is actually quite easy; we can use ffmpeg command to copy the original video and audio streams into a new container. This simple method can save a lot of time since we are not encoding the media file, and the conversion process will be fast. Additionally, the video and audio quality will not be reduced.

What encoder does FFmpeg use for MP4?

This is the H.264 video encoder used by ffmepgand, if available, is the default encoder for MP4 output. See the FFmpeg H.264 Video Encoding Guidefor more info on that.

How to FFmpeg convert to MP4 with H264 codec?

For example, if you want to FFmpeg convert to MP4 with H264 codec. You can input: ffmpeg –i input.mkv –c:v h264 output.mp4 -c:v means the following character is used to nominate the codec of video.


2 Answers

problem solved, specify the audio codec solve my problem...

ffmpeg -i filename.mkv -vcodec copy -acodec copy 1.mp4
like image 59
unknown Avatar answered Oct 25 '22 03:10

unknown


Remuxing containers, e.g. MKV or AVI to MP4, with FFmpeg will only keep a single – it tries to choose the best one available – audio and video stream from the input file in the output file. This can be avoided by providing -map 0.

Matroska files frequently contain subtitles in a format not supported in MOV/MPEG containers by FFmpeg, esp. SRT/Subrip or ASS/SSA. They can either simply be dropped with -sn or be converted to a native format like mov_text. (You could also burn hard subtitles into a video stream with filters.)

Sometimes, adding missing information by using heuristics might help. This is activated with -find_stream_info, but I am not sure whether this should be used by default.

I shall assume that built configuration is not important to know (-hide_banner) and only serious problems should be logged to the console (-loglevel warning, alternatively: quiet | panic | fatal | error | warning | info (default) | verbose | debug | trace).

Therefore, a rather universal conversion command looks like this:

$ ffmpeg -find_stream_info -i input.mkv \
         -map 0 -codec copy -codec:s mov_text output.mp4 \
         -hide_banner -loglevel warning; \
  rm input.mkv

For batch processing multiple files on a Windows box within cmd and overwriting existing files (-y), use for:

FOR /r %F IN (*.mkv) DO (@ffmpeg \
  -find_stream_info -i "%F" \
  -map 0 -codec copy -codec:s mov_text "%~pnF.mp4" \
  -hide_banner -loglevel warning -y)
like image 4
Crissov Avatar answered Oct 25 '22 02:10

Crissov