I'm trying to get a video to play in an Away3d texture on iOS. It's fine on Android and Windows. The video will play in Starling on iOS so I know it's not the video.
Here is how I add the video:
sphereGeometry = new SphereGeometry(5000, 64, 48);
panoTextureMaterial = new TextureMaterial(panoTexture2DBase, false, false, false);
panoVideoMesh = new Mesh(sphereGeometry, panoTextureMaterial);
panoVideoMesh.scaleX *= -1;
panoVideoMesh.rotate(Vector3D.Y_AXIS,-90);
scene.addChild(panoVideoMesh);
panoTexture2DBase.player.play();
view.render();
On iOS I get this from the netstats when I try and load it as a video texture.
NetStream.Play.Start
NetStream.Play.Failed
NetStream.Play.Stop
I'm using the Away3d NativeVideoTexture class
texture = context.createVideoTexture();
texture.attachNetStream(_player.ns);
I think it might be do with MP4 encoding, and I've had a good look around and can't find anything that works, currently I'm trying this in FFMEG
-vcodec libx264 -profile:v main -level 3.1 -crf 23 -s 1024:768 -movflags +faststart
But what I set doesn't seem to make a lot of difference.
Any idea why my video is failing to load as a VideoTexture on iOS?
Related
I've got a webm file with transparency : https://itype.techforge.com.au/assets/videos/upshot/module1/NP_1A.webm
I'm trying to convert it into something that will play in the video element of a web page in the Safari browser on an IPad.
An example of a file that works is : https://rotato.netlify.app/alpha-demo/movie-hevc.mov
My attempts at doing this conversion have all failed. 3rd party apps seem to all lose the alpha channel.
On my mac I tried ffmpeg
ffmpeg -i input.webm -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 output.mov
However, while this resulted in a file that reported a codec of MPEG-H Part2/HEVC (H.265) (hvc1) the resulting file still has a black background instead of a transparent one.
ffmpeg log : https://pastebin.com/DMM9y5PU
The built-in, default decoder for VP9 currently does not support alpha / transparency. Manually use the decoder libvpx-vp9:
ffmpeg -c:v libvpx-vp9 -i input.webm -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 -movflags +faststart output.mov
Your ffmpeg needs to be compiled with --enable-libvpx for this to work.
I have a live RTSP stream that i have managed to transcode to HLS via VLC. Now it works perfect on Android and on desktop browsers (via flash).
But not on Apple (i can test it on iPad and desktop Safari on my virtual machine). I can see the player but when i press the 'play' button all i see is a black rectangle inside the player. On desktop Safari there is also a text 'Loading...' near the play/pause button and nothing else happens.
My HTML:
<video id="player" controls style="width:100%; height:100%">
<source src="http://178.79.164.114/playlist.m3u8" type="application/x-mpegURL">
</video>
The command for vlc:
vlc -I dummy rtsp://<stream-url> --sout '#transcode{width=320,height=240,fps=25,vcodec=h264,vb=256,acodec=none,venc=x264{aud,profile=baseline,level=30,keyint=30,bframes=0,ref=1,nocabac}}:std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=/path/to/server/directory/playlist.m3u8,index-url=http://178.79.164.114/seg-########.ts},mux=ts{use-key-frames},dst=/path/to/server/directory/seg-########.ts}'
And an example of the playlist file:
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-MEDIA-SEQUENCE:179
#EXTINF:9.60,
http://178.79.164.114/seg-00000179.ts
#EXTINF:9.60,
http://178.79.164.114/seg-00000180.ts
#EXTINF:9.60,
http://178.79.164.114/seg-00000181.ts
#EXTINF:9.61,
http://178.79.164.114/seg-00000182.ts
#EXTINF:9.59,
http://178.79.164.114/seg-00000183.ts
And here is the strange output of ffprobe http://178.79.164.114/playlist.m3u8 (why there are these N/A and the variant_bitrate is 0?). Maybe it can help:
Input #0, hls,applehttp, from 'http://178.79.164.114/playlist.m3u8':
Duration: N/A, start: 3995.330722, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 320x240 [SAR 11:12 DAR 11:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
I have also configured correct MIME types for .m3u8 and .ts files and spent a day searching and trying different options for the transcode command: width, height, bitrate, fps, different profiles and levels... - nothing works. But if i try some examples from apple (http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8) - all is fine, though it's not a live stream.
If anyone has any ideas or has a possibility to test my stream with the mediastreamvalidator - please help.
UPDATE
Now i'm experimenting with variant playlist but it changes nothing.
The player might expect muxed video and audio so add a silent audio track.
The Apple HLS documentation says:
The media segment files are normally produced by the stream segmenter, based on input from the encoder, and consist of a series of .ts files containing segments of an MPEG-2 Transport Stream carrying H.264 video and AAC, MP3, or AC-3 audio
Support for audio-only streams is mentioned in Technical Note TN2224 and the 7th revision of the protocol introduced support for alternate renditions (unmuxed streams) but this is done with EXT-X-MEDIA tags in a master playlist controlling the playback (yours is a media playlist).
I'm trying to seek into a video file at a certain point. Lets say the video is 5 minutes long and I'm jumping in at 110 seconds.
When I play from the beginning, everything plays through fine, however, when I try to seek into the file, I can hear the audio but I can't see the video. I first thought this was maybe an issue with the order I'm loading the subviews but I can still see (and use) the controls for the player. Sliding back to 0:00 starts the video.
The following is code from my video class. The initIntoView method accepts a UIView and then returns an amended copy which then gets written to the main view. Sorry in advance for the messy code. I'm still quite new to Objective-C.
Init the Video view
- (WWFVideo*) initIntoView: (UIView*) view withContent:(NSDictionary*)contentDict{
self=[super init];
viewRef=view;
contentData = contentDict;
NSURL *videoUrl = [[NSURL alloc]initWithString:[contentDict objectForKey:#"cnloc"]]; //Returns a HTTP link to my video file (MP4, H.246, AAC Audio)
videoController = [[MPMoviePlayerController alloc] init];
videoController.movieSourceType = MPMovieSourceTypeFile;
[videoController setContentURL:videoUrl];
videoController.view.frame = viewRef.bounds;
[videoController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[viewRef addSubview:videoController.view];
return self;
}
Start playing the video
-(void)play:(int)offset { //Offset is "110"
[videoController setInitialPlaybackTime:offset];
[videoController play];
}
I've tried adding the videoController to viewRef both before and after the video starts playing but it has the same outcome.
I've also tried using an MPMoviePlayerViewController with no avail.
Another thing I tried was changing the streaming type to MPMovieSourceTypeStreaming but it seemed to have no effect.
If I've missed any more vital code, just ask and I'll see what I can do.
Edit:
Xcode 4.6.3
iOS 6
Testing on an iPad 2
Edit #2:
Works perfectly on the simulator, just not on the device.
After trying to piece together a sample app to upload here, I found that the w3 version of Big Buck Bunny worked fine. This indicates it was an encoding problem and not an objective C issue.
I've re-encoded the same file I was trying to play before but now with the baseline profile with the following command:
ffmpeg -i {filename} -acodec aac -ac 2 -strict experimental -ab 160k -s {ssize} -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 {filename}.ipad.mp4
I found this code on here through this Stack Overflow post.
Primarily for low-cost applications that require additional data loss robustness, this profile is used in some videoconferencing and mobile applications. This profile includes all features that are supported in the Constrained Baseline Profile, plus three additional features that can be used for loss robustness (or for other purposes such as low-delay multi-point video stream compositing). The importance of this profile has faded somewhat since the definition of the Constrained Baseline Profile in 2009. All Constrained Baseline Profile bitstreams are also considered to be Baseline Profile bitstreams, as these two profiles share the same profile identifier code value.
-From Wikipedia
I realise this may not help anyone here looking for Objective-C help but if it saves just one person the 5 hours I spent today trying to get this working, this will be worth it.
is there a option in JavaCV to capture 1080p videos from images?
If i use the FFmpegFrameRecorde, i only find 480p.
Or is there a alternate library for Java?
I want to use it to create a video from kind of pictures (with zooming and rotating effects)
greetings
//EDIT
Okay,
now i've tested a very simple code:
FrameRecorder recorder = FFmpegFrameRecorder.createDefault("out.avi", 1920, 1080);
recorder.start();
recorder.record(iplImage);
recorder.stop();
and it's works! But the file is very large (10sec around 300MB...)
Now i want to add a codec like xvid. I've get the following eyxception:
com.googlecode.javacv.FrameRecorder$Exception: codec not found
But i've installed the xvid paket. Must i add the codec in a special folder like the ffmpeg bin?
Okay,
now i test the mp4 codec and all works fine :)
//UPDATE
for JavaCV 0.2
FrameRecorder recorder = FFmpegFrameRecorder.createDefault("out.avi", 1920, 1080);
recorder.setCodecID(CODEC_ID_MPEG4);
recorder.setPixelFormat(PIX_FMT_YUV420P);
recorder.start();
.....
recorder.stop();
for JavaCV 0.3
FrameRecorder recorder = FFmpegFrameRecorder.createDefault("out.avi", 1920, 1080);
recorder.setVideoCodec(CODEC_ID_MPEG4);
recorder.setFrameRate(fps);
recorder.setFormat("avi");
recorder.start();
.....
recorder.stop();
I'm doing a project which requires converting SWF movies to H.264 video on server-side, to be able to play them both in Flash player and on iPhone/iPad. And I really got stuck.
I'm using Melt from http://www.mltframework.org/ and this is my command-line:
melt movie.swf -consumer avformat:video.mp4 r=30 s=640x360 f=mp4 acodec=aac ab=128k ar=48000 vcodec=libx264 b=1000k an=1
It does play in Flash player, but fails to play on iDevices. I googled for iPhone video requirements and it seems my video files do satisfy them(frame size, framerate and bitrate). What settings should I change to make it play?
I've spent a lot of time in google but managed to gather all the pieces, so these are parameters that work for iPhone:
r=30 s=640x360 f=mp4 acodec=aac ab=128k ar=48000 vcodec=libx264 level=30 b=1024k flags=+loop+mv4 cmp=256 partitions=+parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 me_method=hex subq=7 trellis=1 refs=1 bf=0 flags2=+mixed_refs-wpred-dct8x8 coder=0 wpredp=0 me_range=16 g=250 keyint_min=25 sc_threshold=40 i_qfactor=0.71 qmin=10 qmax=51 qdiff=4 maxrate=10M bufsize=10M an=1 threads=0
Also, I use faac -w to convert audio to appropriate format and MP4Box to join video and sound.