Viewing .avi videos on Buster

Aug 02, 2022 Last reply: 3 years ago 36 Replies

How does one view .avi video files on a Pi running Buster?



I've an old Canon A460 that captures video clips in .avi format. When I connect the camera to the Pi it's recognized and I can copy the files to the Pi, but when I try to open them vlc player comes up with a black screen showing an orange and white traffic cone.



Thanks for reading, any suggestions appreciated!



bob prohaska



On a sunny day (Tue, 2 Aug 2022 15:30:48 -0000 (UTC)) it happened bob prohaska snipped-for-privacy@www.zefox.net> wrote in <tcbfv8$1in57$ snipped-for-privacy@dont-email.me:

I seem to be using ffplay for videos on my Pi4 these dsys

AVI is not a format, it is a wrapper around the file that specifies many things including the format & codec in use you probably do not have the correct codec installed

If I open the media file using VLC Media player and open tools > codec I see: stream 0 Codec Motion JPEG Video (MJPEG) Video reolustion 64x480 Buffer dimensions 640x480 Frame rate 10 orientation top left

stream 1 Codec: Araw Type: Audio Sample rate 11024 Hz Bits per sample: 8 Bitrate: 88kb/s Meanwhile the progress bar moves back and forth, as if something's running. If I click the play button nothing changes.

There's no prompt or error message saying a codec is needed. If I open current media information all values are zero. The file size is nearly six MB, so it's not empty.

I'm baffled.

Any suggestions appreciated!

bob prohaska

That's a prime example of "AVI is not a format". MJPEG is quite unusual and only commonly used by cameras/webcams. VLC probably should play it, but there may be some bug being triggered, especially if the video data from the device isn't 100% to spec.

You could try mplayer or ffplay. Personally I'd focus on converting it into a normal format (mpeg4, etc.) and playing that. Try ffmpeg with "-acodec [codec]" and "-vcodec [codec]" to set the format to something you like. I'd use "libmp3lame" and "mpeg4".

I've had that a lot in VLC over the years, it seems to be common behaviour when a particular part of the decoding chain is broken. Sometimes the audio plays without the video. Re-encoding the video in a more common format as described above is my usual solution.

IME when the progress bar bounces backward and forward it's bad news. Usually a stream failing to connect, don't think I've ever seen it for a local file.

You need those options if you want a specific encoder, yes, but if you just want a compatible format, simply specify .mp4 as the extension of the output file: "ffmpeg -i input.avi output.mp4".

Most examples will use -c:v and -c:a now instead of -vcodec and -acodec. Also the thing to remember is that these can be input or output options; to choose their function, specify them before the input file name (-i srcfile.avi) or before the output file name (dstfile.mp4), or both. But really, using them as input options should "never" be necessary because ffmpeg is good at automatically determining the decoders needed, and they need to be exactly right.

To see what ffmpeg thinks of a file, don't specify an output file name: "ffmpeg -hide_banner -i input.avi" (hide_banner just to skip the annoying program info header). But really, that should be the same as the stream info from VLC.

Mplayer can display my camera's video capture directly. Unfortunately, the video performance is very poor; either 640x480 at 10 Hz or 320x240 at 30 Hz. Your recipe for using ffmpeg seemed to work, but the 10 Hz videos don't seem to play and the 30 Hz videos aren't sharp enough.

An old iPhone6 takes much better videos, but my Pi4 freezes instantly when the iPhone is connected. Any hope of connecting to the iPhone?

The reason for the videos is to let tech support look at the panel display of a piece of equipment. They want to see lights flash and numbers change. I may start with stills and hope that's good enough.

10 Hz is fast enough to show the action, but unless there's a 10 Hz viewer readily available (probably for Windows) I'm kinda stuck.

Thanks for writing!

bob prohaska

>

Set the output frame rate to 24! "ffmpeg -i src.avi -r 24 dst.mp4"

Or 30 for a smoother up-rating if the source is 10 Hz, but 24 is the most compatible frame rate number.

On a sunny day (3 Aug 2022 07:33:26 +1000) it happened snipped-for-privacy@telling.you.invalid (Computer Nerd Kev) wrote in snipped-for-privacy@news.ausics.net>:

Yes, I have 2 A470 and these scripts I used in the past:

#canon_a470_big_to_30fps_mpeg4 if [ "$1" = "" ] then echo "Usage: canon_a470_big_to_30fps_mpeg4 infile.avi outfile.avi" exit 1 fi

if [ "$2" = "" ] then echo "Usage: canon_a470_big_to_30fps_mpeg4 infile.avi outfile.avi" exit 1 fi

echo "Extracting wave file."

ffmpeg -i $1 -f wav tmp.wav

sleep 1

echo "Encoding to mpeg4 at 30 fps."

ffmpeg -i $1 -f yuv4mpegpipe -b 5000 -vcodec pgmyuv -y /dev/stdout \ | \ yuvmotionfps -r 30:1 \ | \ ffmpeg -i tmp.wav -f yuv4mpegpipe -i - \

-f avi -vcodec mpeg4 -r 30 -b 1000 -g 300 -bf 2 -ar 48000 -y $2

echo "Ready, file is $2"

An other one:

#encode_a470_small if [ "$1" = "" ] then echo "Usage: encode_a470_small infile.avi outfile.avi" exit 1 fi

if [ "$2" = "" ] then echo "Usage: encode_a470_small infile.avi outfile.avi" exit 1 fi

ffmpeg -i $1 -f avi -vcodec mpeg4 -r 30 -b 1000 -g 300 -bf 2 -ar 48000 -y $2

And yet an other one:

#encode_a470_big if [ "$1" = "" ] then echo "Usage: encode_a470_big infile.avi outfile.avi" exit 1 fi

if [ "$2" = "" ] then echo "Usage: encode_a470_big infile.avi outfile.avi" exit 1 fi

ffmpeg -i $1 -f avi -vcodec mpeg4 -r 20 -b 1000 -g 300 -bf 2 -ar 48000 -y $2

So, his were just scripst I ued long agao, have a different small canon now. But should give some hints.

Or just use

which dumps its opinion of the file content, streams, codecs, resolutions ...

If you are using the "other" toolset -- avprobe does similar

I tried using ffmpeg -i MVI_0001.AVI -r 24 2nd_home_screen.mp4

That seems to run without errors and produces a file, but still VLC player renders a black screen. The progress bar behaves normally, and the sound is played back. Just no picture....

If I try to use Firefox ESR to open the .mp4 file it reports the file is corrupt. The Chrome browser reports no errors, but delivers neither picture nor sound. Not even a progress bar.

mplayer shows the video just fine.

Am I missing a switch or option in the ffmpeg command line? There's a -ilme option for interlace, but I can't figure where it goes in the command line, nor whether it's relevant.

Thanks very much!

bob prohaska

On a sunny day (Wed, 3 Aug 2022 14:45:38 +0100 (BST)) it happened snipped-for-privacy@signal11.invalid (Mike) wrote in <tcdu62$n0u$ snipped-for-privacy@posie.signal.org.uk>:

I use mediainfo

I didn't know about ffprobe, but it seems it's simply an alias for 'ffmpeg

-i' (almost; it doesn't warn about a missing output file). It even prints the same annoying banner which can be hidden with the same option

-hide_banner.

Huh. What does ffprobe say about both files?

I tried the conversion again using an output framerate of 30 Hz, No change. Chrome does nothing, firefox says the file is corrupt, mplayer works fine.

About the .AVI file ffprobe reports: libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 Input #0, avi, from 'MVI_0003.AVI': Metadata: creation_time : 2022-08-03 07:37:09 encoder : CanonMVI02 Duration: 00:11:11.70, start: 0.000000, bitrate: 5060 kb/s Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 4971 kb/s, 10 fps, 10 tbr, 10 tbn, 10 tbc Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 11024 Hz, 1 channels, u8, 88 kb/s

About the .mp4 file ffprobe reports libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2nd_charging_screen.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.20.100 Duration: 00:11:11.79, start: 0.000000, bitrate: 1534 kb/s Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuvj422p(pc), 640x480, 1477 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 11025 Hz, mono, fltp, 53 kb/s (default) Metadata: handler_name : SoundHandler

There's nothing I recognize as an error report. The framerate changes as expected, 10 Hz in the original and 30 Hz in the converted file.

Thanks for writing, and any further thoughts!

Would it help to put the files on a webserver so others can see them?

bob prohaska

Perhaps, but I probably won't be able to help; the file info seems fine on first sight.

In searching on the web there were quite a few references to ffmpeg conversions not playing in firefox/chrome/whatever browsers. The claim seemed to be that it had something to do with h.264 but a sample command line I tried (after simply trimming out unrecognized options) didn't make any difference. It was very much a "monkey see, monkey do" sort of experiment. Are browsers some kind of special case for video?

Thanks for writing!

bob prohaska

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required