codec

Open() and codecs.open() in Python 2.7 behave strangely different

旧巷老猫 提交于 2019-11-29 10:31:16
I have a text file with first line of unicode characters and all other lines in ASCII. I try to read the first line as one variable, and all other lines as another. However, when I use the following code: # -*- coding: utf-8 -*- import codecs import os filename = '1.txt' f = codecs.open(filename, 'r3', encoding='utf-8') print f names_f = f.readline().split(' ') data_f = f.readlines() print len(names_f) print len(data_f) f.close() print 'And now for something completely differerent:' g = open(filename, 'r') names_g = g.readline().split(' ') print g data_g = g.readlines() print len(names_g)

Print to UTF-8 encoded file, with platform-dependent newlines?

坚强是说给别人听的谎言 提交于 2019-11-29 09:30:55
In Python, what is the best way to write to a UTF-8 encoded file with platform-dependent newlines? the solution would ideally work quite transparently in a program that does a lot of printing in Python 2. (Information about Python 3 is welcome too!) In fact, the standard way of writing to a UTF-8 file seems to be codecs.open('name.txt', 'w') . However, the documentation indicates that (…) no automatic conversion of '\n' is done on reading and writing. because the file is actually opened in binary mode. So, how to write to a UTF-8 file with proper platform-dependent newlines? Note: The 't' mode

Opencv error on python

被刻印的时光 ゝ 提交于 2019-11-29 08:43:59
no matter what "CV_FOURCC" I use I get this: OpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend doesn't support this codec acutally.) in CvVideoWriter_GStreamer::open, file /usr/src/packages/BUILD/OpenCV-2.2.0/modules/highgui/src/cap_gstreamer.cpp, line 489 writer = cv.CreateVideoWriter( filename=file, fourcc=cv.CV_FOURCC('F', 'M', 'P', '4') , fps=iFps, frame_size=(800,600), is_color=1) cv.WriteFrame(writer, cv.LoadImage(frames[i])) Also /usr/src/packages/BUILD/OpenCV-2.2.0/modules/highgui/src/cap_gstreamer.cpp, does not exist. Also CV_FOURCC('H','F','Y','U')

FFmpeg fourcc Avi codec support list?

落花浮王杯 提交于 2019-11-29 03:06:26
问题 A couple of similar questions are on stackoverflow, but I haven't been able to figure this exact problem out. I want to get a list of the fourcc s for the avi codecs that FFMpeg can decode. I know how to get all the formats ffmpeg -formats and codecs ffmpeg -codecs but neither list gives me an accessible list of fourccs . Neither does the documentation I can find. I need this list, so that my application can access the fourcc of an avi file and determine whether to use ffmpeg or VfW (or

Concept about Multimedia Codecs (Container,Format, Codec,Muxer,Demuxer) [closed]

孤街浪徒 提交于 2019-11-29 03:01:13
问题 I have gone thorugh lot of multimedia stuff last week and now messed up in few questions.These are related to my work on Developing a Media Player.My questions below are based on that only. I am also looking out for ebook/resource on Multimedia codecs? I am looking for the following info ? What is the difference between container, format,codec, packet, frame? I believe it is Container -> Audio(streams) + Video (streams) Streams are encoded/decoded using the codecs Streams -> Packets Packets -

Android encoder muxer: raw h264 to mp4 container

∥☆過路亽.° 提交于 2019-11-28 20:57:38
I created a h264 raw video file, and I was able to mux it with Android MediaMuxer on Android 4.3 and up. Now I need to support Android versions 4.1 and 4.2. I found Jcodec. And there is an example for doing this: https://github.com/jcodec/jcodec/blob/master/samples/main/java/org/jcodec/samples/mux/AVCMP4Mux.java But I'm getting java.nio.ReadOnlyBufferException exception at line 70: H264Utils.encodeMOVPacket(data); I guess this code is not for Android? How do I fix this. Can someone familiar with Jcodec help on this? xy uber.com I gave up on Jcodec. It exposes too many codec internal stuff, and

Turn image sequence into video with transparency

孤街浪徒 提交于 2019-11-28 17:27:29
问题 I've got what seems like it should be a really simple problem, but it's proving much harder than I expected. Here's the issue: I've got a fairly large image sequence consisting of numbered frames (output from Maya, for what its worth). The images are currently in Targa (.tga) format, but I could convert them to PNGs or other arbitrary format if that matters. The important thing is, they've got an alpha channel. What I want to do is programatically turn them into a video clip. The format doesn

ffmpeg convert mov file to mp4 for HTML5 video tag IE9

我只是一个虾纸丫 提交于 2019-11-28 15:05:16
I looked everywhere here and on google - there is no valid command that works for IE9. some how IE9 is missing something. All that I tried worked everywhere else: chrome,safari,mobile device etc... I want one command that will convert it and I can use it in every device suppose to support mp4 in HTML5 video tag. I use this commands: ffmpeg -i movie.mov -vcodec copy -acodec copy out.mp4 ffmpeg -i movie.mov -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k -pix_fmt yuv420p outa.mp4 ffmpeg -i movie.mov -b

Create video from images

爷,独闯天下 提交于 2019-11-28 11:11:41
Is there a way to create a video from a series of images on android? Maybe a way to extend the MediaRecorder and being able to take images as input. I try to really create the video and store it (as an mpeg4 file for instance). Thanks for any suggestions. Showpath I'm also trying to do the same thing. I have been advice to use Libav. http://libav.org/ However I need to build it with the NDK and I currently have some issues doing it. I'm looking for some doc about it. I'll keep you posted. I've created a post about it: Libav build for Android You can use AnimationDrawable in an ImageView . Add

Check the bandwidth rate in Android

时光怂恿深爱的人放手 提交于 2019-11-28 07:00:18
We have an option to check the network connection types in Android (whether it is 3G, edge or gprs). I need to check the the bandwidth rate. I need to initiate a call. For that I need to check the bandwidth rate. Above a particular bandwidth only I need to make visible an option for a call (to initiate a call). I need to find the connection speed programmatically (connection speed for Mobile Data Link, EDGE). You can download a known-size file from your server, and calculate how long did it take to download it. Then you have your bandwidth. Simple but works :) Sample, not tested : //Download