[pygame] movie in background, convert videos to mpeg

[pygame] movie in background, convert videos to mpeg

Postby metulburr » Mon Apr 21, 2014 2:39 am

Ive been playing with Mekire's movie repo and trying to implement it into my own. However i was looking for a background movie to play behind the menu. But i am not sure if the movie module will allow the regular music to play while the movie is playing (i extracted the audio out of the movie). I attempted it, but i ran into quite a few problems...my edited movies wouldnt play at all (so i re-used the example one for testing it), while python 3 couldt run it at all, and if you move around in the menu, you get a core dump. My assumption is that the core dump is a result of both the movie and the music trying to obtain the mixer? and the python3.x i am assuming its just a missing module or something as its an import error for pygame.movie.

Is this possible to allow a movie to relinquish the audio but play the video?
http://www.mediafire.com/download/g7afv ... 3/boom.zip
i put it on mediafire, because i am not that great with git branches and reverting back to previous states.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: [pygame] movie in background

Postby Mekire » Mon Apr 21, 2014 3:22 am

Okay just tested it with a windows machine (don't have access to Linux at work) with python 2 and if I don't kill the mixer module I can still play music that is not from the movie. Haven't tested sound effects but I assume there is no issue there either.

I too have not found a version of pygame for python3 on Linux that has the movie module.

-Mek
User avatar
Mekire
 
Posts: 987
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: [pygame] movie in background

Postby metulburr » Mon Apr 21, 2014 3:48 am

OHhhhh.. I didnt even see the mixer.quit in your classes constructor. That would makes sense.

Thanks...

Would you have any idea on why my edited mpeg videos would not work? They were originally longer mp4 videos that i chopped smaller, and converted via ffmpeg with commands:

Code: Select all
ffmpeg -i input.mp4 -vcodec mpeg1video -an -ss 61 -t 19 output.mpeg

which seems to work, converts to mpeg, no audio, from start to end postition cut out

when i switch the load to that video, i get a ton of prints:
Code: Select all
Warning: picture block before sequence header block

the menu works, the background is a different color though, with no video
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: [pygame] movie in background

Postby Mekire » Mon Apr 21, 2014 3:55 am

No clue. I will check it out when I get home in a few hours. Besides that example I haven't really worked with the movie module much either. Not sure how picky it is.

-Mek
User avatar
Mekire
 
Posts: 987
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: [pygame] movie in background

Postby metulburr » Mon Apr 21, 2014 4:09 am

thanks

This is the stats on those vidoes


my edited video:
Code: Select all
metulburr@arch ~/Downloads/boom/resources/movies $ mplayer -vo null -ao null -identify -frames 0 menu_movie.mpg
MPlayer SVN-r37051 (C) 2000-2014 MPlayer Team
207 audio & 440 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing menu_movie.mpg.
libavformat version 55.33.100 (internal)
ID_VIDEO_ID=0
MPEG-PS file format detected.
MPEG: No audio stream found -> no sound.
VIDEO:  MPEG1  640x360  (aspect 1)  29.970 fps    0.0 kbps ( 0.0 kbyte/s)
Load subtitles in ./
ID_FILENAME=menu_movie.mpg
ID_DEMUXER=mpegps
ID_VIDEO_FORMAT=0x10000001
ID_VIDEO_BITRATE=0
ID_VIDEO_WIDTH=640
ID_VIDEO_HEIGHT=360
ID_VIDEO_FPS=29.970
ID_VIDEO_ASPECT=0.0000
ID_START_TIME=unknown
ID_LENGTH=0.00
ID_SEEKABLE=1
ID_CHAPTERS=0
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 55.52.102 (internal)
Selected video codec: [ffmpeg1] vfm: ffmpeg (FFmpeg MPEG-1)
==========================================================================
ID_VIDEO_CODEC=ffmpeg1
Audio: no sound
Starting playback...


Exiting... (End of file)
ID_EXIT=EOF


the test video that we used that we know works
Code: Select all
metulburr@arch ~/Downloads/boom/resources/movies $ mplayer -vo null -ao null -identify -frames 0 test-mpeg.mpg
MPlayer SVN-r37051 (C) 2000-2014 MPlayer Team
207 audio & 440 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing test-mpeg.mpg.
libavformat version 55.33.100 (internal)
ID_VIDEO_ID=0
ID_AUDIO_ID=0
MPEG-PS file format detected.
VIDEO:  MPEG1  160x120  (aspect 1)  30.000 fps    0.0 kbps ( 0.0 kbyte/s)
Load subtitles in ./
ID_FILENAME=test-mpeg.mpg
ID_DEMUXER=mpegps
ID_VIDEO_FORMAT=0x10000001
ID_VIDEO_BITRATE=0
ID_VIDEO_WIDTH=160
ID_VIDEO_HEIGHT=120
ID_VIDEO_FPS=30.000
ID_VIDEO_ASPECT=0.0000
ID_AUDIO_FORMAT=80
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=0
ID_AUDIO_NCH=0
ID_START_TIME=0.77
ID_LENGTH=0.00
ID_SEEKABLE=1
ID_CHAPTERS=0
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 55.52.102 (internal)
Selected video codec: [ffmpeg1] vfm: ffmpeg (FFmpeg MPEG-1)
==========================================================================
ID_VIDEO_CODEC=ffmpeg1
==========================================================================
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 32000 Hz, 2 ch, s16le, 64.0 kbit/6.25% (ratio: 8000->128000)
ID_AUDIO_BITRATE=64000
ID_AUDIO_RATE=32000
ID_AUDIO_NCH=2
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
AO: [null] 32000Hz 2ch s16le (2 bytes per sample)
ID_AUDIO_CODEC=mpg123
Starting playback...


Exiting... (End of file)
ID_EXIT=EOF


Aside from the obvious no audio, i dont see much difference in the reasoning it would not play.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: [pygame] movie in background

Postby metulburr » Mon Apr 21, 2014 11:06 pm

I did find a workable solution, adding the argument -target ntsc-vcd
Code: Select all
ffmpeg -i input.mp4 -target ntsc-vcd -vcodec mpeg1video -an output.mpg


the method in pygame docs show:
Code: Select all
ffmpeg -i input.mp4 -vcodec mpeg1video -acodec libmp3lame -intra  output.mpg

which did work, but it didnt work when stripping out the audio from the file whereas the first did so.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: [pygame] movie in background, convert videos to mpeg

Postby Mekire » Tue Apr 22, 2014 12:26 am

Hmm... I was messing with it last night. I converted an avi video using ffmpeg and it did technically work but the result was a video with completely different dimensions and horrible quality. At that point, pygame successfully played it, but it was worthless.

-Mek
User avatar
Mekire
 
Posts: 987
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: [pygame] movie in background, convert videos to mpeg

Postby metulburr » Tue Apr 22, 2014 1:28 am

I think adding the flag
Code: Select all
-q:v 0

will give it the best quality.

Code: Select all
ffmpeg -i input.mp4 -target ntsc-vcd -vcodec mpeg1video -an -q:v 0 output.mpg

the quality looks the same between the two videos for me

and i did notice once you said it, that the new video decreased in size (very slightly, but noticeably), so i passed the original videos dimensions in, and the quality seemed ok, with the same dimentions as the original video
Code: Select all
ffmpeg -i input.mp4 -target ntsc-vcd -vcodec mpeg1video -an -s 480x272 -q:v 0 output.mpg

To me at this point the two videos look identical, though one being mp4, and the other mpeg.

although not sure what command you gave.

EDT:
after seeing the video used as a background.....i dont think a background video for a main menu would look good...it appears too hectic.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1448
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to Game Development

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests