Closed joyrider3774 closed 4 years ago
Instead of going crazy and since using mmal I took the advise of @joyrider3774 and re encoding my mp4 with libx264 I have tested Attract setup mp4 and is working great and smaller size.
Example if anyone interested (of course you can use your paths etc)
sudo ffmpeg -i /home/pi/.attract/menu-art/snap/Attract\ Mode\ Setup.mp4 -vcodec libx264 -acodec aac /home/pi/.attract/menu-art/snap/new//Attract\ Mode\ Setup.mp4
@2play best to provide also -pix_fmt yuv420p
mmal H264 decoder only supports that pixelformat. your convert line won't work if videos are for example yuv444p instead of yuv420p. For hyperpie video's your command works because they already are yuv420p but for other videos (game snaps) in other pixelformats it won't work. I also made pr that will revert to software mode when playing those types of video's not supported on RPI4 through mmal anymore (only h264 is supported now through mmal on rpi4, on all other pi's the other codecs are still supported)
also just to confirm when playing through ffplay on rpi4 you get same mmal errors
ffplay -codec:v mpeg4_mmal ~/.attract/menu-art/snap/All\ Displays.mp4
[mpeg4 @ 0xa7801870] Failed to parse extradata0KB sq= 0B f=0/0
Input #0, avi, from '/home/pi/.attract/menu-art/snap/All Displays.mp4':
Metadata:
date : 2018-01-28T18:10:03.00012
encoder : Lavf56.19.100
Duration: 00:00:31.07, start: 0.000000, bitrate: 2857 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (xvid / 0x64697678), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 2715 kb/s, SAR 1280:1281 DAR 16:9, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
mmal: mmal_vc_port_info_set: failed to set port info (2:0): EINVAL
mmal: mmal_vc_port_set_format: mmal_vc_port_info_set failed 0xa78275e0 (EINVAL)
mmal: mmal_port_disable: port vc.ril.video_decode:in:0(MP4V)(0xa78275e0) is not enabled
mmal: mmal_port_disable: port vc.ril.video_decode:out:0(0xa7827900) is not enabled
mmal: mmal_port_disable: port vc.ril.video_decode:ctr:0(0xa78272d0) is not enabled
37.28 M-A: -0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
tx and noted @joyrider3774 Yes I wanted to initially fix the 205+ videos on HyperPie Theme. So for that we are good yes.
Ill run and test your above once my conversion completes
Would you care sharing your revert to software pr that your mentioned above?
check the code in the pr (pull request) https://github.com/mickelson/attract/pull/626/commits/98bf92fbf3f685b29974dfee136197f5862680f6 when that code is applied with you just recompile attract and add PLATFORM_RPI4=1 to make line along with the other variables (use_mmal and use_drm)
also in windows i created batch files to convert all video's in one commnand using ffmpeg, i can chat them if needed
I did a quick test on what you mentioned:
Orig file
[mpeg4 @ 0xa7801870] Failed to parse extradata0KB sq= 0B f=0/0
Input #0, avi, from '/home/pi/.attract/menu-art/snap/All Displays.mp4':
Metadata:
date : 2018-01-28T18:10:03.00012
encoder : Lavf56.19.100
Duration: 00:00:31.07, start: 0.000000, bitrate: 2857 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (xvid / 0x64697678), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 2715 kb/s, SAR 1280:1281 DAR 16:9, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
mmal: mmal_vc_port_info_set: failed to set port info (2:0): EINVAL
mmal: mmal_vc_port_set_format: mmal_vc_port_info_set failed 0xa7827680 (EINVAL)
mmal: mmal_port_disable: port vc.ril.video_decode:in:0(MP4V)(0xa7827680) is not enabled
mmal: mmal_port_disable: port vc.ril.video_decode:out:0(0xa7827990) is not enabled
mmal: mmal_port_disable: port vc.ril.video_decode:ctr:0(0xa7827360) is not enabled
Encoded File
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/pi/.attract/menu-art/snap/new/All Displays.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
date : 2018-01-28T18:10:03.00012
encoder : Lavf58.20.100
Duration: 00:00:31.08, start: 0.000000, bitrate: 1705 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 1568 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
mmal: mmal_vc_port_info_set: failed to set port info (2:0): EINVAL
mmal: mmal_vc_port_set_format: mmal_vc_port_info_set failed 0xa7939b00 (EINVAL)
mmal: mmal_port_disable: port vc.ril.video_decode:in:0(MP4V)(0xa7939b00) is not enabled
mmal: mmal_port_disable: port vc.ril.video_decode:out:0(0xa7939e10) is not enabled
mmal: mmal_port_disable: port vc.ril.video_decode:ctr:0(0xa79397e0) is not enabled
check the code in the pr (pull request) 98bf92f when that code is applied with you just recompile attract and add PLATFORM_RPI4=1 to make line along with the other variables (use_mmal and use_drm)
also in windows i created batch files to convert all video's in one commnand using ffmpeg, i can chat them if needed
@joyrider3774 Just want to say thank you for your contribution and work.
I use this on Pi4. Added the -pix_fmt yuv420p as you advised. Can you please confirm?
cd /home/pi/.attract/menu-art/snap/
for i in *.mp4;
do name=`echo "$i" | cut -d'.' -f1`
echo "$name"
sudo ffmpeg -i "$i" -vcodec libx264 -acodec aac -pix_fmt yuv420p ./new/"${name}.mp4"
done
your second command is wrong in testing the video you need to use h264_mmal decoder like so when trying to play h264 with mmal in ffplay (if the encoded video is h264)
ffplay -codec:v h264_mmal -loop 0 ~/.attract/menu-art/snap/new/Attract\ Mode\ Setup.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/pi/.attract/menu-art/snap/new/Attract Mode Setup.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
date : 2018-01-31T10:01:11.00494
encoder : Lavf58.20.100
Duration: 00:00:26.07, start: 0.000000, bitrate: 1114 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1280:1281 DAR 16:9], 979 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
11.72 A-V: 0.001 fd= 5 aq= 31KB vq= 139KB sq= 0B f=0/0
also it's possible to just copy the audio stream and only converting video but not sure you want that, it's ok to recompress audio as well i just would set -f MP4 exlicitly also
ffmpeg -i /home/pi/.attract/menu-art/snap/Attract\ Mode\ Setup.mp4 -c:v libx264 -c:a copy -pix_fmt yuv420p -f MP4 /home/pi/.attract/menu-art/snap/new//Attract\ Mode\ Setup.mp4
yes confirm above ffplay -codec:v h264_mmal is ok!
@2play my latest pr will detect the errors when playing with mmal and revert to software decoding if an error occurred, when doing so it will write entries to the log saying the hardware decoding is not supported / working. no PLATFORM_RPI flag is needed anymore and should work on any system supporting mmal where USE_MMAL=1 is provided see code here https://github.com/mickelson/attract/pull/627/commits/60008f08634067a8f6fb978974a04603ebc595a2
Tx I'll update!
it's not in master yet though only submitted a pr
source from rpi engineer https://www.raspberrypi.org/forums/viewtopic.php?t=268356#p1628856
I don't know if it ever will get such support again.
Relevant part:
Pi0-3 have hardware accelerated decode for H264, MPEG4, H263, and through optional codec licences for MPEG2 and VC1.
Pi4 has the same hardware accelerated decode for H264, but not the other codecs. It also has a separate block for HEVC.
trying to play MPEG4 video through mmal produces following errors in attract
Maybe attract should not try to use mmal for MPEG4 anymore on a RPI4 but use software decoder ? Videos using H264 do still play fine using mmal. Perhaps should try adding support for HEVC but not sure if libavcodec (ffmpeg) supports it for mmal or if needs some other implementation, i think it's still being worked on rpi side itselve