I'm trying to add subtitles to a video. But no video cannot be played. Here is my code;
AVPlayer avp;
AVPlayerViewController avpvc;
AVMutableComposition videoPlusSubtitles;
var subtitleEn = "SOME_VTT";
var videoURL = "SOME_MP4_URL";
var url = NSUrl.FromString(videoURL);
var nsVideoUrl = new NSUrl(videoURL);
var localVideoAsset = new AVUrlAsset(nsVideoUrl);
videoPlusSubtitles = new AVMutableComposition();
var videoTrack = videoPlusSubtitles.AddMutableTrack(AVMediaType.Video, 0);
NSError error = new NSError();
videoTrack.InsertTimeRange(CoreMedia.CMTimeRange.Zero, videoPlusSubtitles.TracksWithMediaType(AVMediaType.Video)[0], localVideoAsset.Duration, out error);
var subtitle1 = new NSUrl(subtitleEn);
var subtitleAsset = new AVUrlAsset(subtitle1);
var subttileTrack = videoPlusSubtitles.AddMutableTrack(AVMediaType.Text, 0);
subttileTrack.InsertTimeRange(CoreMedia.CMTimeRange.Zero, videoPlusSubtitles.TracksWithMediaType(AVMediaType.Text)[0], subtitleAsset.Duration, out error);
var playerItems = new AVPlayerItem(videoPlusSubtitles);
avpvc = new AVPlayerViewController();
avp = new AVPlayer(playerItems);
avpvc.Player = avp;
AddChildViewController(avpvc);
View.AddSubview(avpvc.View);
avpvc.View.Frame = View.Frame;
avpvc.ShowsPlaybackControls = true;
avp.Play();
When I type avp = new AVPlayer(url); instead of avp = new AVPlayer(playerItems); everything works fine, so no problems with the video. Any ideas?
This is working for me:
AVMutableComposition videoWithSubtitlesComposition = new AVMutableComposition();
AVMutableCompositionTrack videoTrack = videoWithSubtitlesComposition.AddMutableTrack(AVMediaType.Video, 0);
AVMutableCompositionTrack audioTrack = videoWithSubtitlesComposition.AddMutableTrack(AVMediaType.Audio, 0);
AVMutableCompositionTrack subtitlesTrack = videoWithSubtitlesComposition.AddMutableTrack(AVMediaType.Text, 0);
videoTrack.InsertTimeRange(
new CoreMedia.CMTimeRange { Start = CoreMedia.CMTime.Zero, Duration = videoAsset.Duration },
videoAsset.GetTracks(AVMediaTypes.Video)[0],
CoreMedia.CMTime.Zero, out _
);
audioTrack.InsertTimeRange(
new CoreMedia.CMTimeRange { Start = CoreMedia.CMTime.Zero, Duration = videoAsset.Duration },
videoAsset.GetTracks(AVMediaTypes.Audio)[0],
CoreMedia.CMTime.Zero, out _
);
subtitlesTrack.InsertTimeRange(
new CoreMedia.CMTimeRange { Start = CoreMedia.CMTime.Zero, Duration = subtitlesAsset.Duration },
subtitlesAsset.GetTracks(AVMediaTypes.Text)[0],
CoreMedia.CMTime.Zero, out _
);
In my case, I receive the audio and video track from an url that downloads an mp4 file and another url that downloads a vtt file. They correspond to the videoAsset and subtitlesAsset, respectively.
AVMediaType enum has "Subtitles" but using that instead of "Text" it does not work. Perhaps is a iOS bug.
Related
AWS Elemental Media Converter How To Create Job Thumbnail using .Net C# - I am unable to create the Aws Elemental Media Converter Job using .Net C#. facing the output group exception. I have tried with preset defined facing the same issue using the code and preset...
createJobRequest.Role = mediaConvertRole;
createJobRequest.Queue = jobQueue;
createJobRequest.UserMetadata.Add("Customer", "Amazon");
#region Create job settings
Amazon.MediaConvert.Model.JobSettings jobSettings = new Amazon.MediaConvert.Model.JobSettings();
jobSettings.AdAvailOffset = 0;
jobSettings.TimecodeConfig = new Amazon.MediaConvert.Model.TimecodeConfig();
jobSettings.TimecodeConfig.Source = Amazon.MediaConvert.TimecodeSource.EMBEDDED;
createJobRequest.Settings = jobSettings;
#region Thumbnail
Amazon.MediaConvert.Model.OutputGroup ofgT = new Amazon.MediaConvert.Model.OutputGroup();
ofgT.Name = "Thumbnail";
ofgT.OutputGroupSettings = new Amazon.MediaConvert.Model.OutputGroupSettings();
ofgT.OutputGroupSettings.Type = Amazon.MediaConvert.OutputGroupType.FILE_GROUP_SETTINGS;
ofgT.OutputGroupSettings.FileGroupSettings = new Amazon.MediaConvert.Model.FileGroupSettings();
ofgT.OutputGroupSettings.FileGroupSettings.Destination = fileOutput;
Amazon.MediaConvert.Model.Output outputT = new Amazon.MediaConvert.Model.Output();
outputT.NameModifier = "_thumb_00001";
outputT.Extension = "png";
output.Preset = preset_thumbnail;
#region Mp4 Container
outputT.ContainerSettings = new Amazon.MediaConvert.Model.ContainerSettings();
outputT.ContainerSettings.Container = Amazon.MediaConvert.ContainerType.MP4;
Amazon.MediaConvert.Model.Mp4Settings mp4T = new Amazon.MediaConvert.Model.Mp4Settings();
mp4T.CslgAtom = Amazon.MediaConvert.Mp4CslgAtom.INCLUDE;
mp4T.FreeSpaceBox = Amazon.MediaConvert.Mp4FreeSpaceBox.EXCLUDE;
mp4T.MoovPlacement = Amazon.MediaConvert.Mp4MoovPlacement.PROGRESSIVE_DOWNLOAD;
outputT.ContainerSettings.Mp4Settings = mp4T;
#endregion Mp4 Container
ofgT.Outputs.Add(outputT);
createJobRequest.Settings.OutputGroups.Add(ofgT);
#endregion Thumbnail
#region Input
Amazon.MediaConvert.Model.Input input = new Amazon.MediaConvert.Model.Input();
input.FilterEnable = Amazon.MediaConvert.InputFilterEnable.AUTO;
input.PsiControl = Amazon.MediaConvert.InputPsiControl.USE_PSI;
input.FilterStrength = 0;
input.DeblockFilter = Amazon.MediaConvert.InputDeblockFilter.DISABLED;
input.DenoiseFilter = Amazon.MediaConvert.InputDenoiseFilter.DISABLED;
input.TimecodeSource = Amazon.MediaConvert.InputTimecodeSource.EMBEDDED;
input.FileInput = fileInput;
Amazon.MediaConvert.Model.AudioSelector audsel = new Amazon.MediaConvert.Model.AudioSelector();
audsel.Offset = 0;
audsel.DefaultSelection = Amazon.MediaConvert.AudioDefaultSelection.NOT_DEFAULT;
audsel.ProgramSelection = 1;
input.AudioSelectors.Add("Audio Selector 1", audsel);
input.VideoSelector = new Amazon.MediaConvert.Model.VideoSelector();
input.VideoSelector.ColorSpace = Amazon.MediaConvert.ColorSpace.FOLLOW;
createJobRequest.Settings.Inputs.Add(input);
#endregion Input
Amazon.MediaConvert.Model.CreateJobResponse createJobResponse = mcClient.CreateJob(createJobRequest);
string jobId = createJobResponse.Job.Id;
AWS Elemental Media Converter How To Create Job Thumbnail using .Net C#
This Code solve my problem to generate the thumbnail using Aws elemental media converter. Passing the outoup object with these parameters:
Amazon.MediaConvert.Model.Output outputThumb = new Amazon.MediaConvert.Model.Output();
outputThumb.ContainerSettings = new Amazon.MediaConvert.Model.ContainerSettings { Container = Amazon.MediaConvert.ContainerType.RAW };
outputThumb.NameModifier = "_thumbnail";
outputThumb.Extension = "png";
outputThumb.VideoDescription = new Amazon.MediaConvert.Model.VideoDescription();
outputThumb.VideoDescription.CodecSettings = new Amazon.MediaConvert.Model.VideoCodecSettings();
outputThumb.VideoDescription.CodecSettings.Codec = "FRAME_CAPTURE";
outputThumb.VideoDescription.CodecSettings.FrameCaptureSettings = new Amazon.MediaConvert.Model.FrameCaptureSettings {
MaxCaptures = 1,
Quality = 100
};
ofg.Outputs.Add(outputThumb);
Trying to stitch multiple videos using AVAssetTrack and AVMutableCompositionTrack. Uploaded videos could have different audio settings (e.g. sample rate) - what's the best way to pass in desired audio settings when adding AVAssetTracks to AVMutableVideoComposition? Currently using the following code, certain videos with 48KHz stitched with 44.1KHz produce no sound when played on IE/Edge, but works on other browsers:
Composition = new AVMutableComposition();
AVMutableCompositionTrack VideoCompositionTrack = Composition.AddMutableTrack(AVMediaType.Video, 0);
AVMutableCompositionTrack AudioCompositionTrack = Composition.AddMutableTrack(AVMediaType.Audio, 1);
AVMutableVideoCompositionLayerInstruction LayerInstruction = AVMutableVideoCompositionLayerInstruction.FromAssetTrack(VideoCompositionTrack);
CMTime StartTime = CMTime.Zero;
AVUrlAssetOptions Options = new AVUrlAssetOptions
{
PreferPreciseDurationAndTiming = true
};
CMTimeRange TimeRange;
NSError InsertError = null;
int Counter = 0;
CGSize FinalRenderSize = new CGSize();
foreach (NSUrl VideoLocation in SelectedVideoLocations)
{
using (AVAsset Asset = new AVUrlAsset(VideoLocation, Options))
{
TimeRange = new CMTimeRange()
{
Start = CMTime.Zero,
Duration = Asset.Duration
};
if (Asset.TracksWithMediaType(AVMediaType.Video).Length > 0)
{
using (AVAssetTrack VideoAssetTrack = Asset.TracksWithMediaType(AVMediaType.Video)[0])
{
if (Counter == 0)
{
FinalRenderSize = VideoAssetTrack.NaturalSize;
}
LayerInstruction.SetTransform(VideoAssetTrack.PreferredTransform, StartTime);
VideoCompositionTrack.InsertTimeRange(TimeRange, VideoAssetTrack, StartTime, out InsertError);
}
}
if (Asset.TracksWithMediaType(AVMediaType.Audio).Length > 0)
{
using (AVAssetTrack AudioAssetTrack = Asset.TracksWithMediaType(AVMediaType.Audio)[0])
{
LayerInstruction.SetTransform(AudioAssetTrack.PreferredTransform, StartTime);
AudioCompositionTrack.InsertTimeRange(TimeRange, AudioAssetTrack, StartTime, out InsertError);
}
}
StartTime = CMTime.Add(StartTime, Asset.Duration);
Counter++;
}
}
AVMutableVideoCompositionInstruction MainInstruction = new AVMutableVideoCompositionInstruction
{
TimeRange = VideoCompositionTrack.TimeRange,
LayerInstructions = new AVVideoCompositionLayerInstruction[1] { LayerInstruction }
};
AVMutableVideoComposition CompositionInstruction = AVMutableVideoComposition.Create(Composition);
CompositionInstruction.Instructions = new AVMutableVideoCompositionInstruction[1] { MainInstruction };
CompositionInstruction.FrameDuration = new CMTime(1, 30);
CompositionInstruction.RenderScale = 1.0f;
CompositionInstruction.RenderSize = FinalRenderSize;
string FilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), FolderName, FileName);
await LocalStorage.DeleteFileAsync(FilePath);
NSUrl FilePathURL = NSUrl.CreateFileUrl(new string[] { FilePath });
MediaURL = FilePath;
AVAssetExportSession ExportSession = new AVAssetExportSession(Composition, AVAssetExportSessionPreset.Preset960x540);
if (CompositionInstruction != null)
{
ExportSession.VideoComposition = CompositionInstruction;
}
ExportSession.ShouldOptimizeForNetworkUse = true;
ExportSession.OutputUrl = FilePathURL;
ExportSession.OutputFileType = AVFileType.Mpeg4;
await ExportSession.ExportTaskAsync();
if (ExportSession.Status != AVAssetExportSessionStatus.Completed)
{
throw new Exception(ExportSession.Error.DebugDescription);
}
I'm building an android app with Xamarin which communicates with an ASP.net server's API. I'm trying to upload a file to the server using the following lines of code:
public async Task<HttpResponseMessage> UploadFile(byte[] file)
{
var progress = new System.Net.Http.Handlers.ProgressMessageHandler();
//progress.HttpSendProgress += progress_HttpSendProgress;
using (var client = HttpClientFactory.Create(progress))
{
client.BaseAddress = new Uri(GlobalVariables.host);
// Set the Accept header for BSON.
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/bson"));
var request = new uploadFileModel { data = file, dateCreated = DateTime.Now, fileName = "myvideooo.mp4", username = "psyoptica" };
// POST using the BSON formatter.
MediaTypeFormatter bsonFormatter = new BsonMediaTypeFormatter();
var m = client.MaxResponseContentBufferSize;
var result = await client.PostAsync("api/media/upload", request, bsonFormatter);
return result.EnsureSuccessStatusCode();
}
}
The app crashes before the server receives the request. The file I'm trying to upload could be a video or an audio file. The server receives the request after the app has crashed. This works fine on the local server but the crash happens with the live server. My server side code looks like this:
[HttpPost]
[Route("upload")]
public async Task<HttpResponseMessage> Upload(uploadFileModel model)
{
var result = new HttpResponseMessage(HttpStatusCode.OK);
if (ModelState.IsValid)
{
string thumbname = "";
string resizedthumbname = Guid.NewGuid() + "_yt.jpg";
string FfmpegPath = Encoding_Settings.FFMPEGPATH;
string tempFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/tempuploads"), model.fileName);
string pathToFiles = HttpContext.Current.Server.MapPath("~/tempuploads");
string pathToThumbs = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/thumbs");
string finalPath = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/flv");
string resizedthumb = Path.Combine(pathToThumbs, resizedthumbname);
var outputPathVid = new MediaFile { Filename = Path.Combine(finalPath, model.fileName) };
var inputPathVid = new MediaFile { Filename = Path.Combine(pathToFiles, model.fileName) };
int maxWidth = 380;
int maxHeight = 360;
var namewithoutext = Path.GetFileNameWithoutExtension(Path.Combine(pathToFiles, model.fileName));
thumbname = model.VideoThumbName;
string oldthumbpath = Path.Combine(pathToThumbs, thumbname);
var fileName = model.fileName;
File.WriteAllBytes(tempFilePath, model.data);
if (model.fileName.Contains("audio"))
{
File.WriteAllBytes(Path.Combine(finalPath, model.fileName), model.data);
string audio_thumb = "mic_thumb.jpg";
string destination = Path.Combine(pathToThumbs, audio_thumb);
string source = Path.Combine(pathToFiles, audio_thumb);
if (!System.IO.File.Exists(destination))
{
System.IO.File.Copy(source, destination, true);
}
Video_Struct vd = new Video_Struct();
vd.CategoryID = 0; // store categoryname or term instead of category id
vd.Categories = "";
vd.UserName = model.username;
vd.Title = "";
vd.Description = "";
vd.Tags = "";
vd.OriginalVideoFileName = model.fileName;
vd.VideoFileName = model.fileName;
vd.ThumbFileName = "mic_thumb.jpg";
vd.isPrivate = 0;
vd.AuthKey = "";
vd.isEnabled = 1;
vd.Response_VideoID = 0; // video responses
vd.isResponse = 0;
vd.isPublished = 1;
vd.isReviewed = 1;
vd.Thumb_Url = "none";
//vd.FLV_Url = flv_url;
vd.Embed_Script = "";
vd.isExternal = 0; // website own video, 1: embed video
vd.Type = 0;
vd.YoutubeID = "";
vd.isTagsreViewed = 1;
vd.Mode = 0; // filter videos based on website sections
long videoid = VideoBLL.Process_Info(vd, false);
}
else
{
using (var engine = new Engine())
{
engine.GetMetadata(inputPathVid);
// Saves the frame located on the 15th second of the video.
var outputPathThumb = new MediaFile { Filename = Path.Combine(pathToThumbs, thumbname+".jpg") };
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(0), CustomHeight = 360, CustomWidth = 380 };
engine.GetThumbnail(inputPathVid, outputPathThumb, options);
}
Image image = Image.FromFile(Path.Combine(pathToThumbs, thumbname+".jpg"));
//var ratioX = (double)maxWidth / image.Width;
//var ratioY = (double)maxHeight / image.Height;
//var ratio = Math.Min(ratioX, ratioY);
var newWidth = (int)(maxWidth);
var newHeight = (int)(maxHeight);
var newImage = new Bitmap(newWidth, newHeight);
Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);
Bitmap bmp = new Bitmap(newImage);
bmp.Save(Path.Combine(pathToThumbs, thumbname+"_resized.jpg"));
//File.Delete(Path.Combine(pathToThumbs, thumbname));
using (var engine = new Engine())
{
var conversionOptions = new ConversionOptions
{
VideoSize = VideoSize.Hd720,
AudioSampleRate = AudioSampleRate.Hz44100,
VideoAspectRatio = VideoAspectRatio.Default
};
engine.GetMetadata(inputPathVid);
engine.Convert(inputPathVid, outputPathVid, conversionOptions);
}
File.Delete(tempFilePath);
Video_Struct vd = new Video_Struct();
vd.CategoryID = 0; // store categoryname or term instead of category id
vd.Categories = "";
vd.UserName = model.username;
vd.Title = "";
vd.Description = "";
vd.Tags = "";
vd.Duration = inputPathVid.Metadata.Duration.ToString();
vd.Duration_Sec = Convert.ToInt32(inputPathVid.Metadata.Duration.Seconds.ToString());
vd.OriginalVideoFileName = model.fileName;
vd.VideoFileName = model.fileName;
vd.ThumbFileName = thumbname+"_resized.jpg";
vd.isPrivate = 0;
vd.AuthKey = "";
vd.isEnabled = 1;
vd.Response_VideoID = 0; // video responses
vd.isResponse = 0;
vd.isPublished = 1;
vd.isReviewed = 1;
vd.Thumb_Url = "none";
//vd.FLV_Url = flv_url;
vd.Embed_Script = "";
vd.isExternal = 0; // website own video, 1: embed video
vd.Type = 0;
vd.YoutubeID = "";
vd.isTagsreViewed = 1;
vd.Mode = 0; // filter videos based on website sections
//vd.ContentLength = f_contentlength;
vd.GalleryID = 0;
long videoid = VideoBLL.Process_Info(vd, false);
}
return result;
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}
}`
What am I doing wrong here that's making the app crash. Is there a better way to do this?
Any help is appreciated.
I was wondering if there was a way to crop videos in Xamarin. I can't seem to find any examples. I tried looking at the existing functions and Classes but I couldn't find anything.
Basically make square videos like what Vine and Instagram have. I think this is done by cropping out the rest of the video and not just zooming in.
I find part of the code from one source, I tried to add owner but I could not find. The solution's key part is added by me for cropping which is "VideoCleanAperture" inside AVVideoSettingsCompressed.
videoUrl = ((AVFoundation.AVUrlAsset)avAsset).Url;
NSError assetReaderError;
var assetReader = AVAssetReader.FromAsset(avAsset, out assetReaderError);
var assetTrack = avAsset.Tracks.First();
//Height = (System.nint?)avAsset.NaturalSize.Height,
//Width = (System.nint?)avAsset.NaturalSize.Width,
var inputSettings = new AVVideoSettingsUncompressed()
{
Height = (System.nint?)avAsset.NaturalSize.Height,
Width = (System.nint?)avAsset.NaturalSize.Width,
};
var assetReaderOutput = new AVAssetReaderTrackOutput(assetTrack, settings: inputSettings);
assetReaderOutput.AlwaysCopiesSampleData = false;
string tempFile = Path.Combine(Path.GetTempPath(), "CroppedVideo.mp4");
if (File.Exists(tempFile)) File.Delete(tempFile);
var url = NSUrl.FromFilename(tempFile);
NSError assetWriterError;
var assetWriter = new AVAssetWriter(url, AVFileType.Mpeg4, out assetWriterError);
var outputSettings = new AVVideoSettingsCompressed()
{
Height = 300,
Width = 300,
Codec = AVVideoCodec.H264,
CodecSettings = new AVVideoCodecSettings()
{
AverageBitRate = 1000000,
VideoCleanAperture = new AVVideoCleanApertureSettings(
new NSDictionary(
AVVideo.CleanApertureWidthKey, new NSNumber(300),
AVVideo.CleanApertureHeightKey, new NSNumber(300),
AVVideo.CleanApertureVerticalOffsetKey, new NSNumber(10),
AVVideo.CleanApertureHorizontalOffsetKey, new NSNumber(10)
)
)
},
ScalingMode = AVVideoScalingMode.ResizeAspectFill
};
var assetWriterInput = new AVAssetWriterInput(mediaType: AVMediaType.Video, outputSettings: outputSettings);
assetWriterInput.ExpectsMediaDataInRealTime = false;
assetWriter.AddInput(assetWriterInput);
assetWriter.StartWriting();
assetReader.AddOutput(assetReaderOutput);
assetReader.StartReading();
assetWriter.StartSessionAtSourceTime(CoreMedia.CMTime.Zero);
var mediaInputQueue = new DispatchQueue("mediaInputQueue");
assetWriterInput.RequestMediaData(mediaInputQueue, () =>
{
while (assetWriterInput.ReadyForMoreMediaData)
{
var nextBuffer = assetReaderOutput.CopyNextSampleBuffer();
if (nextBuffer != null)
{
assetWriterInput.AppendSampleBuffer(nextBuffer);
}
else
{
assetWriterInput.MarkAsFinished();
assetWriter.FinishWritingAsync();
assetReader.CancelReading();
assetReader.Dispose();
assetReaderOutput.Dispose();
assetWriter.Dispose();
assetWriterInput.Dispose();
break;
}
}
});
}
I am working on Expedia hotel API.All the function are working except booking.All the other request using GET method for requesting.But in booking we have to use the POST method with different URL.So i changed the URL for request but still getting the error.
My codes are
HotelServicesImplService client = new HotelServicesImplService();
HotelRoomReservationRequest bookreq = new HotelRoomReservationRequest();
HotelRoomReservationResponse bookres = new HotelRoomReservationResponse();
addressInfo bookad = new addressInfo();
reservationInfo bookinfo = new reservationInfo();
client.Url = "https://book.api.ean.com/ean-services/rs/hotel/v3";
//bookreq.minorRevSpecified = true;
//bookreq.minorRev = 25;
bookreq.hotelId = 106347;
bookreq.apiKey = "api";
bookreq.cid = "cid";
bookreq.arrivalDate = "12/11/2013";
bookreq.departureDate = "12/13/2013";
bookreq.supplierType = SupplierType.E;
bookreq.rateKey = "af00b688-acf4-409e-8bdc-fcfc3d1cb80c";
bookreq.roomTypeCode = "198058";
bookreq.rateCode = "484072";
bookreq.RoomGroup = new[] { new Room
{
numberOfAdults=Convert.ToInt32(2),
numberOfChildren=Convert.ToInt32(0),
childAges=new int[] {} ,
firstName="Test Booking",
lastName="Test Booking",
bedTypeId="23",
smokingPreference=SmokingPreference.NS,
}};
float i = float.Parse("231.18");
bookreq.currencyCode = "USD";
bookreq.chargeableRate = i;
bookinfo.email = "ranaabhi007#yahoo.com";
bookinfo.firstName = "TestBooking";
bookinfo.lastName = "TestBooking";
bookinfo.homePhone = "2145370159";
bookinfo.workPhone = "2145370159";
bookinfo.creditCardType = "CA";
bookinfo.creditCardNumber = "5401999999999999";
bookinfo.creditCardIdentifier = "TestBooking";
bookinfo.creditCardExpirationMonth = "12";
bookinfo.creditCardExpirationYear = "2015";
bookad.city = "Seattle";
bookad.stateProvinceCode = "WA";
bookad.countryCode = "US";
bookad.postalCode = "98004";
bookreq.ReservationInfo = bookinfo;
bookad.address1 = "travelnow";
//bookad.city = txtCity.Text;
//bookad.stateProvinceCode = txtState.Text;
//bookad.countryCode = txtCountry.Text;
//bookad.postalCode = txtPostal.Text;
bookreq.AddressInfo = bookad;
bookres = client.getReservation(bookreq);
// HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(client);
Response.Write(bookres.confirmationNumbers);
Response.Write(bookres.departureDate);
Response.Write(bookres.drivingDirections);
Response.Write(bookres.CouponInformationResponse);
but i am still getting the error
The request failed with HTTP status 404: Not Found.
Are you sure your URL is correct? According to the documentation, it should be
https://book.api.ean.com/ean-services/rs/hotel/v3/res