[FFmpeg-devel] Switching from mp4 container to avi

Jean Delvare khali at linux-fr.org
Thu Sep 8 14:29:24 CEST 2011

Some more information about my case...

On Thu, 8 Sep 2011 09:30:00 +0200, Jean Delvare wrote:
> I am facing a strange container change issue for which I am seeking for
> guidance.
> Background:
> I have a series of video files in mp4 container format (xvid + mp3).
> They play well on my Samsung YP-R1 PMP, but not on my (father in law's)
> Sony digital TV set. That TV set plays avi container files just fine,
> and so does my PMP, so I decided to convert my files from mp4 container
> to avi so that I can play them on both devices.
> In order to not lose quality in the process, and to make conversion as
> fast as possible, I avoided recoding using the following command line:
> ffmpeg -i input.mp4 -vcodec copy -acodec copy -vtag xvid copy.avi
> The problem is, my PMP will refuse to play the resulting file (although
> I can play it with any media player on Linux - mplayer, totem,
> ffplay...) Sadly, it doesn't tell me why.

I forgot to mention: to the best of my knowledge, the original file
doesn't contain anything the avi container wouldn't be able to cope
with. No B frames, no VBR audio, no variable frame rate.

> I tried without -vtag but it did not help. I tried reencoding the audio,
> with the same settings used for the original audio:
> ffmpeg -i input.mp4 -vcodec copy -acodec libmp3lame -ab 112k -vtag xvid new-audio.avi
> but it did not help either. Then I tried reencoding the video, with the
> same settings used for the original video :
> ffmpeg -i input.mp4 -vcodec libxvid -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -b 640k -g 125 -acodec copy new-video.avi
> and that _does_ work, but it's obviously slow and certainly degrades
> video quality, so I'm not happy with this solution.
> My questions now:
> * Does anyone has any idea why my Samsung YP-R1 accepts to play the
>   reencoded video file but refuses to play the straight-copy version?
>   Is there anything ffmpeg does differently (or omits doing) when using
>   -vcodec copy?
> * Can anyone suggest an alternative way to convert from mp4 container
>   to avi without loss?

I tried with mencoder instead:

mencoder input.mp4 -oac copy -ovc copy -o copy-mencoder.avi

The resulting file also cannot be played by my Samsung YP-R1. So it's
not an ffmpeg-only issue.

> * Is there any tool out there that can display detailed information
>   about avi file headers / structure? I tried mediainfo and ffprobe but
>   both claim that copy.avi and new-video.avi are identical, except for
>   slight variations in sizes and average bit rates. It will be
>   difficult to figure out what my PMP doesn't like about the avi file
>   that doesn't play if I can't find exactly how it differs from the one
>   which does play.

I had the idea to open the problematic avi files with GSpot, and it
reported one interesting thing:

Note: MPEG info in AVI stream header.

I don't get this statement for files with reencoded video. So this
could be the one thing that confuses my Samsung YP-R1.

This raises two additional questions:

* Why does ffmpeg include MPEG information on video stream copy to an
  avi container, which it wouldn't include if encoding the same video
  stream? Is this a bug?

* If there a way to prevent this information from being written to the
  file at copy time? Or afterwards?

> I can do any testing if you have suggestions, and provide small sample
> files exhibiting my problem if needed.

Jean Delvare

More information about the ffmpeg-devel mailing list