How to create a m4v video using ffmpeg?

1.5k Views Asked by At

I'm trying to create a m4v video with the following command using ffmpeg:

ffmpeg -loop 1 -i orange640x360.png -i Be+Present.mp3 -tune stillimage -shortest -c:v libx264 -c:a copy ./Be+Presentorange640x360.m4v

This is the error that I'm getting:

[ipod @ 0x7fbbc9801600] Could not find tag for codec mp3 in stream #1, codec not currently supported in container


Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

If I do the same command to create a mp4 video, it works correctly, as such:

ffmpeg -loop 1 -i orange640x360.png -i Be+Present.mp3 -tune stillimage -shortest -c:v libx264 -c:a copy ./Be+Presentorange640x360.mp4

.m4v is the required format for jPlayer which I'm currently using.

1

There are 1 best solutions below

3
Rudolfs Bundulis On

Since I was not sure I looked it up and yeah - FFmpeg considers m4v files to be a raw video stream container without any audio. From rawenc.c on github:

#if CONFIG_M4V_MUXER
AVOutputFormat ff_m4v_muxer = {
    .name              = "m4v",
    .long_name         = NULL_IF_CONFIG_SMALL("raw MPEG-4 video"),
    .extensions        = "m4v",
    .audio_codec       = AV_CODEC_ID_NONE,
    .video_codec       = AV_CODEC_ID_MPEG4,
    .write_header      = force_one_stream,
    .write_packet      = ff_raw_write_packet,
    .flags             = AVFMT_NOTIMESTAMPS,
};
#endif

So the error is appropriate, since you are trying to put an MP3 audio stream inside m4v. I'd suggest trying the mp4 version - docs and examples of jPlayer indicate that it should handle it.