ffmpeg - Create a mp3 file with album art from an mkv file

7,615

Maybe you can convert the video to audio with

ffmpeg -i Spiral\ -\ 09.mkv -vn -c:a libmp3lame Spiral\ -\ 09.mp3

then grab the first frame with

ffmpeg -i Spiral\ -\ 09.mkv -vframes 1 cover.jpg

Afterwards, just use a MP3 tagging tool (like EasyTag) to put the cover image in.

Share:
7,615

Related videos on Youtube

Hashken
Author by

Hashken

Updated on September 18, 2022

Comments

  • Hashken
    Hashken over 1 year

    I want to create an mp3 file from a given mkv file using ffmpeg

    the output of ffmpeg -i is as follows

    Seems stream 0 codec frame rate differs from container frame rate: 59.94 (2000000/33367) -> 29.97 (30000/1001)
    Input #0, matroska,webm, from 'Spiral - 09.mkv':
      Duration: 00:23:09.65, start: 0.000000, bitrate: N/A
        Chapter #0.0: start 0.097000, end 1389.654000
        Metadata:
          title           : 00:00:00.097
        Stream #0.0: Video: h264 (High), yuv420p, 640x428, PAR 1:1 DAR 160:107, 23.98 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
        Stream #0.1(jpn): Audio: aac, 48000 Hz, stereo, s16 (default)
        Stream #0.2: Audio: aac, 48000 Hz, stereo, s16
        Stream #0.3: Subtitle: [0][0][0][0] / 0x0000 (default)
    

    Now I used the following command to create the file. My aim is to get a portion of audio and an image snapshot from the input file and use these as the audio stream and album art for the output file.

    ffmpeg -i Spiral\ -\ 09.mkv \
           -map 0:0 -map 0:1\
           -c:v -ss 00:01:30 -vframes 1\
           -c:a:0 mp3 -b:a:0 128k\
           out.mp3
    

    But, I get the following error.

    Seems stream 0 codec frame rate differs from container frame rate: 59.94 (2000000/33367) -> 29.97 (30000/1001)
    Input #0, matroska,webm, from 'Spiral - 09.mkv':
      Duration: 00:23:09.65, start: 0.000000, bitrate: N/A
        Chapter #0.0: start 0.097000, end 1389.654000
        Metadata:
          title           : 00:00:00.097
        Stream #0.0: Video: h264 (High), yuv420p, 640x428, PAR 1:1 DAR 160:107, 23.98 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
        Stream #0.1(jpn): Audio: aac, 48000 Hz, stereo, s16 (default)
        Stream #0.2: Audio: aac, 48000 Hz, stereo, s16
        Stream #0.3: Subtitle: [0][0][0][0] / 0x0000 (default)
    Expected number for vframes but found: 1-c:a:0
    

    Is my way of handling streams correct here? If so, what else could be the problem.

    • llogan
      llogan over 10 years
      Please include the complete ffmpeg console outputs and not just segments.
    • Hashken
      Hashken over 10 years
      These are the full output, except for the part where ffmpeg says that this is a deprecated version and asks to use avconv instead
  • rubo77
    rubo77 over 9 years
    ffmpeg is removed from the repository in 14.04, use avconv instead. Any program that calls ffmpeg by name should work with avconv.