How to convert video to `m4v` with `ffmpeg`?

25,353

Solution 1

Try:

tools/ffmpeg/./ffmpeg -i debug/assets/videos/sample_iPod.mp4 -vcodec libx264 debug/assets/videos/sample_iPod.m4v

Solution 2

For those who find this question today still, because they're trying to play m4v, their software player won't let them and they need it converted to a "real" format and Google sent them to this question: m4v is not just "mp4 with DRM", but can also be a pure video stream without any playback metadata. This may be the case when you use certain digital cameras, you render video through Adobe's media encoder with certain h.264 presets, and other similar video-generating processes.

In those cases, it may very well be that all you need to do is get ffmpeg to add playback metadata on tope, which it will do by telling it to convert to mp4, turning your pure stream into a playable media resource.

$> ffmpeg -i input.m4v -vcodec copy -acodec copy output.mp4

Or you can use the short (but I find harder to remember) form:

$> ffmpeg -i input.m4v -c:v copy -c:a copy output.mp4

Done, you should now have a perfectly playable mp4 file.

Solution 3

Try:

# extract and encode audio
ffmpeg -i film.avi -vn temp_audio.mp3
faac -w -b 128 temp_audio.mp3 temp_audio.aac
# extract and encode video
ffmpeg -i input.avi -an -b 400 -vcodec mpeg4 temp_video.m4v
# mux into mp4
mp4creator -c temp_video.m4v -hint -r 30 output.mp4
mp4creator -c temp_audio.aac -hint -interleave output.mp4
rm temp_audio.mp3 temp_audio.aac temp_video.m4v

found here:

http://discerning.com/topics/audiovideo/video_encoding.html chapter ffmpeg (command shell)

Share:
25,353
Silver Light
Author by

Silver Light

PHP developer. As hobby also a Python/Django programmer, guitarist, marshal art and bicycle enthusiast.

Updated on August 05, 2022

Comments

  • Silver Light
    Silver Light over 1 year

    I'm trying to encode a video to m4v, so I can play it using jplayer on my website, but having troubles while specifieng correct parameter to ffmpeg. Here is the command I use:

    ffmpeg -i 1.avi -vcodec mpeg4 -f m4v -qmax 8 1.m4v 2>&1
    

    The video I get with this command won't play in jplayer and even in Totem Movie Player (on ubuntu). But if I try the demo video from jplayer website evrything works fine.

    Can anyone give me a hint on what parameters I need to specify to ffmpeg to get a working m4v video, like the one with a bunny?

  • Silver Light
    Silver Light over 12 years
    Thank you, but this example produces mp4, not m4v
  • piotrekkr
    piotrekkr over 12 years
    I fought that mp4 was m4v without DRM en.wikipedia.org/wiki/M4V so you could use mp4
  • Jake
    Jake about 6 years
    This doesn't work with the DRM m4v format. ffmpeg doesn't support DRM.
  • Jake
    Jake about 6 years
    This created a file that seemed to play, but had not video or audio. The M4V file format is a video container format developed by Apple and is very similar to the MP4 format. The primary difference is that M4V files may optionally be protected by DRM copy protection. en.wikipedia.org/wiki/M4V
  • Jake
    Jake about 6 years
    Sorry. it doesn't work convert FROM m4v. It might work to create m4v.
  • Jake
    Jake about 6 years
    You could open the mp4 in Quicktime and output for iphone to convert it to an m4v.
  • Mike 'Pomax' Kamermans
    Mike 'Pomax' Kamermans about 6 years
    Apparently the entire comment thread and all the edits have fallen off this answer, so to restore all that starting with comments: quite a few digital cameras generate m4v files, as well as several adobe tools, of the type that are a pure video stream, so if that sounds like your situation, then this solution will work. If you have an m4v from a different kind of source (say, the itunes folder) then your mileage may vary.