youtube api upload "Cannot close stream until all bytes are written" - asp.net

I am using the youtube api to direct upload videos like this:
YouTubeRequestSettings setting = new YouTubeRequestSettings("devpa", key, "user", "pass");
YouTubeRequest req = new YouTubeRequest(setting);
Video ytv = new Video();
ytv.Title = "test video1";
ytv.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
ytv.Keywords = "test, dev";
ytv.Description = "this is a test video";
ytv.YouTubeEntry.Private = true;
ytv.YouTubeEntry.MediaSource = new MediaFileSource(Server.MapPath("PATH"), "video/mp4");
Video createdVideo = req.Upload(ytv);
But every time i get this error:
Cannot close stream until all bytes are written
Even though *i am uploading small videos with different extinctions (flv,mp4 ..etc) *, what is the problem?
Thanks

You need to set timeout. Like ytv.TimeOut = 100000000;

Actually set the instance of
YouTubeRequestSettings.Timeout = [A LARGER NUMBER]
That's the setting you'll want to use.

Related

We found a problem with some content in "example.xlsx" - using ClosedXML library

I'm using ClosedXML library to generate a simple Excel file with 2 worksheets.
I keep getting error message whenever i try to open the file saying
"We found a problem with some content in "example.xlsx". Do you want us to try to recover as much as we can. if you trust source of this workbook, click Yes"
If i click Yes, it displays the data as expected, i don't see any
problems with it. Also if i generate only 1 worksheet this error does
not appear.
This is what my stored procedure returns, first result set is populated in sheet1 and second result set is populated in sheet2, which works as expected.
Workbook data
Here is the method i am using, it returns 2 result sets and populates both result sets in 2 different worksheets:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult POAReport(POAReportVM model)
{
POAReportVM poaReportVM = reportService.GetPOAReport(model);
using (var workbook = new XLWorkbook())
{
IXLWorksheet worksheet1 = workbook.Worksheets.Add("ProductOrderAccuracy");
worksheet1.Cell("A1").Value = "DATE";
worksheet1.Cell("B1").Value = "ORDER";
worksheet1.Cell("C1").Value = "";
var countsheet1 = 2;
for (int i = 0; i < poaReportVM.productOrderAccuracyList.Count; i++)
{
worksheet1.Cell(countsheet1, 1).Value = poaReportVM.productOrderAccuracyList[i].CompletedDate.ToString();
worksheet1.Cell(countsheet1, 2).Value = poaReportVM.productOrderAccuracyList[i].WebOrderID.ToString();
worksheet1.Cell(countsheet1, 3).Value = poaReportVM.productOrderAccuracyList[i].CompletedIndicator;
countsheet1++;
}
IXLWorksheet worksheet2 = workbook.Worksheets.Add("Summary");
worksheet2.Cell("A1").Value = "Total Orders Sampled";
worksheet2.Cell("B1").Value = "Passed";
worksheet2.Cell("C1").Value = "% Passed";
worksheet2.Cell(2, 1).Value = poaReportVM.summaryVM.TotalOrdersSampled.ToString();
worksheet2.Cell(2, 2).Value = poaReportVM.summaryVM.Passed.ToString();
worksheet2.Cell(2, 3).Value = poaReportVM.summaryVM.PassedPercentage.ToString();
//save file to memory stream and return it as byte array
using (var ms = new MemoryStream())
{
workbook.SaveAs(ms);
ms.Position = 0;
var content = ms.ToArray();
return File(content, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
}
}
I had similar problem. For me the cause was as mentioned in this answer:
I had this issue when I was using EPPlus to customise an existing template. For me the issue was in the template itself as it contained invalid references to lookup tables. I found this in Formula -> Name Manager.
You may find other solutions there.
Apologies as my reputation is too low to add a comment.

NODE RED http request - post image via API (Face++)

I have similar problem to this post
I get an image via a file buffer node. It works fine if this node goes into an visual-recognition node of ibm watson.
I also wanted to use this image to post it into another API. Therefore I use the http request node with URL = https://api-us.faceplusplus.com/facepp/v3/detect
And in front of it I use a function node to create header and body for this http request. It works very good. But I'm not able to "attach" the image to it.
I don't know the correct syntax. It's the line with "image_file".
var image = msg.payload;
msg.headers = {};
msg.headers["content-type"] ='application/x-www-form-urlencoded';
msg.payload = {};
msg.payload['api_key'] = 'zrxC';
msg.payload['api_secret'] = 's3UN';
msg.payload['image_file'] = image;
msg.payload['return_landmark'] = '1';
msg.payload['return_attributes'] = 'gender,age,emotion,beauty,skinstatus';
return msg;
If I use a different image input (url), it works.
msg.payload['image_url'] = 'http://picture.com/pic.jpg";
Soooo...syntax ;)
Maybe its also a problem, because the image needs another content-type. Is it possible to give different body parts different content-types?
Edit: I tried something with multipart http requests...here is my whole flow.
[{"id":"6c6e1506.29cf2c","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"b84cd67b.aaaee8","type":"http response","z":"6c6e1506.29cf2c","name":"","x":971,"y":602,"wires":[]},{"id":"a220ce16.64fcb","type":"http in","z":"6c6e1506.29cf2c","name":"Get Home Page","url":"/homepage","method":"get","upload":false,"swaggerDoc":"","x":441,"y":590,"wires":[["c46a3f0a.a30cb"]]},{"id":"c46a3f0a.a30cb","type":"template","z":"6c6e1506.29cf2c","name":"Form and Response Template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":" <html>\n <body>\n <form action=\"/classify\" method=\"post\" enctype=\"multipart/form-data\">\n <input type=\"file\" name=\"pic\" accept=\"image/*\"><br>\n <input type=\"submit\" value=\"Submit\">\n </form> \n <div>Classifications:</div>\n <div>\n {{#result}}\n <table>\n <tr>\n <th>Class</th>\n <th>Score</th>\n <th>Type</th>\n </tr>\n {{#images}}\n {{#.}}\n {{#classifiers}}\n {{#.}}\n {{#classes}}\n {{#.}}\n <tr>\n <td>{{class}}</td>\n <td>{{score}}</td> \n <td>{{&type_hierarchy}}</td>\n </tr> \n {{/.}} \n {{/classes}} \n {{/.}} \n {{/classifiers}}\n {{/.}}\n {{/images}}\n </table>\n {{/result}}\n </div>\n </body>\n</html>","x":720.5,"y":600,"wires":[["b84cd67b.aaaee8"]]},{"id":"ee17076b.7b9038","type":"function","z":"6c6e1506.29cf2c","name":" Determine File Path","func":"if (msg.req.files) {\n var files = Object.keys(msg.req.files);\n msg.payload = msg.req.files[files[0]][0].path; \n}\nreturn msg;","outputs":1,"noerr":0,"x":321.5,"y":737,"wires":[["d8385fe9.3b5d4"]]},{"id":"b4bcb13e.bd4a","type":"visual-recognition-v3","z":"6c6e1506.29cf2c","name":"","apikey":"3738dbb4a5ae703eb3d23285127f8a21233e6566","image-feature":"classifyImage","lang":"en","x":701,"y":716,"wires":[["95fdb967.895c98","c46a3f0a.a30cb"]]},{"id":"95fdb967.895c98","type":"debug","z":"6c6e1506.29cf2c","name":"","active":true,"tosidebar":true,"console":false,"complete":"result","x":912.5,"y":760,"wires":[]},{"id":"d8385fe9.3b5d4","type":"file-buffer","z":"6c6e1506.29cf2c","name":"","mode":"asBuffer","x":511,"y":793,"wires":[["b4bcb13e.bd4a","7b398291.92ee0c"]]},{"id":"5c0e525d.d8230c","type":"httpInMultipart","z":"6c6e1506.29cf2c","name":"Classify Image","url":"/classify","method":"post","fields":"[{ \"name\":\"pic\"}]","swaggerDoc":"","x":117,"y":774,"wires":[["ee17076b.7b9038"]]},{"id":"4d5c181f.bdcbe8","type":"http request","z":"6c6e1506.29cf2c","name":"face++","method":"POST","ret":"obj","url":"https://api-us.faceplusplus.com/facepp/v3/detect","tls":"","x":797,"y":928,"wires":[["11b9d42c.ae40ec"]]},{"id":"11b9d42c.ae40ec","type":"debug","z":"6c6e1506.29cf2c","name":"","active":true,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","x":1005,"y":927,"wires":[]},{"id":"7b398291.92ee0c","type":"function","z":"6c6e1506.29cf2c","name":"set payload and headers","func":"var image = msg.payload;\n\n\nmsg.headers = {};\nmsg.headers[\"content-type\"] ='application/x-www-form-urlencoded';\n\nmsg.payload = {};\nmsg.payload['api_key'] = 'z8lK8AM2u7X9CfI5PodNcFYv0OPq3rxC';\nmsg.payload['api_secret'] = 's33uL-coCxnDZn_naWMceZh-Xko1QSUN';\nmsg.payload['image_file'] = [image]; \nmsg.payload['return_landmark'] = '1';\nmsg.payload['return_attributes'] = 'gender,age,emotion,beauty,skinstatus';\n\n\nreturn msg;\n","outputs":1,"noerr":0,"x":560,"y":933,"wires":[["4d5c181f.bdcbe8"]]}]
My problem is to send the image to the red highlighted API.
To push a buffer as a field you need use the node-red-contrib-http-request-multipart to set the content-type in the headers to multipart/form-data.
Then you need to make sure the msg.payload object matches the input needed for the request node:
var image = msg.payload;
msg.headers = {};
msg.headers["content-type"] ='multipart/form-data';
msg.payload = {};
msg.payload['api_key'] = 'zrxC';
msg.payload['api_secret'] = 's3UN';
msg.payload['image_file'] = image;
msg.payload['return_landmark'] = '1';
msg.payload['return_attributes'] = 'gender,age,emotion,beauty,skinstatus';
return msg;

Image files dosen't print correctly in windows fax service

I've written some codes to send fax using faxcomlib. it work fine when running code in my windows application but i want to use my sending fax code in a windows service,the problem is go here when i try to send fax by using windows service, my problem is that when i sending text files,or pdf or word document it work fine,but when sending any image format like .jpg,.tiff,... i face to operation failed error and my service get hanged,i try this ways but unfortunately i didn't get any right anwser :
1- i get all permissions to my service and related folders
2- i try to convert images to the same format and size that fax printer use it ( CCITT T6 - 1740*2400)
3- i try to convert my images to pdf files and then send it but i cann't, despite already i did send pdf files without any errors.
and here is my codes for sendig fax :
if (ImageExtensions.Contains(System.IO.Path.GetExtension(tempFileName).ToUpperInvariant().Trim()))
{
string newFileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + #"\Temp\" + System.IO.Path.GetFileNameWithoutExtension(currentAttachment) + ".tif";
Toranj.Base.Graphic.Imaging.SaveTiff(tempFileName, newFileName);
Bitmap tempImage = new Bitmap(tempFileName);
System.Drawing.Image newImage = Toranj.Base.Graphic.Imaging.Resize(tempImage, 1728, 2200, RotateFlipType.RotateNoneFlipXY, 204, 196);
tempImage.Dispose();
System.IO.File.Delete(tempFileName);
newImage.Save(tempFileName);
newImage.Dispose();
Toranj.Base.Graphic.Imaging.SaveTiff(tempFileName, newFileName);
//PdfDocument doc = new PdfDocument();
//doc.Pages.Add(new PdfPage());
//XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
//XImage img = XImage.FromFile(tempFileName);
//xgr.DrawImage(img, 0, 0);
//doc.Save(newFileName);
//doc.Close();
fileList.Add(newFileName);
System.IO.File.Delete(tempFileName);
}
else
fileList.Add(tempFileName);
}
FAXCOMEXLib.FaxDocument currentDocument = new FAXCOMEXLib.FaxDocument();
string[] attachList = fileList.ToArray();
currentDocument.Bodies = attachList;
ShamsiDate curretnDate = new ShamsiDate(DateTime.Now);
currentDocument.DocumentName = "fax:" + curretnDate.PerSimpleDate();
currentDocument.Priority = FAXCOMEXLib.FAX_PRIORITY_TYPE_ENUM.fptHIGH;
currentDocument.Recipients.Add(currentRow["faxNumber"].ToString(), currentRow["RecipientName"].ToString());
currentDocument.AttachFaxToReceipt = true;
currentDocument.Sender.Title = "xxxxx";
currentDocument.Sender.Name = "";
currentDocument.Sender.City = "xxxxx";
currentDocument.Sender.Company = "xxxxx";
currentDocument.Sender.Country = "xxxxx";
currentDocument.Sender.Email = "xxxxx";
currentDocument.Sender.FaxNumber = "";
currentDocument.Sender.HomePhone = "";
currentDocument.Sender.TSID = "";
currentDocument.Sender.SaveDefaultSender();
object jobsId = new object();
currentDocument.ConnectedSubmit2(sendServer, out jobsId);
string[] jobID = (string[])jobsId;
can anyone help me?
in above code, if my files was image format files, i'll first change size,and save them az tiff format and convert it to the pdf format file to sending by fax but there is no change!!!

Encrypted cookies in Chrome

I am currently working on a C# forms application that needs to access a specific cookie on my computer, which I can do perfectly fine. Here's the issue:
Google stores cookies in SQLite, and I've downloaded Sqlite database browser to help me look at these values. What surprises me is that about half of the cookie values shows as empty (including the one I need), even though they are obviously not.
The db file is located at:
C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Cookies
On Chrome I have an addon called "Edit This Cookie" which allows me to directly modify cookies on the website I'm on. This addon can read these cookies, and the web browser can parse values through HTTP when needed for different requests, so they are definitely there - still, the SQLite browser, and my custom code both come to the conclusion that the particular value field is empty.
Why is that?
What is it that somehow prevents the field from being read by certain applications?
I've run into this same problem, and the code below provides a working example for anyone who is interested. All credit to Scherling, as the DPAPI was spot on.
public class ChromeCookieReader
{
public IEnumerable<Tuple<string,string>> ReadCookies(string hostName)
{
if (hostName == null) throw new ArgumentNullException("hostName");
var dbPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + #"\Google\Chrome\User Data\Default\Cookies";
if (!System.IO.File.Exists(dbPath)) throw new System.IO.FileNotFoundException("Cant find cookie store",dbPath); // race condition, but i'll risk it
var connectionString = "Data Source=" + dbPath + ";pooling=false";
using (var conn = new System.Data.SQLite.SQLiteConnection(connectionString))
using (var cmd = conn.CreateCommand())
{
var prm = cmd.CreateParameter();
prm.ParameterName = "hostName";
prm.Value = hostName;
cmd.Parameters.Add(prm);
cmd.CommandText = "SELECT name,encrypted_value FROM cookies WHERE host_key = #hostName";
conn.Open();
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
var encryptedData = (byte[]) reader[1];
var decodedData = System.Security.Cryptography.ProtectedData.Unprotect(encryptedData, null, System.Security.Cryptography.DataProtectionScope.CurrentUser);
var plainText = Encoding.ASCII.GetString(decodedData); // Looks like ASCII
yield return Tuple.Create(reader.GetString(0), plainText);
}
}
conn.Close();
}
}
}
Alright, so in case anyone is interested, I found a solution to this problem after alot of trial, error and googling.
Google Chrome cookies DB has 2 columns for storing values: "value" and "encrypted_value", the latter being used when the cookie stored was requested to be encrypted - often the case with certain confidential information and long-time session keys.
After figuring this out, I then needed to find a way to access this key, stored as a Blob value. I found several guides on how to do this, but the one that ended up paying of was: http://www.codeproject.com/Questions/56109/Reading-BLOB-in-Sqlite-using-C-NET-CF-PPC
Simply reading the value is not enough, as it is encrypted. - Google Chrome uses triple DES encryption with the current users password as seed on windows machines. In order to decrypt this in C#, one should use Windows Data Protection API (DPAPI), there are a few guides out there on how to make use of it.
Like Jasper's answer, in a PowerShell script (of course, customize the SQL query to your needs, and the path to your cookies location):
$cookieLocation = 'C:\Users\John\AppData\Local\Google\Chrome\User Data\Default\cookies'
$tempFileName = [System.IO.Path]::GetTempFileName()
"select writefile('$tempFileName', encrypted_value) from cookies where host_key = 'localhost' and path = '/api' and name = 'sessionId';" | sqlite3.exe "$cookieLocation"
$cookieAsEncryptedBytes = Get-Content -Encoding Byte "$tempFileName"
Remove-Item "$tempFileName"
Add-Type -AssemblyName System.Security
$cookieAsBytes = [System.Security.Cryptography.ProtectedData]::Unprotect($cookieAsEncryptedBytes, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)
$cookie = [System.Text.Encoding]::ASCII.GetString($cookieAsBytes)
$cookie
So I wanted to do this without writing to a tempfile every time but also without implementing a separate class as per jasper's solution. Like jasper, I found it easier and quicker to access the System.Data.SQLite.dll available here. It's not as elegant as a separate class, but it's what worked best for me:
Add-Type -AssemblyName System.Security
Add-Type -Path 'C:\Program Files\System.Data.SQLite\2015\bin\x64\System.Data.SQLite.dll'
Function Get-Last-Cookie {
Param(
[Parameter(Mandatory=$True)] $valueName,
[Parameter(Mandatory=$True)] $hostKey,
[Parameter(Mandatory=$True)] $dbDataSource
)
$conn = New-Object -TypeName System.Data.SQLite.SQLiteConnection
$conn.ConnectionString = "Data Source=$dbDataSource"
$conn.Open()
$command = $conn.CreateCommand()
$query = "SELECT encrypted_value FROM cookies WHERE name='$valueName' `
AND host_key='$hostKey' ORDER BY creation_utc DESC LIMIT 1"
$command.CommandText = $query
$adapter = New-Object -TypeName System.Data.SQLite.SQLiteDataAdapter $command
$dataset = New-Object System.Data.DataSet
[void]$adapter.Fill($dataset)
$command.Dispose();
$conn.Close();
$cookieAsEncryptedBytes = $dataset.Tables[0].Rows[0].ItemArray[0]
$cookieAsBytes = [System.Security.Cryptography.ProtectedData]::Unprotect($cookieAsEncryptedBytes, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)
return [System.Text.Encoding]::ASCII.GetString($cookieAsBytes)
}
$localAppDataPath = [Environment]::GetFolderPath([Environment+SpecialFolder]::LocalApplicationData)
$cookieDbPath = 'Google\Chrome\User Data\Default\Cookies'
$dbDataSource = Join-Path -Path $localAppDataPath -ChildPath $cookieDbPath
$plainCookie = Get-Last-Cookie 'acct' '.stackoverflow.com' $dbDataSource
Write-Host $plainCookie
I also found the Add-SqliteAssembly function by halr9000 to be very helpful when it came time to schedule my script in the windows task scheduler and realized that the task scheduler runs the x86 version of PowerShell and thus SQLite rather than the x64 I was using in the console.
The thing is that Google Chrome encrypts the data you need to read, so you have to decrypt it.
First, get a copy of the cookies file. Then read it using SQLite3. After that, get the encrypted bytes. And last, use the code below to decrypt it.
You'll need these Nugets:
using System.IO;
using System.Net;
using System.Data.SQLite;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Modes;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto;
using Newtonsoft.Json.Linq;
The code so far:
File.Copy(Environment.GetEnvironmentVariable("APPDATA") + #"/../Local/Google/Chrome/User Data/Default/Cookies", #"./Cookies",true);
SQLiteConnection Cnn = new SQLiteConnection("Data Source=" + #"./Cookies" + ";pooling=false");
Cnn.Open();
SQLiteCommand cmd = new SQLiteCommand("SELECT host_key, name, value, encrypted_value FROM cookies WHERE name='mvrusername' OR name='mvrcookie' OR name='mikuki4'", Cnn);
SQLiteDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
byte[] encryptedData = (byte[])rdr["encrypted_value"];
string encKey = File.ReadAllText(Environment.GetEnvironmentVariable("APPDATA") + #"/../Local/Google/Chrome/User Data/Local State");
encKey = JObject.Parse(encKey)["os_crypt"]["encrypted_key"].ToString();
var decodedKey = System.Security.Cryptography.ProtectedData.Unprotect(Convert.FromBase64String(encKey).Skip(5).ToArray(), null, System.Security.Cryptography.DataProtectionScope.LocalMachine);
const int MAC_BIT_SIZE = 128;
const int NONCE_BIT_SIZE = 96;
using (var cipherStream = new MemoryStream(encryptedData))
using (var cipherReader = new BinaryReader(cipherStream))
{
var nonSecretPayload = cipherReader.ReadBytes(3);
var nonce = cipherReader.ReadBytes(NONCE_BIT_SIZE / 8);
var cipher = new GcmBlockCipher(new AesEngine());
var parameters = new AeadParameters(new KeyParameter(decodedKey), MAC_BIT_SIZE, nonce);
cipher.Init(false, parameters);
var cipherText = cipherReader.ReadBytes(encryptedData.Length);
var plainText = new byte[cipher.GetOutputSize(cipherText.Length)];
try
{
var len = cipher.ProcessBytes(cipherText, 0, cipherText.Length, plainText, 0);
cipher.DoFinal(plainText, len);
}
catch (InvalidCipherTextException)
{
}
string _cookie= Encoding.Default.GetString(plainText);
}
}
// Big thanks to https://stackoverflow.com/a/60611673/6481581 for answering how Chrome 80 and up changed the way cookies are encrypted.
# this powershell scripts exports your cookies to a format curl and wget understand
# Obs ! Each profile has its own cookes file , replace me (ysg ;o) with your win usr name
# aka wget -x --load-cookies cookies.txt http://stackoverflow.com/questions/22532870/encrypted-cookies-in-chrome
$cookieLocation = 'C:\Users\ysg\AppData\Local\Google\Chrome\User Data\Profile 1\Cookies'
$curl_cookies_file="C:\var\ygeo.reports.app.futurice.com.cookies.doc-pub-host.txt"
$tempFileName1 = [System.IO.Path]::GetTempFileName()
$tempFileName2 = [System.IO.Path]::GetTempFileName()
# adjust your filter in the where clause ...
"select writefile('$tempFileName1', encrypted_value) from cookies where host_key = '.futurice.com' ;" | sqlite3.exe "$cookieLocation"
$cookieAsEncryptedBytes = Get-Content -Encoding Byte "$tempFileName1"
Remove-Item "$tempFileName1"
Add-Type -AssemblyName System.Security
$cookieAsBytes = [System.Security.Cryptography.ProtectedData]::Unprotect($cookieAsEncryptedBytes, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)
$cookie = [System.Text.Encoding]::ASCII.GetString($cookieAsBytes)
$unquoted_cookie=$cookie -replace '"', ""
# adjust your filter in the where clause ...
"
select
host_key
, CASE WHEN httponly=0 THEN 'FALSE' ELSE 'TRUE' END
, path
, CASE WHEN secure=0 THEN 'FALSE' ELSE 'TRUE' END
, expires_utc
, name
, '$unquoted_cookie'
from cookies where host_key = '.futurice.com' ;" | sqlite3.exe -separator " " "$cookieLocation" > $curl_cookies_file
Get-ChildItem *.txt | ForEach-Object { (Get-Content $_) | Out-File -Encoding ASCII $_ }
# check the meta data table
#"PRAGMA table_info([cookies]);" | sqlite3.exe "$cookieLocation"
# src: https://github.com/daftano/cookies.txt/blob/master/src/popup.js
#content += escapeForPre(cookie.domain);
#content += "\t";
#content += escapeForPre((!cookie.hostOnly).toString().toUpperCase());
#content += "\t";
#content += escapeForPre(cookie.path);
#content += "\t";
#content += escapeForPre(cookie.secure.toString().toUpperCase());
#content += "\t";
#content += escapeForPre(cookie.expirationDate ? Math.round(cookie.expirationDate) : "0");
#content += "\t";
#content += escapeForPre(cookie.name);
#content += "\t";
#content += escapeForPre(cookie.value);
#content += "\n";
#
#0|creation_utc|INTEGER|1||1
#1|host_key|TEXT|1||0
#2|name|TEXT|1||0
#3|value|TEXT|1||0
#4|path|TEXT|1||0
#5|expires_utc|INTEGER|1||0
#6|secure|INTEGER|1||0
#7|httponly|INTEGER|1||0
#8|last_access_utc|INTEGER|1||0
#9|has_expires|INTEGER|1|1|0
#10|persistent|INTEGER|1|1|0
#11|priority|INTEGER|1|1|0
#12|encrypted_value|BLOB|0|''|0
#13|firstpartyonly|INTEGER|1|0|0
Just set "value" to the cookie you want, "encrypted_value" to NULL and "priority" to 0

improve quality of recorded video using Red5 media server and oflaDemo app

what i do now is:
cam = Camera.getCamera(); // Get default camera.
mic = Microphone.getMicrophone(); // Get the microphone
cam.setMode(800, 600, 25);
cam.setQuality(0,90);
videoDisplay.attachCamera(cam);
and when the user clicks a button to record i do the following:
private function netStatusHandler(e:NetStatusEvent):void {
var code:String = e.info.code;
Alert.show("code = " + code);
if(code == "NetConnection.Connect.Success"){ //in case of recording...
ns = new NetStream(nc);
ns.attachCamera(cam);
ns.attachAudio(mic);
ns.publish( "file1", "record" );
}
else{
trace(code);
}
}
private function start_rec():void{
nc = new NetConnection();
nc.connect("rtmp://localhost/oflaDemo");
nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
}
but the quality of the recording is awful... i follow the same code as above to play the video instead of ns.publish i do ns.play() and the video shown is not as expected although when i ns.play() the ready made flv videos used as samples in red5 they play perfect..there is something wrong with the way i record? with the camera? whats going wrong? any idea??
The code to play the video is:
var nsClient:Object = {};
nsClient.onMetaData = ns_onMetaData;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.client = nsClient;
video = new Video(myVid.width,myVid.height);
video.attachNetStream(ns);
video.smoothing=true;
myVid.addChild(video);
ns.play("http://localhost:5080/oflaDemo/recordings/file1.flv");`
Thanks in advance!
camera = Camera.getCamera();
mic = Microphone.getMicrophone();
mic.setLoopBack(false);
mic.setUseEchoSuppression(true);
camera.setMode(640,480,30);
camera.setQuality(65536,90);
in camera.setQuality(65536,90); U can do 100 for best Quality, However it is your choice. Hopefully with these changes, ur quality will be improved very much. Also the quality depends on your webcam too.
The problem might be the bandwidth. Try to install a bandwidth limiter and then try the recording. You will have a very bad palyback.
If you have a high speed connection then everything will be fine.
If you are using RTMP protocol then it means that everything should be real time. So if the bandwidth is low frames will be dropped.

Resources