├── .gitignore ├── 7h800-2.mp4 ├── COPYING ├── COPYING.LESSER ├── Classes ├── AppDelegate.h ├── AppDelegate.m ├── AudioPacketQueue.h ├── AudioPacketQueue.m ├── AudioPlayer.h ├── AudioPlayer.m ├── AudioUtilities.h ├── AudioUtilities.m ├── H264_Save.h ├── H264_Save.m ├── Mp4_Save.c ├── Mp4_Save.h ├── Utilities.h ├── Utilities.m ├── VideoFrameExtractor.h ├── VideoFrameExtractor.m ├── iFrameExtractorViewController.h └── iFrameExtractorViewController.m ├── Default-568h@2x.png ├── Default.png ├── README.markdown ├── Storyboard.storyboard ├── gas-preprocessor.pl ├── h265_ex3.mp4 ├── iFrameExtractor-Info.plist ├── iFrameExtractor.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── iFrameExtractor.xccheckout │ └── xcuserdata │ │ └── wjie.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── liaokuohsun.xcuserdatad │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── wjie.xcuserdatad │ └── xcschemes │ ├── iFrameExtractor.xcscheme │ └── xcschememanagement.plist ├── iFrameExtractor_Prefix.pch ├── main.m └── sophie.mov /.gitignore: -------------------------------------------------------------------------------- 1 | ffmpeg/ 2 | .DS_Store 3 | 4 | *.xcuserstate 5 | 6 | *.xcsettings 7 | 8 | *.xcscheme 9 | 10 | iFrameExtractor.xcodeproj/xcuserdata/liaokuohsun.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist 11 | 12 | iFrameExtractor.xcodeproj/xcuserdata/liaokuohsun.xcuserdatad/xcschemes/xcschememanagement.plist 13 | -------------------------------------------------------------------------------- /7h800-2.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alb423/iFrameExtractor/c64609dd34c2064e8e2680c1f2441aeed628c500/7h800-2.mp4 -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | -------------------------------------------------------------------------------- /COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | 167 | -------------------------------------------------------------------------------- /Classes/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 2016/11/24. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 2016/11/24. 6 | // 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | #import "VideoFrameExtractor.h" 12 | #import "Utilities.h" 13 | #include "H264_Save.h" 14 | 15 | 16 | @implementation AppDelegate 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 19 | { 20 | // Override point for customization after application launch. 21 | 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 33 | NSLog(@"applicationDidEnterBackground"); 34 | 35 | /* 36 | AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; 37 | UINavigationController *nav = (UINavigationController *)delegate.window.rootViewController; 38 | */ 39 | 40 | //[self postNotificationWithName:remoteControlShowMessage]; 41 | 42 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 43 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 44 | } 45 | 46 | - (void)applicationWillEnterForeground:(UIApplication *)application 47 | { 48 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 49 | } 50 | 51 | - (void)applicationDidBecomeActive:(UIApplication *)application 52 | { 53 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 54 | } 55 | 56 | - (void)applicationWillTerminate:(UIApplication *)application 57 | { 58 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 59 | } 60 | 61 | 62 | - (void)postNotificationWithName:(NSString *)name 63 | { 64 | [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil]; 65 | } 66 | 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Classes/AudioPacketQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // AudioPacketQueue.h 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 13/4/19. 6 | // 7 | // 8 | 9 | #ifndef AudioPacketQueue_h 10 | #define AudioPacketQueue_h 11 | 12 | #import 13 | #include "libavformat/avformat.h" 14 | 15 | @interface AudioPacketQueue : NSObject{ 16 | NSMutableArray *pQueue; 17 | NSLock *pLock; 18 | 19 | } 20 | @property (nonatomic) NSInteger count; 21 | @property (nonatomic) NSInteger size; 22 | - (id) initQueue; 23 | - (void) destroyQueue; 24 | -(bool) putAVPacket: (AVPacket *) pkt; 25 | -(bool) getAVPacket :(AVPacket *) pkt; 26 | -(void)freeAVPacket:(AVPacket *) pkt; 27 | @end 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Classes/AudioPacketQueue.m: -------------------------------------------------------------------------------- 1 | // 2 | // AudioPacketQueue.m 3 | // a queue to store AVPacket from ffmpeg 4 | // 5 | // Created by Liao KuoHsun on 13/4/19. 6 | // 7 | // 8 | 9 | #import "AudioPacketQueue.h" 10 | 11 | @implementation AudioPacketQueue 12 | 13 | @synthesize count; 14 | @synthesize size; 15 | 16 | - (id) initQueue 17 | { 18 | self = [self init]; 19 | if(self != nil) 20 | { 21 | pQueue = [[NSMutableArray alloc] init]; 22 | pLock = [[NSLock alloc]init]; 23 | count = 0; 24 | size = 0; 25 | } 26 | return self; 27 | } 28 | 29 | // Useless in ARC mode 30 | - (void) destroyQueue { 31 | AVPacket vxPacket; 32 | NSMutableData *packetData = nil; 33 | 34 | [pLock lock]; 35 | while ([pQueue count]>0) { 36 | packetData = [pQueue objectAtIndex:0]; 37 | if(packetData!= nil) 38 | { 39 | [packetData getBytes:&vxPacket length:sizeof(AVPacket)]; 40 | av_packet_unref(&vxPacket); 41 | packetData = nil; 42 | [pQueue removeObjectAtIndex: 0]; 43 | count--; 44 | } 45 | } 46 | //[pQueue removeAllObjects]; 47 | count = 0; 48 | size = 0; 49 | NSLog(@"Release Audio Packet Queue"); 50 | if(pQueue) pQueue = nil; 51 | 52 | [pLock unlock]; 53 | if(pLock) pLock = nil; 54 | 55 | } 56 | 57 | -(bool) putAVPacket: (AVPacket *) pPacket{ 58 | 59 | // memory leakage is related to pPacket 60 | // if ((av_dup_packet(pPacket)) < 0) { 61 | // NSLog(@"Error duplicating packet"); 62 | // } 63 | 64 | [pLock lock]; 65 | 66 | //NSLog(@"putAVPacket %d", [pQueue count]); 67 | NSMutableData *pTmpData = [[NSMutableData alloc] initWithBytes:pPacket length:sizeof(*pPacket)]; 68 | [pQueue addObject: pTmpData]; 69 | size += pPacket->size; 70 | pTmpData = nil; 71 | count= count + 1; 72 | [pLock unlock]; 73 | return true; 74 | } 75 | 76 | -(bool ) getAVPacket :(AVPacket *) pPacket{ 77 | NSMutableData *packetData = nil; 78 | 79 | // Do we have any items? 80 | [pLock lock]; 81 | //if ([pQueue count]>0) { 82 | if (count>0) { 83 | packetData = [pQueue objectAtIndex:0]; 84 | if(packetData!= nil) 85 | { 86 | unsigned long vCount = [pQueue count]; 87 | // if(vCount<10) 88 | // NSLog(@"getAVPacket %ld", vCount); 89 | [packetData getBytes:pPacket length:sizeof(AVPacket)]; 90 | 91 | packetData = nil; 92 | [pQueue removeObjectAtIndex: 0]; 93 | if(pPacket) 94 | size = size - pPacket->size; 95 | count--; 96 | } 97 | [pLock unlock]; 98 | return true; 99 | } 100 | else 101 | { 102 | [pLock unlock]; 103 | return false; 104 | } 105 | 106 | return false; 107 | } 108 | 109 | -(void)freeAVPacket:(AVPacket *) pPacket{ 110 | [pLock lock]; 111 | av_packet_unref(pPacket); 112 | [pLock unlock]; 113 | } 114 | 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /Classes/AudioPlayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // AudioPlayer.h 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 13/4/19. 6 | // 7 | // 8 | 9 | #ifndef AudioPlayer_h 10 | #define AudioPlayer_h 11 | 12 | #import 13 | #import 14 | #import "AudioPacketQueue.h" 15 | #include "libavformat/avformat.h" 16 | #include "libavutil/opt.h" 17 | #include "libswresample/swresample.h" 18 | 19 | // An audio queue can use any number of buffers—your application specifies how many. A typical number is three. 20 | #define NUM_BUFFERS 3 21 | #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 22 | 23 | typedef enum eAACType { 24 | eAAC_UNDEFINED = 0, 25 | eAAC_RAW = 1, 26 | eAAC_ADTS = 2, 27 | eAAC_LATM = 3, 28 | }eAACType; 29 | 30 | 31 | @interface AudioPlayer : NSObject{ 32 | 33 | enum eAudioStatus { 34 | eAudioRunning = 1, 35 | eAudioStop = 2 36 | }; 37 | 38 | enum eAudioRecordingStatus { 39 | eRecordInit = 1, 40 | eRecordRecording = 2, 41 | eRecordStop = 3 42 | }; 43 | 44 | // 1 45 | AudioStreamBasicDescription mDataFormat; // 2 46 | AudioQueueRef mQueue; // 3 47 | AudioQueueBufferRef mBuffers[NUM_BUFFERS]; // 4 48 | AudioFileID mAudioFile; // 5 49 | UInt32 bufferByteSize; // 6 50 | SInt64 mCurrentPacket; // 7 51 | UInt32 mNumPacketsToRead; // 8 52 | AudioStreamPacketDescription *mPacketDescs; // 9 53 | bool mIsRunning; // 10 54 | 55 | bool isFormatVBR; 56 | 57 | AVCodecContext *aCodecCtx; 58 | AudioPacketQueue *audioPacketQueue; 59 | SwrContext *pSwrCtx; 60 | 61 | long LastStartTime; 62 | 63 | // For audio recording 64 | AVFormatContext *pRecordingAudioFC; 65 | AVCodecContext *pOutputCodecContext; 66 | bool enableRecording; 67 | UInt32 vRecordingAudioStreamIdx; 68 | UInt32 vRecordingAudioFormat; 69 | UInt32 vRecordingStatus; 70 | UInt32 vAudioOutputFileSize; 71 | FILE * pAudioOutputFile; 72 | //NSMutableArray *pSampleQueue; 73 | } 74 | 75 | -(id)initAudio: (AudioPacketQueue *) audioQueue withCodecCtx:(AVCodecContext *) aCodecCtx; 76 | - (int) Play; 77 | - (void) Stop:(BOOL)bStopImmediatelly; 78 | - (void) SetVolume:(float)vVolume; 79 | -(void) decodeAudioFile: (NSString *) FilePathIn ToPCMFile:(NSString *) FilePathOut withCodecCtx: (AVCodecContext *)pAudioCodecCtx withFormat:(AVFormatContext *) pFormatCtx withStreamIdx :(int) audioStream; 80 | -(int) getStatus; 81 | 82 | -(bool) putAVPacket: (AVPacket *) pkt; 83 | -(bool) getAVPacket :(AVPacket *) pkt; 84 | -(void)freeAVPacket:(AVPacket *) pkt; 85 | -(NSInteger) getSize; 86 | - (void) RecordingStart:(NSString *)pRecordingFile; 87 | - (void) RecordingStop; 88 | - (void) RecordingSetAudioFormat:(int)vAudioFormat; 89 | @property BOOL bIsADTSAAS; 90 | //@property NSMutableArray *pSampleQueue; 91 | @property eAACType vAACType; 92 | @end 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Classes/AudioUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // Utilities.h 3 | // FFmpegAudioPlayer 4 | // 5 | // Created by albert on 13/4/28. 6 | // Copyright (c) 2013年 Liao KuoHsun. All rights reserved. 7 | // 8 | 9 | #ifndef AudioUtilities_h 10 | #define AudioUtilities_h 11 | 12 | #import 13 | #import 14 | #import "AudioPacketQueue.h" 15 | #include "libavformat/avformat.h" 16 | #include "libavutil/opt.h" 17 | #include "libswresample/swresample.h" 18 | 19 | @interface AudioUtilities : NSObject 20 | 21 | // Reference : https://github.com/mstorsjo/libav/blob/fdk-aac/libavcodec/aacadtsdec.c 22 | typedef struct AACADTSHeaderInfo { 23 | 24 | // == adts_fixed_header == 25 | uint16_t syncword; // 12 bslbf 26 | uint8_t ID; // 1 bslbf 27 | uint8_t layer; // 2 uimsbf 28 | uint8_t protection_absent; // 1 bslbf 29 | uint8_t profile; // 2 uimsbf 30 | uint8_t sampling_frequency_index; // 4 uimsbf 31 | uint8_t private_bit; // 1 bslbf 32 | uint8_t channel_configuration; // 3 uimsbf 33 | uint8_t original_copy; // 1 bslbf 34 | uint8_t home; // 1 bslbf 35 | 36 | // == adts_variable_header == 37 | uint8_t copyright_identification_bit; //1 bslbf 38 | uint8_t copyright_identification_start; //1 bslbf 39 | uint16_t frame_length; //13 bslbf 40 | uint16_t adts_buffer_fullness; //11 bslbf 41 | uint8_t number_of_raw_data_blocks_in_frame; //2 uimsfb 42 | 43 | } tAACADTSHeaderInfo; 44 | 45 | + (BOOL) parseAACADTSHeader:(uint8_t *) pInput ToHeader:(tAACADTSHeaderInfo *) pADTSHeader; 46 | + (int) getMPEG4AudioSampleRates: (uint8_t) vSamplingIndex; 47 | 48 | + (int) EstimateAudioSecondsByBufferSize: (uint32_t) vSize WithSampleRate: (uint32_t)vSampleRate WithChannel: (uint32_t) vChannel ; 49 | + (id)initForDecodeAudioFile: (NSString *) FilePathIn ToPCMFile:(NSString *) FilePathOut; 50 | + (void) PrintFileStreamBasicDescription:(AudioStreamBasicDescription *) dataFormat; 51 | + (void) PrintFileStreamBasicDescriptionFromFile:(NSString *) FilePath; 52 | + (void) writeWavHeaderWithCodecCtx: (AVCodecContext *)pAudioCodecCtx withFormatCtx: (AVFormatContext *) pFormatCtx toFile: (FILE *) wavFile; 53 | @end 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /Classes/AudioUtilities.m: -------------------------------------------------------------------------------- 1 | // 2 | // Utilities.m 3 | // FFmpegAudioPlayer 4 | // 5 | // Created by albert on 13/4/28. 6 | // Copyright (c) 2013年 Liao KuoHsun. All rights reserved. 7 | // 8 | 9 | #import "AudioUtilities.h" 10 | 11 | @implementation AudioUtilities 12 | 13 | #pragma mark - For specific audio header parser 14 | 15 | // TODO: parseAACADTSHeader 16 | + (BOOL) parseAACADTSHeader:(uint8_t *) pInput ToHeader:(tAACADTSHeaderInfo *) pADTSHeader 17 | { 18 | BOOL bHasSyncword = FALSE; 19 | if(pADTSHeader==nil) 20 | return FALSE; 21 | 22 | // == adts_fixed_header == 23 | // syncword; 12 bslbf should be 0x1111 1111 1111 24 | if(pInput[0]==0xFF) 25 | { 26 | if((pInput[1]&0xF0)==0xF0) 27 | { 28 | bHasSyncword = TRUE; 29 | } 30 | } 31 | 32 | if(!bHasSyncword) return FALSE; 33 | 34 | //== adts_fixed_header == 35 | // uint16_t syncword; // 12 bslbf 36 | // uint8_t ID; // 1 bslbf 37 | // uint8_t layer; // 2 uimsbf 38 | // uint8_t protection_absent; // 1 bslbf 39 | // uint8_t profile; // 2 uimsbf 40 | // uint8_t sampling_frequency_index; // 4 uimsbf 41 | // uint8_t private_bit; // 1 bslbf 42 | // uint8_t channel_configuration; // 3 uimsbf 43 | // uint8_t original_copy; // 1 bslbf 44 | // uint8_t home; // 1 bslbf 45 | 46 | pADTSHeader->syncword = 0x0fff; 47 | pADTSHeader->ID = (pInput[1]&0x08)>>3; 48 | pADTSHeader->layer = (pInput[1]&0x06)>>2; 49 | pADTSHeader->protection_absent = pInput[1]&0x01; 50 | 51 | pADTSHeader->profile = (pInput[2]&0xC0)>>6; 52 | pADTSHeader->sampling_frequency_index = (pInput[2]&0x3C)>>2; 53 | pADTSHeader->private_bit = (pInput[2]&0x02)>>1; 54 | 55 | pADTSHeader->channel_configuration = ((pInput[2]&0x01)<<2) + ((pInput[3]&0xC0)>>6); 56 | pADTSHeader->original_copy = ((pInput[3]&0x20)>>5); 57 | pADTSHeader->home = ((pInput[3]&0x10)>>4); 58 | 59 | 60 | // == adts_variable_header == 61 | // copyright_identification_bit; 1 bslbf 62 | // copyright_identification_start; 1 bslbf 63 | // frame_length; 13 bslbf 64 | // adts_buffer_fullness; 11 bslbf 65 | // number_of_raw_data_blocks_in_frame; 2 uimsfb 66 | 67 | pADTSHeader->copyright_identification_bit = ((pInput[3]&0x08)>>3); 68 | pADTSHeader->copyright_identification_start = ((pInput[3]&0x04)>>2); 69 | pADTSHeader->frame_length = ((pInput[3]&0x03)<<11) + ((pInput[4])<<3) + ((pInput[5]&0xE0)>>5); 70 | pADTSHeader->adts_buffer_fullness = ((pInput[5]&0x1F)<<6) + ((pInput[6]&0xFC)>>2); 71 | pADTSHeader->number_of_raw_data_blocks_in_frame = ((pInput[6]&0x03)); 72 | 73 | 74 | // We can't use bits mask to convert byte array to ADTS structure. 75 | // http://mjfrazer.org/mjfrazer/bitfields/ 76 | // Big endian machines pack bitfields from most significant byte to least. 77 | // Little endian machines pack bitfields from least significant byte to most. 78 | // Direct bits mapping is hard.... we should implement a parser ourself. 79 | 80 | return TRUE; 81 | 82 | 83 | ; 84 | } 85 | 86 | // TODO in the future for audio recording 87 | - (uint8_t *) generateAACADTSHeader:(uint8_t *) pInOut ToHeader:(tAACADTSHeaderInfo *) pADTSHeader 88 | { 89 | if(pADTSHeader==nil) 90 | return NULL; 91 | 92 | // adts_fixed_header 93 | // syncword; 12 bslbf 94 | // ID; 1 bslbf 95 | // layer; 2 uimsbf 96 | // protection_absent; 1 bslbf 97 | // profile; 2 uimsbf 98 | // sampling_frequency_index; 4 uimsbf 99 | // private_bit; 1 bslbf 100 | // channel_configuration; 3 uimsbf 101 | // original/copy; 1 bslbf 102 | // home; 1 bslbf 103 | 104 | // adts_variable_header 105 | // copyright_identification_bit; 1 bslbf 106 | // copyright_identification_start; 1 bslbf 107 | // frame_length; 13 bslbf 108 | // adts_buffer_fullness; 11 bslbf 109 | // number_of_raw_data_blocks_in_frame; 2 uimsfb 110 | 111 | return NULL; 112 | } 113 | 114 | + (int) getMPEG4AudioSampleRates: (uint8_t) vSamplingIndex 115 | { 116 | int pRates[13] = { 117 | 96000, 88200, 64000, 48000, 44100, 32000, 118 | 24000, 22050, 16000, 12000, 11025, 8000, 7350 119 | }; 120 | 121 | if(vSamplingIndex<13) 122 | return pRates[vSamplingIndex]; 123 | else 124 | return 0; 125 | } 126 | 127 | + (void) PrintFileStreamBasicDescriptionFromFile:(NSString *) filePath 128 | { 129 | OSStatus status; 130 | UInt32 size; 131 | AudioFileID audioFile; 132 | AudioStreamBasicDescription dataFormat; 133 | 134 | CFURLRef URL = (__bridge CFURLRef)[NSURL fileURLWithPath:filePath]; 135 | //status=AudioFileOpenURL(URL, kAudioFileReadPermission, kAudioFileAAC_ADTSType, &audioFile); 136 | status=AudioFileOpenURL(URL, kAudioFileReadPermission, 0, &audioFile); 137 | if (status != noErr) { 138 | NSLog(@"*** Error *** PlayAudio - play:Path: could not open audio file. Path given was: %@", filePath); 139 | return ; 140 | } 141 | else { 142 | NSLog(@"*** OK *** : %@", filePath); 143 | } 144 | 145 | size = sizeof(dataFormat); 146 | AudioFileGetProperty(audioFile, kAudioFilePropertyDataFormat, &size, &dataFormat); 147 | if(size>0){ 148 | NSLog(@"mFormatID=%d", (signed int)dataFormat.mFormatID); 149 | NSLog(@"mFormatFlags=%d", (signed int)dataFormat.mFormatFlags); 150 | NSLog(@"mSampleRate=%ld", (signed long int)dataFormat.mSampleRate); 151 | NSLog(@"mBitsPerChannel=%d", (signed int)dataFormat.mBitsPerChannel); 152 | NSLog(@"mBytesPerFrame=%d", (signed int)dataFormat.mBytesPerFrame); 153 | NSLog(@"mBytesPerPacket=%d", (signed int)dataFormat.mBytesPerPacket); 154 | NSLog(@"mChannelsPerFrame=%d", (signed int)dataFormat.mChannelsPerFrame); 155 | NSLog(@"mFramesPerPacket=%d", (signed int)dataFormat.mFramesPerPacket); 156 | NSLog(@"mReserved=%d", (signed int)dataFormat.mReserved); 157 | } 158 | 159 | AudioFileClose(audioFile); 160 | } 161 | 162 | + (void) PrintFileStreamBasicDescription:(AudioStreamBasicDescription *) dataFormat 163 | { 164 | NSLog(@"mFormatID=%d", (signed int)dataFormat->mFormatID); 165 | NSLog(@"mFormatFlags=%d", (signed int)dataFormat->mFormatFlags); 166 | NSLog(@"mSampleRate=%ld", (signed long int)dataFormat->mSampleRate); 167 | NSLog(@"mBitsPerChannel=%d", (signed int)dataFormat->mBitsPerChannel); 168 | NSLog(@"mBytesPerFrame=%d", (signed int)dataFormat->mBytesPerFrame); 169 | NSLog(@"mBytesPerPacket=%d", (signed int)dataFormat->mBytesPerPacket); 170 | NSLog(@"mChannelsPerFrame=%d", (signed int)dataFormat->mChannelsPerFrame); 171 | NSLog(@"mFramesPerPacket=%d", (signed int)dataFormat->mFramesPerPacket); 172 | NSLog(@"mReserved=%d", (signed int)dataFormat->mReserved); 173 | } 174 | 175 | 176 | + (void) writeWavHeaderWithCodecCtx: (AVCodecContext *)pAudioCodecCtx withFormatCtx: (AVFormatContext *) pFormatCtx toFile: (FILE *) wavFile; 177 | { 178 | char *data; 179 | int32_t long_temp; 180 | int16_t short_temp; 181 | int16_t BlockAlign; 182 | int32_t fileSize; 183 | int32_t audioDataSize=0; 184 | 185 | int vBitsPerSample = 0; 186 | switch(pAudioCodecCtx->sample_fmt) { 187 | case AV_SAMPLE_FMT_S16: 188 | vBitsPerSample=16; 189 | break; 190 | case AV_SAMPLE_FMT_S32: 191 | vBitsPerSample=32; 192 | break; 193 | case AV_SAMPLE_FMT_U8: 194 | vBitsPerSample=8; 195 | break; 196 | default: 197 | vBitsPerSample=16; 198 | break; 199 | } 200 | 201 | if(pFormatCtx) 202 | { 203 | audioDataSize= (int32_t)((pFormatCtx->duration)*(vBitsPerSample/8)*(pAudioCodecCtx->sample_rate)*(pAudioCodecCtx->channels)); 204 | } 205 | fileSize=audioDataSize+36; 206 | 207 | // ============= 208 | // fmt subchunk 209 | data="RIFF"; 210 | fwrite(data,sizeof(char),4,wavFile); 211 | fwrite(&fileSize,sizeof(int32_t),1,wavFile); 212 | 213 | //"WAVE" 214 | data="WAVE"; 215 | fwrite(data,sizeof(char),4,wavFile); 216 | 217 | 218 | // ============= 219 | // fmt subchunk 220 | data="fmt "; 221 | fwrite(data,sizeof(char),4,wavFile); 222 | 223 | // SubChunk1Size (16 for PCM) 224 | long_temp=16; 225 | fwrite(&long_temp,sizeof(int32_t),1,wavFile); 226 | 227 | // AudioFormat, 1=PCM 228 | short_temp=0x01; 229 | fwrite(&short_temp,sizeof(int16_t),1,wavFile); 230 | 231 | // NumChannels (mono=1, stereo=2) 232 | short_temp=(pAudioCodecCtx->channels); 233 | fwrite(&short_temp,sizeof(int16_t),1,wavFile); 234 | 235 | // SampleRate (U32) 236 | long_temp=(pAudioCodecCtx->sample_rate); 237 | fwrite(&long_temp,sizeof(int32_t),1,wavFile); 238 | 239 | // ByteRate (U32) 240 | long_temp=(vBitsPerSample/8)*(pAudioCodecCtx->channels)*(pAudioCodecCtx->sample_rate); 241 | fwrite(&long_temp,sizeof(int32_t),1,wavFile); 242 | 243 | // BlockAlign (U16) 244 | BlockAlign=(vBitsPerSample/8)*(pAudioCodecCtx->channels); 245 | fwrite(&BlockAlign,sizeof(int16_t),1,wavFile); 246 | 247 | // BitsPerSaympe (U16) 248 | short_temp=(vBitsPerSample); 249 | fwrite(&short_temp,sizeof(int16_t),1,wavFile); 250 | 251 | // ============= 252 | // Data Subchunk 253 | data="data"; 254 | fwrite(data,sizeof(char),4,wavFile); 255 | 256 | // SubChunk2Size 257 | fwrite(&audioDataSize,sizeof(int32_t),1,wavFile); 258 | 259 | fseek(wavFile,44,SEEK_SET); 260 | } 261 | 262 | 263 | // Used to decode an audio file to PCM file with WAV header 264 | +(id) initForDecodeAudioFile: (NSString *) FilePathIn ToPCMFile:(NSString *) FilePathOut { 265 | // Test to write a audio file into PCM format file 266 | FILE *wavFile=NULL; 267 | AVPacket AudioPacket={0}; 268 | AVFrame *pAVFrame1; 269 | int iFrame=0; 270 | int audioFileSize=0; 271 | 272 | AVCodec *pAudioCodec; 273 | AVCodecContext *pAudioCodecCtx; 274 | AVFormatContext *pAudioFormatCtx; 275 | SwrContext *pSwrCtx = NULL; 276 | 277 | int audioStream = -1; 278 | 279 | avcodec_register_all(); 280 | av_register_all(); 281 | avformat_network_init(); 282 | 283 | pAudioFormatCtx = avformat_alloc_context(); 284 | 285 | if(avformat_open_input(&pAudioFormatCtx, [FilePathIn cStringUsingEncoding:NSASCIIStringEncoding], NULL, NULL) != 0){ 286 | av_log(NULL, AV_LOG_ERROR, "Couldn't open file\n"); 287 | } 288 | 289 | if(avformat_find_stream_info(pAudioFormatCtx,NULL) < 0) { 290 | av_log(NULL, AV_LOG_ERROR, "Couldn't find stream information\n"); 291 | } 292 | 293 | av_dump_format(pAudioFormatCtx, 0, [FilePathIn UTF8String], 0); 294 | 295 | int i; 296 | for(i=0;inb_streams;i++){ 297 | if(pAudioFormatCtx->streams[audioStream]->codecpar->codec_type==AVMEDIA_TYPE_AUDIO){ 298 | audioStream=i; 299 | break; 300 | } 301 | } 302 | if(audioStream<0) { 303 | av_log(NULL, AV_LOG_ERROR, "Cannot find a audio stream in the input file\n"); 304 | return nil; 305 | } 306 | 307 | 308 | //pAudioCodecCtx = pAudioFormatCtx->streams[audioStream]->codec; 309 | pAudioCodecCtx = avcodec_alloc_context3(NULL); 310 | avcodec_parameters_to_context(pAudioCodecCtx, pAudioFormatCtx->streams[audioStream]->codecpar); 311 | 312 | pAudioCodec = avcodec_find_decoder(pAudioCodecCtx->codec_id); 313 | if(pAudioCodec == NULL) { 314 | av_log(NULL, AV_LOG_ERROR, "Unsupported audio codec!\n"); 315 | } 316 | 317 | // If we want to change the argument about decode 318 | // We should set before invoke avcodec_open2() 319 | if(avcodec_open2(pAudioCodecCtx, pAudioCodec, NULL) < 0) { 320 | av_log(NULL, AV_LOG_ERROR, "Cannot open audio decoder\n"); 321 | } 322 | 323 | if(pAudioCodecCtx->sample_fmt==AV_SAMPLE_FMT_FLTP) 324 | { 325 | pSwrCtx = swr_alloc_set_opts(pSwrCtx, 326 | pAudioCodecCtx->channel_layout, 327 | AV_SAMPLE_FMT_S16, 328 | pAudioCodecCtx->sample_rate, 329 | pAudioCodecCtx->channel_layout, 330 | AV_SAMPLE_FMT_FLTP, 331 | pAudioCodecCtx->sample_rate, 332 | 0, 333 | 0); 334 | if(swr_init(pSwrCtx)<0) 335 | { 336 | NSLog(@"swr_init() for AV_SAMPLE_FMT_FLTP fail"); 337 | return nil; 338 | } 339 | } 340 | // For topview ipcam pcm_law 341 | else if(pAudioCodecCtx->bits_per_coded_sample==8) 342 | //else if(pAudioCodecCtx->sample_fmt==AV_SAMPLE_FMT_U8) 343 | { 344 | pSwrCtx = swr_alloc_set_opts(pSwrCtx, 345 | 1,//pAudioCodecCtx->channel_layout, 346 | AV_SAMPLE_FMT_S16, 347 | pAudioCodecCtx->sample_rate, 348 | 1,//pAudioCodecCtx->channel_layout, 349 | AV_SAMPLE_FMT_U8, 350 | pAudioCodecCtx->sample_rate, 351 | 0, 352 | 0); 353 | if(swr_init(pSwrCtx)<0) 354 | { 355 | NSLog(@"swr_init() fail"); 356 | return nil; 357 | } 358 | } 359 | 360 | wavFile=fopen([FilePathOut UTF8String],"wb"); 361 | if (wavFile==NULL) 362 | { 363 | printf("open file for writing error\n"); 364 | return self; 365 | } 366 | 367 | pAVFrame1 = av_frame_alloc(); 368 | av_init_packet(&AudioPacket); 369 | 370 | int buffer_size = 192000 + FF_INPUT_BUFFER_PADDING_SIZE; 371 | uint8_t buffer[buffer_size]; 372 | AudioPacket.data = buffer; 373 | AudioPacket.size = buffer_size; 374 | 375 | [AudioUtilities writeWavHeaderWithCodecCtx: pAudioCodecCtx withFormatCtx: pAudioFormatCtx toFile: wavFile]; 376 | while(av_read_frame(pAudioFormatCtx,&AudioPacket)>=0) { 377 | if(AudioPacket.stream_index==audioStream) { 378 | int vRet=0; 379 | if((iFrame++)>=4000) 380 | break; 381 | 382 | avcodec_send_packet(pAudioCodecCtx, &AudioPacket); 383 | do { 384 | vRet = avcodec_receive_frame(pAudioCodecCtx, pAVFrame1); 385 | } while(vRet==EAGAIN); 386 | 387 | if(vRet<0){ 388 | printf("Error while decoding\n"); 389 | break; 390 | } 391 | else { 392 | int data_size = av_samples_get_buffer_size(NULL, pAudioCodecCtx->channels, 393 | pAVFrame1->nb_samples,pAudioCodecCtx->sample_fmt, 1); 394 | 395 | // Resampling 396 | if(pAudioCodecCtx->sample_fmt==AV_SAMPLE_FMT_FLTP){ 397 | int in_samples = pAVFrame1->nb_samples; 398 | int outCount=0; 399 | uint8_t *out=NULL; 400 | int out_linesize; 401 | av_samples_alloc(&out, 402 | &out_linesize, 403 | pAVFrame1->channels, 404 | in_samples, 405 | AV_SAMPLE_FMT_S16, 406 | 0 407 | ); 408 | outCount = swr_convert(pSwrCtx, 409 | (uint8_t **)&out, 410 | in_samples, 411 | (const uint8_t **)pAVFrame1->extended_data, 412 | in_samples); 413 | 414 | if(outCount<0) 415 | NSLog(@"swr_convert fail"); 416 | 417 | fwrite(out, 1, data_size/2, wavFile); 418 | audioFileSize+=data_size/2; 419 | } 420 | 421 | fflush(wavFile); 422 | 423 | } 424 | } 425 | av_packet_unref(&AudioPacket); 426 | } 427 | fseek(wavFile,40,SEEK_SET); 428 | fwrite(&audioFileSize,1,sizeof(int32_t),wavFile); 429 | audioFileSize+=36; 430 | fseek(wavFile,4,SEEK_SET); 431 | fwrite(&audioFileSize,1,sizeof(int32_t),wavFile); 432 | fclose(wavFile); 433 | 434 | if (pSwrCtx) swr_free(&pSwrCtx); 435 | if (pAVFrame1) av_frame_free(&pAVFrame1); 436 | if (pAudioCodecCtx) avcodec_close(pAudioCodecCtx); 437 | if (pAudioFormatCtx) { 438 | avformat_close_input(&pAudioFormatCtx); 439 | } 440 | return self; 441 | } 442 | 443 | + (int) EstimateAudioSecondsByBufferSize: (uint32_t) vSize WithSampleRate: (uint32_t)vSampleRate WithChannel: (uint32_t) vChannel 444 | { 445 | return vSize/(vSampleRate*vChannel); 446 | } 447 | @end 448 | -------------------------------------------------------------------------------- /Classes/H264_Save.h: -------------------------------------------------------------------------------- 1 | // 2 | // H264_Save.h 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 13/5/24. 6 | // 7 | // 8 | 9 | #ifndef H264_Save_h 10 | #define H264_Save_h 11 | 12 | 13 | // TODO: when PTS_DTS_IS_CORRECT==1, it should ok?? 14 | #define PTS_DTS_IS_CORRECT 1 15 | 16 | extern int h264_file_create(const char *pFilePath, AVFormatContext *fc, AVCodecContext *pCodecCtx,AVCodecContext *pAudioCodecCtx, double fps, void *p, int len ); 17 | extern void h264_file_write_frame(AVFormatContext *fc, int vStreamId, const void* p, int len, int64_t dts, int64_t pts); 18 | extern void h264_file_write_audio_frame(AVFormatContext *fc, AVCodecContext *pAudioCodecContext,int vStreamIdx, const void* p, int len, int64_t dts, int64_t pts ); 19 | extern void h264_file_close(AVFormatContext *fc); 20 | 21 | extern void h264_file_write_frame2(AVFormatContext *fc, int vStreamIdx, AVPacket *pkt ); 22 | 23 | typedef enum 24 | { 25 | eH264RecIdle = 0, 26 | eH264RecInit, 27 | eH264RecActive, 28 | eH264RecClose 29 | } eH264RecordState; 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Classes/H264_Save.m: -------------------------------------------------------------------------------- 1 | // 2 | // H264_Save.c 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 13/5/24. 6 | // 7 | // 8 | 9 | // Reference ffmpeg\doc\examples\muxing.c 10 | #include 11 | #include "libavcodec/avcodec.h" 12 | #include "libavformat/avformat.h" 13 | #include "H264_Save.h" 14 | #import "AudioUtilities.h" 15 | 16 | int vVideoStreamIdx = -1, vAudioStreamIdx = -1, waitkey = 1; 17 | 18 | 19 | 20 | #if 1 //FFMpeg will link to libiconv(), so I write wrapp function here 21 | #include 22 | size_t libiconv(iconv_t cd, 23 | char **inbuf, size_t *inbytesleft, 24 | char **outbuf, size_t *outbytesleft) 25 | { 26 | return iconv( cd, inbuf, inbytesleft, outbuf, outbytesleft); 27 | } 28 | 29 | iconv_t libiconv_open(const char *tocode, const char *fromcode) 30 | { 31 | return iconv_open(tocode, fromcode); 32 | } 33 | 34 | int libiconv_close(iconv_t cd) 35 | { 36 | return iconv_close(cd); 37 | } 38 | #endif 39 | 40 | // < 0 = error 41 | // 0 = I-Frame 42 | // 1 = P-Frame 43 | // 2 = B-Frame 44 | // 3 = S-Frame 45 | static int getVopType( const void *p, int len ) 46 | { 47 | 48 | if ( !p || 6 >= len ) 49 | { 50 | fprintf(stderr, "getVopType() error"); 51 | return -1; 52 | } 53 | 54 | unsigned char *b = (unsigned char*)p; 55 | 56 | // Verify VOP id 57 | if ( 0xb6 == *b ) 58 | { 59 | b++; 60 | return ( *b & 0xc0 ) >> 6; 61 | } // end if 62 | 63 | switch( *b ) 64 | { 65 | case 0x65 : return 0; 66 | case 0x61 : return 1; 67 | case 0x01 : return 2; 68 | } // end switch 69 | 70 | return -1; 71 | } 72 | 73 | void h264_file_close(AVFormatContext *fc) 74 | { 75 | if ( !fc ) 76 | return; 77 | 78 | av_write_trailer( fc ); 79 | 80 | if ( fc->oformat && !( fc->oformat->flags & AVFMT_NOFILE ) && fc->pb ) 81 | avio_close( fc->pb ); 82 | 83 | av_free( fc ); 84 | } 85 | 86 | 87 | 88 | // Since the data may not from ffmpeg as AVPacket format 89 | void h264_file_write_frame(AVFormatContext *fc, int vStreamIdx, const void* p, int len, int64_t dts, int64_t pts ) 90 | { 91 | AVStream *pst = NULL; 92 | AVPacket pkt; 93 | 94 | if ( 0 > vVideoStreamIdx ) 95 | return; 96 | 97 | // may be audio or video 98 | pst = fc->streams[ vStreamIdx ]; 99 | 100 | // Init packet 101 | av_init_packet( &pkt ); 102 | 103 | if(vStreamIdx ==vVideoStreamIdx) 104 | { 105 | pkt.flags |= ( 0 >= getVopType( p, len ) ) ? AV_PKT_FLAG_KEY : 0; 106 | //pkt.flags |= AV_PKT_FLAG_KEY; 107 | pkt.stream_index = pst->index; 108 | pkt.data = (uint8_t*)p; 109 | pkt.size = len; 110 | 111 | #if PTS_DTS_IS_CORRECT == 1 112 | pkt.dts = dts; 113 | pkt.pts = pts; 114 | #else 115 | pkt.dts = AV_NOPTS_VALUE; 116 | pkt.pts = AV_NOPTS_VALUE; 117 | #endif 118 | // TODO: mark or unmark the log 119 | //fprintf(stderr, "dts=%lld, pts=%lld\n",dts,pts); 120 | // av_write_frame( fc, &pkt ); 121 | } 122 | av_interleaved_write_frame( fc, &pkt ); 123 | } 124 | 125 | void h264_file_write_audio_frame(AVFormatContext *fc, AVCodecContext *pAudioCodecContext ,int vStreamIdx, const void* pData, int vDataLen, int64_t dts, int64_t pts ) 126 | { 127 | int vRet=0; 128 | AVStream *pst = NULL; 129 | AVPacket pkt; 130 | 131 | if ( 0 > vVideoStreamIdx ) 132 | return; 133 | 134 | // may be audio or video 135 | pst = fc->streams[ vStreamIdx ]; 136 | 137 | // Init packet 138 | av_init_packet( &pkt ); 139 | 140 | if(vStreamIdx==vAudioStreamIdx) 141 | { 142 | int bIsADTSAAS=0, vRedudantHeaderOfAAC=0; 143 | tAACADTSHeaderInfo vxADTSHeader={0}; 144 | uint8_t *pHeader = (uint8_t *)pData; 145 | 146 | bIsADTSAAS = [AudioUtilities parseAACADTSHeader:pHeader ToHeader:(tAACADTSHeaderInfo *) &vxADTSHeader]; 147 | // If header has the syncword of adts_fixed_header 148 | // syncword = 0xFFF 149 | if(bIsADTSAAS) 150 | { 151 | vRedudantHeaderOfAAC = 7; 152 | } 153 | else 154 | { 155 | vRedudantHeaderOfAAC = 0; 156 | } 157 | 158 | #if 0 159 | int gotFrame=0, len=0; 160 | 161 | AVFrame vxAVFrame1={0}; 162 | AVFrame *pAVFrame1 = &vxAVFrame1; 163 | 164 | av_init_packet(&AudioPacket); 165 | av_frame_unref(pAVFrame1); 166 | 167 | if(bIsADTSAAS) 168 | { 169 | AudioPacket.size = vDataLen-vRedudantHeaderOfAAC; 170 | AudioPacket.data = pHeader+vRedudantHeaderOfAAC; 171 | } 172 | else 173 | { 174 | // This will produce error message 175 | // "malformated aac bitstream, use -absf aac_adtstoasc" 176 | AudioPacket.size = vDataLen; 177 | AudioPacket.data = pHeader; 178 | } 179 | // Decode from input format to PCM 180 | len = avcodec_decode_audio4(pAudioCodecContext, pAVFrame1, &gotFrame, &AudioPacket); 181 | 182 | // Encode from PCM to AAC 183 | vRet = avcodec_encode_audio2(pAudioOutputCodecContext, &pkt, pAVFrame1, &gotFrame); 184 | if(vRet!=0) 185 | NSLog(@"avcodec_encode_audio2 fail"); 186 | pkt.stream_index = vStreamIdx;//pst->index; 187 | 188 | #else 189 | 190 | // This will produce error message 191 | // "malformated aac bitstream, use -absf aac_adtstoasc" 192 | pkt.size = vDataLen-vRedudantHeaderOfAAC; 193 | pkt.data = pHeader+vRedudantHeaderOfAAC; 194 | pkt.stream_index = vStreamIdx;//pst->index; 195 | pkt.flags |= AV_PKT_FLAG_KEY; 196 | 197 | pkt.pts = pts; 198 | pkt.dts = dts; 199 | 200 | #endif 201 | // pkt.dts = AV_NOPTS_VALUE; 202 | // pkt.pts = AV_NOPTS_VALUE; 203 | vRet = av_interleaved_write_frame( fc, &pkt ); 204 | if(vRet!=0) 205 | NSLog(@"av_interleaved_write_frame for audio fail"); 206 | } 207 | } 208 | 209 | 210 | void h264_file_write_frame2(AVFormatContext *fc, int vStreamIdx, AVPacket *pPkt ) 211 | { 212 | av_interleaved_write_frame( fc, pPkt ); 213 | } 214 | 215 | 216 | int h264_file_create(const char *pFilePath, AVFormatContext *fc, AVCodecContext *pCodecCtx,AVCodecContext *pAudioCodecCtx, double fps, void *p, int len ) 217 | { 218 | int vRet=0; 219 | AVOutputFormat *of=NULL; 220 | AVStream *pst=NULL, *pst2=NULL; 221 | AVCodecContext *pcc=NULL, *pAudioOutputCodecContext=NULL; 222 | 223 | av_register_all(); 224 | av_log_set_level(AV_LOG_VERBOSE); 225 | 226 | if(!pFilePath) 227 | { 228 | fprintf(stderr, "FilePath no exist"); 229 | return -1; 230 | } 231 | 232 | if(!fc) 233 | { 234 | fprintf(stderr, "AVFormatContext no exist"); 235 | return -1; 236 | } 237 | fprintf(stderr, "file=%s\n",pFilePath); 238 | 239 | // Create container 240 | of = fc->oformat; 241 | strcpy( fc->filename, pFilePath ); 242 | 243 | // Add video stream 244 | pst = avformat_new_stream( fc, 0 ); 245 | vVideoStreamIdx = pst->index; 246 | NSLog(@"Video Stream:%d",vVideoStreamIdx); 247 | 248 | pcc = avcodec_alloc_context3(NULL); 249 | 250 | // Save the stream as origin setting without convert 251 | pcc->codec_type = pCodecCtx->codec_type; 252 | pcc->codec_id = pCodecCtx->codec_id; 253 | pcc->bit_rate = pCodecCtx->bit_rate; 254 | pcc->width = pCodecCtx->width; 255 | pcc->height = pCodecCtx->height; 256 | 257 | #if PTS_DTS_IS_CORRECT == 1 258 | pcc->time_base.num = pCodecCtx->time_base.num; 259 | pcc->time_base.den = pCodecCtx->time_base.den; 260 | pcc->ticks_per_frame = pCodecCtx->ticks_per_frame; 261 | 262 | NSLog(@"time_base, num=%d, den=%d, fps should be %g",\ 263 | pcc->time_base.num, pcc->time_base.den, \ 264 | (1.0/ av_q2d(pCodecCtx->time_base)/pcc->ticks_per_frame)); 265 | #else 266 | if(fps==0) 267 | { 268 | double fps=0.0; 269 | AVRational pTimeBase; 270 | pTimeBase.num = pCodecCtx->time_base.num; 271 | pTimeBase.den = pCodecCtx->time_base.den; 272 | fps = 1.0/ av_q2d(pCodecCtx->time_base)/ FFMAX(pCodecCtx->ticks_per_frame, 1); 273 | NSLog(@"fps_method(tbc): 1/av_q2d()=%g",fps); 274 | pcc->time_base.num = 1; 275 | pcc->time_base.den = fps; 276 | } 277 | else 278 | { 279 | pcc->time_base.num = 1; 280 | pcc->time_base.den = fps; 281 | } 282 | #endif 283 | 284 | // reference ffmpeg\libavformat\utils.c 285 | 286 | // For SPS and PPS in avcC container 287 | pcc->extradata = av_malloc(sizeof(uint8_t)*pCodecCtx->extradata_size); 288 | memcpy(pcc->extradata, pCodecCtx->extradata, pCodecCtx->extradata_size); 289 | pcc->extradata_size = pCodecCtx->extradata_size; 290 | 291 | avcodec_parameters_from_context(pst->codecpar, pcc); 292 | 293 | // Add audio stream 294 | if(pAudioCodecCtx) 295 | { 296 | 297 | pst2 = avformat_new_stream( fc, 0); 298 | vAudioStreamIdx = pst2->index; 299 | 300 | pAudioOutputCodecContext = avcodec_alloc_context3(NULL); 301 | 302 | pAudioOutputCodecContext->codec_type = pAudioCodecCtx->codec_type;//AVMEDIA_TYPE_AUDIO; 303 | pAudioOutputCodecContext->codec_id = pAudioCodecCtx->codec_id;//AV_CODEC_ID_AAC; 304 | 305 | // Copy the codec attributes 306 | pAudioOutputCodecContext->sample_fmt = pAudioCodecCtx->sample_fmt; 307 | pAudioOutputCodecContext->sample_rate = pAudioCodecCtx->sample_rate; 308 | pAudioOutputCodecContext->bit_rate = pAudioCodecCtx->sample_rate * pAudioCodecCtx->bits_per_coded_sample; //12000 309 | 310 | pAudioOutputCodecContext->channels = pAudioCodecCtx->channels; 311 | pAudioOutputCodecContext->channel_layout = pAudioCodecCtx->channel_layout; 312 | 313 | pAudioOutputCodecContext->bits_per_coded_sample = pAudioCodecCtx->bits_per_coded_sample; 314 | pAudioOutputCodecContext->profile = pAudioCodecCtx->profile; 315 | 316 | avcodec_parameters_from_context(pst2->codecpar, pAudioOutputCodecContext); 317 | 318 | NSLog(@"[Audio] Stream:%d",vAudioStreamIdx); 319 | NSLog(@"[Audio] bits_per_coded_sample=%d",pAudioCodecCtx->bits_per_coded_sample); 320 | NSLog(@"[Audio] profile:%d, sample_rate:%d, channles:%d", pAudioOutputCodecContext->profile, pAudioOutputCodecContext->sample_rate, pAudioOutputCodecContext->channels); 321 | 322 | } 323 | 324 | if(fc->oformat->flags & AVFMT_GLOBALHEADER) 325 | { 326 | pcc->flags |= CODEC_FLAG_GLOBAL_HEADER; 327 | if(pAudioOutputCodecContext) 328 | pAudioOutputCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER; 329 | } 330 | 331 | if ( !( fc->oformat->flags & AVFMT_NOFILE ) ) 332 | { 333 | vRet = avio_open( &fc->pb, fc->filename, AVIO_FLAG_WRITE ); 334 | if(vRet!=0) 335 | { 336 | NSLog(@"avio_open(%s) error", fc->filename); 337 | } 338 | } 339 | 340 | // dump format in console 341 | av_dump_format(fc, 0, pFilePath, 1); 342 | 343 | vRet = avformat_write_header( fc, NULL ); 344 | if(vRet==0) { 345 | return true; 346 | } 347 | else { 348 | NSLog(@"Fail, vRet=%d", vRet); 349 | return false; 350 | } 351 | 352 | } 353 | -------------------------------------------------------------------------------- /Classes/Mp4_Save.c: -------------------------------------------------------------------------------- 1 | // 2 | // H264_Save.c 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 13/5/24. 6 | // 7 | // 8 | 9 | // Reference ffmpeg\doc\examples\muxing.c 10 | #include 11 | #include "libavcodec/avcodec.h" 12 | #include "libavformat/avformat.h" 13 | #include "Mp4_Save.h" 14 | //#include "libavformat/avio.h" 15 | //#import "AudioUtilities.h" 16 | 17 | int vVideoStreamIdx = -1, vAudioStreamIdx = -1, waitkey = 1; 18 | 19 | 20 | 21 | 22 | // Reference : https://github.com/mstorsjo/libav/blob/fdk-aac/libavcodec/aacadtsdec.c 23 | typedef struct AACADTSHeaderInfo { 24 | 25 | // == adts_fixed_header == 26 | uint16_t syncword; // 12 bslbf 27 | uint8_t ID; // 1 bslbf 28 | uint8_t layer; // 2 uimsbf 29 | uint8_t protection_absent; // 1 bslbf 30 | uint8_t profile; // 2 uimsbf 31 | uint8_t sampling_frequency_index; // 4 uimsbf 32 | uint8_t private_bit; // 1 bslbf 33 | uint8_t channel_configuration; // 3 uimsbf 34 | uint8_t original_copy; // 1 bslbf 35 | uint8_t home; // 1 bslbf 36 | 37 | // == adts_variable_header == 38 | uint8_t copyright_identification_bit; //1 bslbf 39 | uint8_t copyright_identification_start; //1 bslbf 40 | uint16_t frame_length; //13 bslbf 41 | uint16_t adts_buffer_fullness; //11 bslbf 42 | uint8_t number_of_raw_data_blocks_in_frame; //2 uimsfb 43 | 44 | } tAACADTSHeaderInfo; 45 | 46 | int parseAACADTSHeader(unsigned char *pInput,tAACADTSHeaderInfo *pADTSHeader) 47 | { 48 | int bHasSyncword = 0; 49 | if(pADTSHeader==NULL) 50 | return 0; 51 | 52 | // == adts_fixed_header == 53 | // syncword; 12 bslbf should be 0x1111 1111 1111 54 | if(pInput[0]==0xFF) 55 | { 56 | if((pInput[1]&0xF0)==0xF0) 57 | { 58 | bHasSyncword = 1; 59 | } 60 | } 61 | 62 | if(!bHasSyncword) return 0; 63 | 64 | //== adts_fixed_header == 65 | // uint16_t syncword; // 12 bslbf 66 | // uint8_t ID; // 1 bslbf 67 | // uint8_t layer; // 2 uimsbf 68 | // uint8_t protection_absent; // 1 bslbf 69 | // uint8_t profile; // 2 uimsbf 70 | // uint8_t sampling_frequency_index; // 4 uimsbf 71 | // uint8_t private_bit; // 1 bslbf 72 | // uint8_t channel_configuration; // 3 uimsbf 73 | // uint8_t original_copy; // 1 bslbf 74 | // uint8_t home; // 1 bslbf 75 | 76 | pADTSHeader->syncword = 0x0fff; 77 | pADTSHeader->ID = (pInput[1]&0x08)>>3; 78 | pADTSHeader->layer = (pInput[1]&0x06)>>2; 79 | pADTSHeader->protection_absent = pInput[1]&0x01; 80 | 81 | pADTSHeader->profile = (pInput[2]&0xC0)>>6; 82 | pADTSHeader->sampling_frequency_index = (pInput[2]&0x3C)>>2; 83 | pADTSHeader->private_bit = (pInput[2]&0x02)>>1; 84 | 85 | pADTSHeader->channel_configuration = ((pInput[2]&0x01)<<2) + ((pInput[3]&0xC0)>>6); 86 | pADTSHeader->original_copy = ((pInput[3]&0x20)>>5); 87 | pADTSHeader->home = ((pInput[3]&0x10)>>4); 88 | 89 | 90 | // == adts_variable_header == 91 | // copyright_identification_bit; 1 bslbf 92 | // copyright_identification_start; 1 bslbf 93 | // frame_length; 13 bslbf 94 | // adts_buffer_fullness; 11 bslbf 95 | // number_of_raw_data_blocks_in_frame; 2 uimsfb 96 | 97 | pADTSHeader->copyright_identification_bit = ((pInput[3]&0x08)>>3); 98 | pADTSHeader->copyright_identification_start = ((pInput[3]&0x04)>>2); 99 | pADTSHeader->frame_length = ((pInput[3]&0x03)<<11) + ((pInput[4])<<3) + ((pInput[5]&0xE0)>>5); 100 | pADTSHeader->adts_buffer_fullness = ((pInput[5]&0x1F)<<6) + ((pInput[6]&0xFC)>>2); 101 | pADTSHeader->number_of_raw_data_blocks_in_frame = ((pInput[6]&0x03)); 102 | 103 | 104 | // We can't use bits mask to convert byte array to ADTS structure. 105 | // http://mjfrazer.org/mjfrazer/bitfields/ 106 | // Big endian machines pack bitfields from most significant byte to least. 107 | // Little endian machines pack bitfields from least significant byte to most. 108 | // Direct bits mapping is hard.... we should implement a parser ourself. 109 | 110 | return 1; 111 | } 112 | 113 | 114 | // < 0 = error 115 | // 0 = I-Frame 116 | // 1 = P-Frame 117 | // 2 = B-Frame 118 | // 3 = S-Frame 119 | static int getVopType( const void *p, int len ) 120 | { 121 | 122 | if ( !p || 6 >= len ) 123 | { 124 | fprintf(stderr, "getVopType() error"); 125 | return -1; 126 | } 127 | 128 | unsigned char *b = (unsigned char*)p; 129 | 130 | // Verify VOP id 131 | if ( 0xb6 == *b ) 132 | { 133 | b++; 134 | return ( *b & 0xc0 ) >> 6; 135 | } // end if 136 | 137 | switch( *b ) 138 | { 139 | case 0x65 : return 0; 140 | case 0x61 : return 1; 141 | case 0x01 : return 2; 142 | } // end switch 143 | 144 | return -1; 145 | } 146 | 147 | void h264_file_close(AVFormatContext *fc) 148 | { 149 | if ( !fc ) 150 | return; 151 | 152 | av_write_trailer( fc ); 153 | 154 | if ( fc->oformat && !( fc->oformat->flags & AVFMT_NOFILE ) && fc->pb ) 155 | avio_close( fc->pb ); 156 | 157 | av_free( fc ); 158 | } 159 | 160 | 161 | 162 | // Since the data may not from ffmpeg as AVPacket format 163 | void h264_file_write_frame(AVFormatContext *fc, int vStreamIdx, const void* p, int len, int64_t dts, int64_t pts ) 164 | { 165 | AVStream *pst = NULL; 166 | AVPacket pkt; 167 | 168 | if ( 0 > vVideoStreamIdx ) 169 | return; 170 | 171 | // may be audio or video 172 | pst = fc->streams[ vStreamIdx ]; 173 | 174 | // Init packet 175 | av_init_packet( &pkt ); 176 | 177 | if(vStreamIdx ==vVideoStreamIdx) 178 | { 179 | pkt.flags |= ( 0 >= getVopType( p, len ) ) ? AV_PKT_FLAG_KEY : 0; 180 | //pkt.flags |= AV_PKT_FLAG_KEY; 181 | pkt.stream_index = pst->index; 182 | pkt.data = (uint8_t*)p; 183 | pkt.size = len; 184 | 185 | #if PTS_DTS_IS_CORRECT == 1 186 | pkt.dts = dts; 187 | pkt.pts = pts; 188 | #else 189 | pkt.dts = AV_NOPTS_VALUE; 190 | pkt.pts = AV_NOPTS_VALUE; 191 | #endif 192 | // TODO: mark or unmark the log 193 | //fprintf(stderr, "dts=%lld, pts=%lld\n",dts,pts); 194 | // av_write_frame( fc, &pkt ); 195 | } 196 | av_interleaved_write_frame( fc, &pkt ); 197 | } 198 | 199 | void h264_file_write_audio_frame(AVFormatContext *fc, AVCodecContext *pAudioCodecContext ,int vStreamIdx, const void* pData, int vDataLen, int64_t dts, int64_t pts ) 200 | { 201 | int vRet=0; 202 | AVCodecContext *pAudioOutputCodecContext; 203 | AVStream *pst = NULL; 204 | AVPacket pkt; 205 | 206 | if ( 0 > vVideoStreamIdx ) 207 | return; 208 | 209 | // may be audio or video 210 | pst = fc->streams[ vStreamIdx ]; 211 | pAudioOutputCodecContext = pst->codec; 212 | 213 | // Init packet 214 | av_init_packet( &pkt ); 215 | 216 | if(vStreamIdx==vAudioStreamIdx) 217 | { 218 | if(pAudioOutputCodecContext==NULL) 219 | { 220 | fprintf(stderr,"pAudioOutputCodecContext==NULL"); 221 | } 222 | else 223 | { 224 | int bIsADTSAAS=0, vRedudantHeaderOfAAC=0; 225 | AVPacket AudioPacket={0}; 226 | tAACADTSHeaderInfo vxADTSHeader={0}; 227 | uint8_t *pHeader = (uint8_t *)pData; 228 | 229 | //bIsADTSAAS = [AudioUtilities parseAACADTSHeader:pHeader ToHeader:(tAACADTSHeaderInfo *) &vxADTSHeader]; 230 | bIsADTSAAS = parseAACADTSHeader(pHeader, &vxADTSHeader); 231 | // If header has the syncword of adts_fixed_header 232 | // syncword = 0xFFF 233 | if(bIsADTSAAS) 234 | { 235 | vRedudantHeaderOfAAC = 7; 236 | } 237 | else 238 | { 239 | vRedudantHeaderOfAAC = 0; 240 | } 241 | 242 | #if 0 243 | int gotFrame=0, len=0; 244 | 245 | AVFrame vxAVFrame1={0}; 246 | AVFrame *pAVFrame1 = &vxAVFrame1; 247 | 248 | av_init_packet(&AudioPacket); 249 | avcodec_get_frame_defaults(pAVFrame1); 250 | 251 | if(bIsADTSAAS) 252 | { 253 | AudioPacket.size = vDataLen-vRedudantHeaderOfAAC; 254 | AudioPacket.data = pHeader+vRedudantHeaderOfAAC; 255 | } 256 | else 257 | { 258 | // This will produce error message 259 | // "malformated aac bitstream, use -absf aac_adtstoasc" 260 | AudioPacket.size = vDataLen; 261 | AudioPacket.data = pHeader; 262 | } 263 | // Decode from input format to PCM 264 | len = avcodec_decode_audio4(pAudioCodecContext, pAVFrame1, &gotFrame, &AudioPacket); 265 | 266 | // Encode from PCM to AAC 267 | vRet = avcodec_encode_audio2(pAudioOutputCodecContext, &pkt, pAVFrame1, &gotFrame); 268 | if(vRet!=0) 269 | NSLog(@"avcodec_encode_audio2 fail"); 270 | pkt.stream_index = vStreamIdx;//pst->index; 271 | 272 | #else 273 | 274 | //if(pAudioCodecContext->codec_id==AV_CODEC_ID_AAC) 275 | { 276 | // This will produce error message 277 | // "malformated aac bitstream, use -absf aac_adtstoasc" 278 | pkt.size = vDataLen-vRedudantHeaderOfAAC; 279 | pkt.data = pHeader+vRedudantHeaderOfAAC; 280 | pkt.stream_index = vStreamIdx;//pst->index; 281 | pkt.flags |= AV_PKT_FLAG_KEY; 282 | 283 | } 284 | 285 | #endif 286 | // pkt.dts = AV_NOPTS_VALUE; 287 | // pkt.pts = AV_NOPTS_VALUE; 288 | vRet = av_interleaved_write_frame( fc, &pkt ); 289 | if(vRet!=0) 290 | fprintf(stderr,"av_interleaved_write_frame for audio fail"); 291 | } 292 | } 293 | 294 | 295 | } 296 | 297 | 298 | void h264_file_write_frame2(AVFormatContext *fc, int vStreamIdx, AVPacket *pPkt ) 299 | { 300 | av_interleaved_write_frame( fc, pPkt ); 301 | } 302 | 303 | 304 | int h264_file_create(const char *pFilePath, AVFormatContext *fc, AVCodecContext *pCodecCtx,AVCodecContext *pAudioCodecCtx, double fps, void *p, int len ) 305 | { 306 | int vRet=0; 307 | AVOutputFormat *of=NULL; 308 | AVStream *pst=NULL; 309 | AVCodecContext *pcc=NULL, *pAudioOutputCodecContext=NULL; 310 | 311 | avcodec_register_all(); 312 | av_register_all(); 313 | av_log_set_level(AV_LOG_VERBOSE); 314 | 315 | if(!pFilePath) 316 | { 317 | fprintf(stderr, "FilePath no exist"); 318 | return -1; 319 | } 320 | 321 | if(!fc) 322 | { 323 | fprintf(stderr, "AVFormatContext no exist"); 324 | return -1; 325 | } 326 | fprintf(stderr, "file=%s\n",pFilePath); 327 | 328 | // Create container 329 | of = av_guess_format( 0, pFilePath, 0 ); 330 | fc->oformat = of; 331 | strcpy( fc->filename, pFilePath ); 332 | 333 | // Add video stream 334 | pst = avformat_new_stream( fc, 0 ); 335 | vVideoStreamIdx = pst->index; 336 | fprintf(stderr,"Video Stream:%d",vVideoStreamIdx); 337 | 338 | pcc = pst->codec; 339 | avcodec_get_context_defaults3( pcc, AVMEDIA_TYPE_VIDEO ); 340 | 341 | // TODO: test here 342 | //*pcc = *pCodecCtx; 343 | 344 | // TODO: check ffmpeg source for "q=%d-%d", some parameter should be set before write header 345 | 346 | // Save the stream as origin setting without convert 347 | pcc->codec_type = pCodecCtx->codec_type; 348 | pcc->codec_id = pCodecCtx->codec_id; 349 | pcc->bit_rate = pCodecCtx->bit_rate; 350 | pcc->width = pCodecCtx->width; 351 | pcc->height = pCodecCtx->height; 352 | 353 | #if PTS_DTS_IS_CORRECT == 1 354 | pcc->time_base.num = pCodecCtx->time_base.num; 355 | pcc->time_base.den = pCodecCtx->time_base.den; 356 | pcc->ticks_per_frame = pCodecCtx->ticks_per_frame; 357 | // pcc->frame_bits= pCodecCtx->frame_bits; 358 | // pcc->frame_size= pCodecCtx->frame_size; 359 | // pcc->frame_number= pCodecCtx->frame_number; 360 | 361 | // pcc->pts_correction_last_dts = pCodecCtx->pts_correction_last_dts; 362 | // pcc->pts_correction_last_pts = pCodecCtx->pts_correction_last_pts; 363 | 364 | NSLog(@"time_base, num=%d, den=%d, fps should be %g",\ 365 | pcc->time_base.num, pcc->time_base.den, \ 366 | (1.0/ av_q2d(pCodecCtx->time_base)/pcc->ticks_per_frame)); 367 | #else 368 | if(fps==0) 369 | { 370 | double fps=0.0; 371 | AVRational pTimeBase; 372 | pTimeBase.num = pCodecCtx->time_base.num; 373 | pTimeBase.den = pCodecCtx->time_base.den; 374 | fps = 1.0/ av_q2d(pCodecCtx->time_base)/ FFMAX(pCodecCtx->ticks_per_frame, 1); 375 | fprintf(stderr,"fps_method(tbc): 1/av_q2d()=%g",fps); 376 | pcc->time_base.num = 1; 377 | pcc->time_base.den = fps; 378 | } 379 | else 380 | { 381 | pcc->time_base.num = 1; 382 | pcc->time_base.den = fps; 383 | } 384 | #endif 385 | // reference ffmpeg\libavformat\utils.c 386 | 387 | // For SPS and PPS in avcC container 388 | pcc->extradata = malloc(sizeof(uint8_t)*pCodecCtx->extradata_size); 389 | memcpy(pcc->extradata, pCodecCtx->extradata, pCodecCtx->extradata_size); 390 | pcc->extradata_size = pCodecCtx->extradata_size; 391 | 392 | // For Audio stream 393 | if(pAudioCodecCtx) 394 | { 395 | AVCodec *pAudioCodec=NULL; 396 | AVStream *pst2=NULL; 397 | pAudioCodec = avcodec_find_encoder(AV_CODEC_ID_AAC); 398 | 399 | // Add audio stream 400 | pst2 = avformat_new_stream( fc, pAudioCodec ); 401 | vAudioStreamIdx = pst2->index; 402 | pAudioOutputCodecContext = pst2->codec; 403 | avcodec_get_context_defaults3( pAudioOutputCodecContext, pAudioCodec ); 404 | fprintf(stderr,"Audio Stream:%d",vAudioStreamIdx); 405 | fprintf(stderr,"pAudioCodecCtx->bits_per_coded_sample=%d",pAudioCodecCtx->bits_per_coded_sample); 406 | 407 | pAudioOutputCodecContext->codec_type = AVMEDIA_TYPE_AUDIO; 408 | pAudioOutputCodecContext->codec_id = AV_CODEC_ID_AAC; 409 | 410 | // Copy the codec attributes 411 | pAudioOutputCodecContext->channels = pAudioCodecCtx->channels; 412 | pAudioOutputCodecContext->channel_layout = pAudioCodecCtx->channel_layout; 413 | pAudioOutputCodecContext->sample_rate = pAudioCodecCtx->sample_rate; 414 | pAudioOutputCodecContext->bit_rate = 12000;//pAudioCodecCtx->sample_rate * pAudioCodecCtx->bits_per_coded_sample; 415 | pAudioOutputCodecContext->bits_per_coded_sample = pAudioCodecCtx->bits_per_coded_sample; 416 | pAudioOutputCodecContext->profile = pAudioCodecCtx->profile; 417 | //FF_PROFILE_AAC_LOW; 418 | // pAudioCodecCtx->bit_rate; 419 | 420 | // AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P 421 | //pAudioOutputCodecContext->sample_fmt = AV_SAMPLE_FMT_FLTP;//pAudioCodecCtx->sample_fmt; 422 | pAudioOutputCodecContext->sample_fmt = pAudioCodecCtx->sample_fmt; 423 | //pAudioOutputCodecContext->sample_fmt = AV_SAMPLE_FMT_U8; 424 | 425 | pAudioOutputCodecContext->sample_aspect_ratio = pAudioCodecCtx->sample_aspect_ratio; 426 | 427 | pAudioOutputCodecContext->time_base.num = pAudioCodecCtx->time_base.num; 428 | pAudioOutputCodecContext->time_base.den = pAudioCodecCtx->time_base.den; 429 | pAudioOutputCodecContext->ticks_per_frame = pAudioCodecCtx->ticks_per_frame; 430 | pAudioOutputCodecContext->frame_size = 1024; 431 | 432 | fprintf(stderr,"profile:%d, sample_rate:%d, channles:%d", pAudioOutputCodecContext->profile, pAudioOutputCodecContext->sample_rate, pAudioOutputCodecContext->channels); 433 | AVDictionary *opts = NULL; 434 | av_dict_set(&opts, "strict", "experimental", 0); 435 | 436 | if (avcodec_open2(pAudioOutputCodecContext, pAudioCodec, &opts) < 0) { 437 | fprintf(stderr, "\ncould not open codec\n"); 438 | } 439 | 440 | av_dict_free(&opts); 441 | 442 | #if 0 443 | // For Audio, this part is no need 444 | if(pAudioCodecCtx->extradata_size!=0) 445 | { 446 | NSLog(@"extradata_size !=0"); 447 | pAudioOutputCodecContext->extradata = malloc(sizeof(uint8_t)*pAudioCodecCtx->extradata_size); 448 | memcpy(pAudioOutputCodecContext->extradata, pAudioCodecCtx->extradata, pAudioCodecCtx->extradata_size); 449 | pAudioOutputCodecContext->extradata_size = pAudioCodecCtx->extradata_size; 450 | } 451 | else 452 | { 453 | // For WMA test only 454 | pAudioOutputCodecContext->extradata_size = 0; 455 | NSLog(@"extradata_size ==0"); 456 | } 457 | #endif 458 | } 459 | 460 | if(fc->oformat->flags & AVFMT_GLOBALHEADER) 461 | { 462 | pcc->flags |= CODEC_FLAG_GLOBAL_HEADER; 463 | pAudioOutputCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER; 464 | } 465 | 466 | if ( !( fc->oformat->flags & AVFMT_NOFILE ) ) 467 | { 468 | vRet = avio_open( &fc->pb, fc->filename, AVIO_FLAG_WRITE ); 469 | if(vRet!=0) 470 | { 471 | fprintf(stderr,"avio_open(%s) error", fc->filename); 472 | } 473 | } 474 | 475 | // dump format in console 476 | av_dump_format(fc, 0, pFilePath, 1); 477 | 478 | vRet = avformat_write_header( fc, NULL ); 479 | if(vRet==0) 480 | return 1; 481 | else 482 | return 0; 483 | } 484 | 485 | 486 | 487 | 488 | /* 489 | * qt-faststart.c, v0.2 490 | * by Mike Melanson (melanson@pcisys.net) 491 | * This file is placed in the public domain. Use the program however you 492 | * see fit. 493 | * 494 | * This utility rearranges a Quicktime file such that the moov atom 495 | * is in front of the data, thus facilitating network streaming. 496 | * 497 | * To compile this program, start from the base directory from which you 498 | * are building FFmpeg and type: 499 | * make tools/qt-faststart 500 | * The qt-faststart program will be built in the tools/ directory. If you 501 | * do not build the program in this manner, correct results are not 502 | * guaranteed, particularly on 64-bit platforms. 503 | * Invoke the program with: 504 | * qt-faststart 505 | * 506 | * Notes: Quicktime files can come in many configurations of top-level 507 | * atoms. This utility stipulates that the very last atom in the file needs 508 | * to be a moov atom. When given such a file, this utility will rearrange 509 | * the top-level atoms by shifting the moov atom from the back of the file 510 | * to the front, and patch the chunk offsets along the way. This utility 511 | * presently only operates on uncompressed moov atoms. 512 | */ 513 | 514 | #include 515 | #include 516 | #include 517 | #include 518 | 519 | #ifdef __MINGW32__ 520 | #define fseeko(x, y, z) fseeko64(x, y, z) 521 | #define ftello(x) ftello64(x) 522 | #elif defined(_WIN32) 523 | #define fseeko(x, y, z) _fseeki64(x, y, z) 524 | #define ftello(x) _ftelli64(x) 525 | #endif 526 | 527 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) 528 | 529 | #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) 530 | 531 | #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \ 532 | (((uint8_t*)(x))[1] << 16) | \ 533 | (((uint8_t*)(x))[2] << 8) | \ 534 | ((uint8_t*)(x))[3]) 535 | 536 | #define BE_64(x) (((uint64_t)(((uint8_t*)(x))[0]) << 56) | \ 537 | ((uint64_t)(((uint8_t*)(x))[1]) << 48) | \ 538 | ((uint64_t)(((uint8_t*)(x))[2]) << 40) | \ 539 | ((uint64_t)(((uint8_t*)(x))[3]) << 32) | \ 540 | ((uint64_t)(((uint8_t*)(x))[4]) << 24) | \ 541 | ((uint64_t)(((uint8_t*)(x))[5]) << 16) | \ 542 | ((uint64_t)(((uint8_t*)(x))[6]) << 8) | \ 543 | ((uint64_t)( (uint8_t*)(x))[7])) 544 | 545 | #define BE_FOURCC(ch0, ch1, ch2, ch3) \ 546 | ( (uint32_t)(unsigned char)(ch3) | \ 547 | ((uint32_t)(unsigned char)(ch2) << 8) | \ 548 | ((uint32_t)(unsigned char)(ch1) << 16) | \ 549 | ((uint32_t)(unsigned char)(ch0) << 24) ) 550 | 551 | #define QT_ATOM BE_FOURCC 552 | /* top level atoms */ 553 | #define FREE_ATOM QT_ATOM('f', 'r', 'e', 'e') 554 | #define JUNK_ATOM QT_ATOM('j', 'u', 'n', 'k') 555 | #define MDAT_ATOM QT_ATOM('m', 'd', 'a', 't') 556 | #define MOOV_ATOM QT_ATOM('m', 'o', 'o', 'v') 557 | #define PNOT_ATOM QT_ATOM('p', 'n', 'o', 't') 558 | #define SKIP_ATOM QT_ATOM('s', 'k', 'i', 'p') 559 | #define WIDE_ATOM QT_ATOM('w', 'i', 'd', 'e') 560 | #define PICT_ATOM QT_ATOM('P', 'I', 'C', 'T') 561 | #define FTYP_ATOM QT_ATOM('f', 't', 'y', 'p') 562 | #define UUID_ATOM QT_ATOM('u', 'u', 'i', 'd') 563 | 564 | #define CMOV_ATOM QT_ATOM('c', 'm', 'o', 'v') 565 | #define STCO_ATOM QT_ATOM('s', 't', 'c', 'o') 566 | #define CO64_ATOM QT_ATOM('c', 'o', '6', '4') 567 | 568 | #define ATOM_PREAMBLE_SIZE 8 569 | #define COPY_BUFFER_SIZE 33554432 570 | 571 | 572 | //int main(int argc, char *argv[]) 573 | int MoveMP4MoovToHeader(char *pSrc, char *pDst) 574 | { 575 | FILE *infile = NULL; 576 | FILE *outfile = NULL; 577 | unsigned char atom_bytes[ATOM_PREAMBLE_SIZE]; 578 | uint32_t atom_type = 0; 579 | uint64_t atom_size = 0; 580 | uint64_t atom_offset = 0; 581 | uint64_t last_offset; 582 | unsigned char *moov_atom = NULL; 583 | unsigned char *ftyp_atom = NULL; 584 | uint64_t moov_atom_size; 585 | uint64_t ftyp_atom_size = 0; 586 | uint64_t i, j; 587 | uint32_t offset_count; 588 | uint64_t current_offset; 589 | int64_t start_offset = 0; 590 | unsigned char *copy_buffer = NULL; 591 | int bytes_to_copy; 592 | 593 | if((pSrc==NULL) || (pDst==NULL)) return 0 ; 594 | 595 | // if (argc != 3) { 596 | // printf("Usage: qt-faststart \n"); 597 | // return 0; 598 | // } 599 | // 600 | // if (!strcmp(argv[1], argv[2])) { 601 | // fprintf(stderr, "input and output files need to be different\n"); 602 | // return 1; 603 | // } 604 | 605 | infile = fopen(pSrc, "rb"); 606 | if (!infile) { 607 | perror(pSrc); 608 | goto error_out; 609 | } 610 | 611 | /* traverse through the atoms in the file to make sure that 'moov' is 612 | * at the end */ 613 | while (!feof(infile)) { 614 | if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) { 615 | break; 616 | } 617 | atom_size = (uint32_t) BE_32(&atom_bytes[0]); 618 | atom_type = BE_32(&atom_bytes[4]); 619 | 620 | /* keep ftyp atom */ 621 | if (atom_type == FTYP_ATOM) { 622 | ftyp_atom_size = atom_size; 623 | free(ftyp_atom); 624 | ftyp_atom = malloc(ftyp_atom_size); 625 | if (!ftyp_atom) { 626 | printf("could not allocate %"PRIu64" bytes for ftyp atom\n", 627 | atom_size); 628 | goto error_out; 629 | } 630 | if ( fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR) 631 | || fread(ftyp_atom, atom_size, 1, infile) != 1 632 | || (start_offset = ftello(infile))<0) { 633 | perror(pSrc); 634 | goto error_out; 635 | } 636 | } else { 637 | int ret; 638 | /* 64-bit special case */ 639 | if (atom_size == 1) { 640 | if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) { 641 | break; 642 | } 643 | atom_size = BE_64(&atom_bytes[0]); 644 | ret = fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR); 645 | } else { 646 | ret = fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR); 647 | } 648 | if(ret) { 649 | perror(pSrc); 650 | goto error_out; 651 | } 652 | } 653 | printf("%c%c%c%c %10"PRIu64" %"PRIu64"\n", 654 | (atom_type >> 24) & 255, 655 | (atom_type >> 16) & 255, 656 | (atom_type >> 8) & 255, 657 | (atom_type >> 0) & 255, 658 | atom_offset, 659 | atom_size); 660 | if ((atom_type != FREE_ATOM) && 661 | (atom_type != JUNK_ATOM) && 662 | (atom_type != MDAT_ATOM) && 663 | (atom_type != MOOV_ATOM) && 664 | (atom_type != PNOT_ATOM) && 665 | (atom_type != SKIP_ATOM) && 666 | (atom_type != WIDE_ATOM) && 667 | (atom_type != PICT_ATOM) && 668 | (atom_type != UUID_ATOM) && 669 | (atom_type != FTYP_ATOM)) { 670 | printf("encountered non-QT top-level atom (is this a QuickTime file?)\n"); 671 | break; 672 | } 673 | atom_offset += atom_size; 674 | 675 | /* The atom header is 8 (or 16 bytes), if the atom size (which 676 | * includes these 8 or 16 bytes) is less than that, we won't be 677 | * able to continue scanning sensibly after this atom, so break. */ 678 | if (atom_size < 8) 679 | break; 680 | } 681 | 682 | if (atom_type != MOOV_ATOM) { 683 | printf("last atom in file was not a moov atom\n"); 684 | free(ftyp_atom); 685 | fclose(infile); 686 | return 0; 687 | } 688 | 689 | /* moov atom was, in fact, the last atom in the chunk; load the whole 690 | * moov atom */ 691 | if (fseeko(infile, -atom_size, SEEK_END)) { 692 | perror(pSrc); 693 | goto error_out; 694 | } 695 | last_offset = ftello(infile); 696 | moov_atom_size = atom_size; 697 | moov_atom = malloc(moov_atom_size); 698 | if (!moov_atom) { 699 | printf("could not allocate %"PRIu64" bytes for moov atom\n", atom_size); 700 | goto error_out; 701 | } 702 | if (fread(moov_atom, atom_size, 1, infile) != 1) { 703 | perror(pSrc); 704 | goto error_out; 705 | } 706 | 707 | /* this utility does not support compressed atoms yet, so disqualify 708 | * files with compressed QT atoms */ 709 | if (BE_32(&moov_atom[12]) == CMOV_ATOM) { 710 | printf("this utility does not support compressed moov atoms yet\n"); 711 | goto error_out; 712 | } 713 | 714 | /* close; will be re-opened later */ 715 | fclose(infile); 716 | infile = NULL; 717 | 718 | /* crawl through the moov chunk in search of stco or co64 atoms */ 719 | for (i = 4; i < moov_atom_size - 4; i++) { 720 | atom_type = BE_32(&moov_atom[i]); 721 | if (atom_type == STCO_ATOM) { 722 | printf(" patching stco atom...\n"); 723 | atom_size = (uint32_t)BE_32(&moov_atom[i - 4]); 724 | if (i + atom_size - 4 > moov_atom_size) { 725 | printf(" bad atom size\n"); 726 | goto error_out; 727 | } 728 | offset_count = BE_32(&moov_atom[i + 8]); 729 | if (i + 12LL + offset_count * 4LL > moov_atom_size) { 730 | printf(" bad atom size\n"); 731 | goto error_out; 732 | } 733 | for (j = 0; j < offset_count; j++) { 734 | current_offset = (uint32_t)BE_32(&moov_atom[i + 12 + j * 4]); 735 | current_offset += moov_atom_size; 736 | moov_atom[i + 12 + j * 4 + 0] = (current_offset >> 24) & 0xFF; 737 | moov_atom[i + 12 + j * 4 + 1] = (current_offset >> 16) & 0xFF; 738 | moov_atom[i + 12 + j * 4 + 2] = (current_offset >> 8) & 0xFF; 739 | moov_atom[i + 12 + j * 4 + 3] = (current_offset >> 0) & 0xFF; 740 | } 741 | i += atom_size - 4; 742 | } else if (atom_type == CO64_ATOM) { 743 | printf(" patching co64 atom...\n"); 744 | atom_size = (uint32_t)BE_32(&moov_atom[i - 4]); 745 | if (i + atom_size - 4 > moov_atom_size) { 746 | printf(" bad atom size\n"); 747 | goto error_out; 748 | } 749 | offset_count = BE_32(&moov_atom[i + 8]); 750 | if (i + 12LL + offset_count * 8LL > moov_atom_size) { 751 | printf(" bad atom size\n"); 752 | goto error_out; 753 | } 754 | for (j = 0; j < offset_count; j++) { 755 | current_offset = BE_64(&moov_atom[i + 12 + j * 8]); 756 | current_offset += moov_atom_size; 757 | moov_atom[i + 12 + j * 8 + 0] = (current_offset >> 56) & 0xFF; 758 | moov_atom[i + 12 + j * 8 + 1] = (current_offset >> 48) & 0xFF; 759 | moov_atom[i + 12 + j * 8 + 2] = (current_offset >> 40) & 0xFF; 760 | moov_atom[i + 12 + j * 8 + 3] = (current_offset >> 32) & 0xFF; 761 | moov_atom[i + 12 + j * 8 + 4] = (current_offset >> 24) & 0xFF; 762 | moov_atom[i + 12 + j * 8 + 5] = (current_offset >> 16) & 0xFF; 763 | moov_atom[i + 12 + j * 8 + 6] = (current_offset >> 8) & 0xFF; 764 | moov_atom[i + 12 + j * 8 + 7] = (current_offset >> 0) & 0xFF; 765 | } 766 | i += atom_size - 4; 767 | } 768 | } 769 | 770 | /* re-open the input file and open the output file */ 771 | infile = fopen(pSrc, "rb"); 772 | if (!infile) { 773 | perror(pSrc); 774 | goto error_out; 775 | } 776 | 777 | if (start_offset > 0) { /* seek after ftyp atom */ 778 | if (fseeko(infile, start_offset, SEEK_SET)) { 779 | perror(pSrc); 780 | goto error_out; 781 | } 782 | 783 | last_offset -= start_offset; 784 | } 785 | 786 | outfile = fopen(pDst, "wb"); 787 | if (!outfile) { 788 | perror(pDst); 789 | goto error_out; 790 | } 791 | 792 | /* dump the same ftyp atom */ 793 | if (ftyp_atom_size > 0) { 794 | printf(" writing ftyp atom...\n"); 795 | if (fwrite(ftyp_atom, ftyp_atom_size, 1, outfile) != 1) { 796 | perror(pDst); 797 | goto error_out; 798 | } 799 | } 800 | 801 | /* dump the new moov atom */ 802 | printf(" writing moov atom...\n"); 803 | if (fwrite(moov_atom, moov_atom_size, 1, outfile) != 1) { 804 | perror(pDst); 805 | goto error_out; 806 | } 807 | 808 | /* copy the remainder of the infile, from offset 0 -> last_offset - 1 */ 809 | bytes_to_copy = FFMIN(COPY_BUFFER_SIZE, last_offset); 810 | copy_buffer = malloc(bytes_to_copy); 811 | if (!copy_buffer) { 812 | printf("could not allocate %d bytes for copy_buffer\n", bytes_to_copy); 813 | goto error_out; 814 | } 815 | printf(" copying rest of file...\n"); 816 | while (last_offset) { 817 | bytes_to_copy = FFMIN(bytes_to_copy, last_offset); 818 | 819 | if (fread(copy_buffer, bytes_to_copy, 1, infile) != 1) { 820 | perror(pSrc); 821 | goto error_out; 822 | } 823 | if (fwrite(copy_buffer, bytes_to_copy, 1, outfile) != 1) { 824 | perror(pDst); 825 | goto error_out; 826 | } 827 | last_offset -= bytes_to_copy; 828 | } 829 | 830 | fclose(infile); 831 | fclose(outfile); 832 | free(moov_atom); 833 | free(ftyp_atom); 834 | free(copy_buffer); 835 | 836 | return 0; 837 | 838 | error_out: 839 | if (infile) 840 | fclose(infile); 841 | if (outfile) 842 | fclose(outfile); 843 | free(moov_atom); 844 | free(ftyp_atom); 845 | free(copy_buffer); 846 | return 1; 847 | } 848 | 849 | 850 | -------------------------------------------------------------------------------- /Classes/Mp4_Save.h: -------------------------------------------------------------------------------- 1 | // 2 | // H264_Save.h 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 13/5/24. 6 | // 7 | // 8 | 9 | #ifndef H264_Save_h 10 | #define H264_Save_h 11 | <<<<<<< HEAD:Classes/H264_Save.h 12 | 13 | ======= 14 | >>>>>>> origin/master:Classes/Mp4_Save.h 15 | 16 | // TODO: when PTS_DTS_IS_CORRECT==1, it should ok?? 17 | #define PTS_DTS_IS_CORRECT 0 18 | 19 | extern int h264_file_create(const char *pFilePath, AVFormatContext *fc, AVCodecContext *pCodecCtx,AVCodecContext *pAudioCodecCtx, double fps, void *p, int len ); 20 | extern void h264_file_write_frame(AVFormatContext *fc, int vStreamId, const void* p, int len, int64_t dts, int64_t pts); 21 | extern void h264_file_write_audio_frame(AVFormatContext *fc, AVCodecContext *pAudioCodecContext,int vStreamIdx, const void* p, int len, int64_t dts, int64_t pts ); 22 | extern void h264_file_close(AVFormatContext *fc); 23 | 24 | extern void h264_file_write_frame2(AVFormatContext *fc, int vStreamIdx, AVPacket *pkt ); 25 | 26 | extern int MoveMP4MoovToHeader(char *pSrc, char *pDst); 27 | 28 | typedef enum 29 | { 30 | eH264RecIdle = 0, 31 | eH264RecInit, 32 | eH264RecActive, 33 | eH264RecClose 34 | } eH264RecordState; 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Classes/Utilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // Utilities.h 3 | // iFrameExtractor 4 | // 5 | // Created by lajos on 1/10/10. 6 | // 7 | // Copyright 2010 Lajos Kamocsay 8 | // 9 | // lajos at codza dot com 10 | // 11 | // iFrameExtractor is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU Lesser General Public 13 | // License as published by the Free Software Foundation; either 14 | // version 2.1 of the License, or (at your option) any later version. 15 | // 16 | // iFrameExtractor is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Lesser General Public License for more details. 20 | // 21 | 22 | #import 23 | #include 24 | 25 | @interface Utilities : NSObject { 26 | 27 | } 28 | 29 | +(NSString *)bundlePath:(NSString *)fileName; 30 | +(NSString *)documentsPath:(NSString *)fileName; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Classes/Utilities.m: -------------------------------------------------------------------------------- 1 | // 2 | // Utilities.m 3 | // iFrameExtractor 4 | // 5 | // Created by lajos on 1/10/10. 6 | // 7 | // Copyright 2010 Lajos Kamocsay 8 | // 9 | // lajos at codza dot com 10 | // 11 | // iFrameExtractor is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU Lesser General Public 13 | // License as published by the Free Software Foundation; either 14 | // version 2.1 of the License, or (at your option) any later version. 15 | // 16 | // iFrameExtractor is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Lesser General Public License for more details. 20 | // 21 | 22 | #import "Utilities.h" 23 | 24 | 25 | @implementation Utilities 26 | 27 | +(NSString *)bundlePath:(NSString *)fileName { 28 | return [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:fileName]; 29 | } 30 | 31 | +(NSString *)documentsPath:(NSString *)fileName { 32 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 33 | NSString *documentsDirectory = [paths objectAtIndex:0]; 34 | return [documentsDirectory stringByAppendingPathComponent:fileName]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Classes/VideoFrameExtractor.h: -------------------------------------------------------------------------------- 1 | // 2 | // Video.h 3 | // iFrameExtractor 4 | // 5 | // Created by lajos on 1/10/10. 6 | // 7 | // Copyright 2010 Lajos Kamocsay 8 | // 9 | // lajos at codza dot com 10 | // 11 | // iFrameExtractor is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU Lesser General Public 13 | // License as published by the Free Software Foundation; either 14 | // version 2.1 of the License, or (at your option) any later version. 15 | // 16 | // iFrameExtractor is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Lesser General Public License for more details. 20 | // 21 | 22 | 23 | #import 24 | 25 | #include "libavformat/avformat.h" 26 | #include "libswscale/swscale.h" 27 | 28 | #include "H264_Save.h" 29 | 30 | #import "AudioPlayer.h" 31 | #import "AudioPacketQueue.h" 32 | #import "AudioUtilities.h" 33 | 34 | #define RECORDING_AT_RTSP_START 0 35 | //#define RECORDING_AT_RTSP_START 1 36 | #define RECPRDING_SECONDS 5 37 | 38 | @interface VideoFrameExtractor : NSObject { 39 | AVFormatContext *pFormatCtx; 40 | AVCodecContext *pCodecCtx; 41 | 42 | AVFrame *pYUVFrame; 43 | AVFrame *pRGBFrame; 44 | AVPacket packet; 45 | int videoStream; 46 | int audioStream; 47 | struct SwsContext *pImgConvertCtx; 48 | int sourceWidth, sourceHeight; 49 | int outputWidth, outputHeight; 50 | UIImage *currentImage; 51 | double duration; 52 | double currentTime; 53 | 54 | AVFormatContext *pFormatCtx_Record; 55 | AVCodecContext *pAudioCodecCtx; 56 | 57 | AudioPlayer *aPlayer; 58 | } 59 | 60 | /* Last decoded picture as UIImage */ 61 | @property (nonatomic, readonly) UIImage *currentImage; 62 | 63 | /* Size of video frame */ 64 | @property (nonatomic, readonly) int sourceWidth, sourceHeight; 65 | 66 | /* Output image size. Set to the source size by default. */ 67 | @property (nonatomic) int outputWidth, outputHeight; 68 | 69 | /* Length of video in seconds */ 70 | @property (nonatomic, readonly) double duration; 71 | 72 | /* Current time of video in seconds */ 73 | @property (nonatomic, readonly) double currentTime; 74 | 75 | /* Initialize with movie at moviePath. Output dimensions are set to source dimensions. */ 76 | -(id)initWithVideo:(NSString *)moviePath; 77 | 78 | /* Read the next frame from the video stream. Returns false if no frame read (video over). */ 79 | -(BOOL)stepFrame; 80 | 81 | /* Seek to closest keyframe near specified time */ 82 | -(void)seekTime:(double)seconds; 83 | 84 | @property (nonatomic) BOOL bSnapShot; 85 | @property (nonatomic) int veVideoRecordState; 86 | @property (nonatomic, retain) NSTimer *RecordingTimer; 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Classes/VideoFrameExtractor.m: -------------------------------------------------------------------------------- 1 | // 2 | // Video.m 3 | // iFrameExtractor 4 | // 5 | // Created by lajos on 1/10/10. 6 | // Copyright 2010 www.codza.com. All rights reserved. 7 | // 8 | 9 | #import "VideoFrameExtractor.h" 10 | #import "Utilities.h" 11 | #import 12 | 13 | @interface VideoFrameExtractor (private) 14 | -(void)convertFrameToRGB; 15 | -(UIImage *)imageFromAVFrame:(AVFrame *)pFrame width:(int)width height:(int)height; 16 | -(void)saveFrame:(AVFrame *)pFrame width:(int)width height:(int)height index:(int)iFrame; 17 | -(void)setupScaler; 18 | @end 19 | 20 | @implementation VideoFrameExtractor 21 | 22 | #define RECORDING_AT_RTSP_START 0 23 | //#define RECORDING_AT_RTSP_START 1 24 | 25 | @synthesize outputWidth, outputHeight; 26 | 27 | @synthesize bSnapShot, veVideoRecordState, RecordingTimer; 28 | 29 | 30 | - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo 31 | { 32 | NSLog(@"Snapshot save may fail..."); 33 | } 34 | 35 | -(void)setOutputWidth:(int)newValue { 36 | if (outputWidth == newValue) return; 37 | outputWidth = newValue; 38 | [self setupScaler]; 39 | } 40 | 41 | -(void)setOutputHeight:(int)newValue { 42 | if (outputHeight == newValue) return; 43 | outputHeight = newValue; 44 | [self setupScaler]; 45 | } 46 | 47 | 48 | -(UIImage *)currentImage { 49 | if (!pYUVFrame->data[0]) return nil; 50 | [self convertFrameToRGB]; 51 | 52 | // Save the image and clear the bSnapShot flag 53 | if(self.bSnapShot==YES) 54 | { 55 | UIImage *myimg=nil; 56 | 57 | struct SwsContext *pTempImgConvertCtx; 58 | 59 | AVFrame *pTmpAVFrame = av_frame_alloc(); 60 | av_frame_unref(pTmpAVFrame); 61 | 62 | int bytes_num = av_image_get_buffer_size(AV_PIX_FMT_RGB24, pYUVFrame->width, pYUVFrame->height, 1); 63 | uint8_t* buff = (uint8_t*)av_malloc(bytes_num); 64 | av_image_fill_arrays((unsigned char **)(AVFrame *)pTmpAVFrame->data, pTmpAVFrame->linesize, buff, AV_PIX_FMT_RGB24, pYUVFrame->width, pYUVFrame->height, 1); 65 | pTmpAVFrame->width = outputWidth; 66 | pTmpAVFrame->height = outputHeight; 67 | pTmpAVFrame->format = AV_PIX_FMT_RGB24; 68 | 69 | pTempImgConvertCtx = sws_getContext(pCodecCtx->width, 70 | pCodecCtx->height, 71 | pCodecCtx->pix_fmt, 72 | pYUVFrame->width, 73 | pYUVFrame->height, 74 | AV_PIX_FMT_RGB24, 75 | SWS_FAST_BILINEAR, 76 | NULL, 77 | NULL, 78 | NULL); 79 | 80 | sws_scale (pTempImgConvertCtx, (const uint8_t **)pYUVFrame->data, pYUVFrame->linesize, 81 | 0, pCodecCtx->height, 82 | pTmpAVFrame->data, pTmpAVFrame->linesize); 83 | 84 | myimg = [self imageFromAVFrame:pTmpAVFrame width:pYUVFrame->width height:pYUVFrame->height]; 85 | 86 | 87 | UIImageWriteToSavedPhotosAlbum(myimg, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 88 | self.bSnapShot = NO; 89 | 90 | return myimg; 91 | 92 | } 93 | 94 | return [self imageFromAVFrame:pRGBFrame width:outputWidth height:outputHeight]; 95 | } 96 | 97 | -(double)duration { 98 | return (double)pFormatCtx->duration / AV_TIME_BASE; 99 | } 100 | 101 | -(double)currentTime { 102 | AVRational timeBase = pFormatCtx->streams[videoStream]->time_base; 103 | return packet.pts * (double)timeBase.num / timeBase.den; 104 | } 105 | 106 | -(int)sourceWidth { 107 | return pCodecCtx->width; 108 | } 109 | 110 | -(int)sourceHeight { 111 | return pCodecCtx->height; 112 | } 113 | 114 | -(id)initWithVideo:(NSString *)moviePath { 115 | if (!(self=[super init])) return nil; 116 | 117 | AVCodec *pCodec, *pAudioCodec; 118 | 119 | // Register all formats and codecs 120 | avcodec_register_all(); 121 | av_register_all(); 122 | 123 | avformat_network_init(); 124 | 125 | // Open video file 126 | AVDictionary *opts = 0; 127 | av_dict_set(&opts, "rtsp_transport", "tcp", 0); 128 | 129 | if(avformat_open_input(&pFormatCtx, [moviePath cStringUsingEncoding:NSASCIIStringEncoding], NULL, &opts) != 0) { 130 | av_log(NULL, AV_LOG_ERROR, "Couldn't open file\n"); 131 | goto initError; 132 | } 133 | av_dict_free(&opts); 134 | 135 | // Retrieve stream information 136 | if(avformat_find_stream_info(pFormatCtx,NULL) < 0) { 137 | av_log(NULL, AV_LOG_ERROR, "Couldn't find stream information\n"); 138 | goto initError; 139 | } 140 | 141 | // Find the first video stream 142 | if ((videoStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &pCodec, 0)) < 0) { 143 | av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n"); 144 | goto initError; 145 | } 146 | 147 | // Get a pointer to the codec context for the video stream 148 | pCodecCtx = avcodec_alloc_context3(NULL); 149 | avcodec_parameters_to_context(pCodecCtx, pFormatCtx->streams[videoStream]->codecpar); 150 | 151 | // Find the decoder for the video stream 152 | pCodec = avcodec_find_decoder(pCodecCtx->codec_id); 153 | if(pCodec == NULL) { 154 | av_log(NULL, AV_LOG_ERROR, "Unsupported codec!\n"); 155 | goto initError; 156 | } 157 | 158 | // Open codec 159 | if(avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { 160 | av_log(NULL, AV_LOG_ERROR, "Cannot open video decoder\n"); 161 | goto initError; 162 | } 163 | 164 | if ((audioStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, &pAudioCodec, 0)) < 0) { 165 | av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n"); 166 | } 167 | else 168 | { 169 | pAudioCodecCtx = avcodec_alloc_context3(NULL); 170 | avcodec_parameters_to_context(pAudioCodecCtx, pFormatCtx->streams[audioStream]->codecpar); 171 | 172 | // Find the decoder for the audio stream 173 | pAudioCodec = avcodec_find_decoder(pAudioCodecCtx->codec_id); 174 | if(pAudioCodec == NULL) { 175 | av_log(NULL, AV_LOG_ERROR, "Unsupported codec!\n"); 176 | goto initError; 177 | } 178 | 179 | // Open codec 180 | if(avcodec_open2(pAudioCodecCtx, pAudioCodec, NULL) < 0) { 181 | av_log(NULL, AV_LOG_ERROR, "Cannot open audio decoder\n"); 182 | goto initError; 183 | } 184 | 185 | } 186 | 187 | av_dump_format(pFormatCtx, 0, [moviePath cStringUsingEncoding:NSASCIIStringEncoding], 0); 188 | 189 | outputWidth = pCodecCtx->width; 190 | outputHeight = pCodecCtx->height; 191 | 192 | // Allocate video frame 193 | pYUVFrame = av_frame_alloc(); 194 | int bytes_num = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, outputWidth, outputHeight, 1); 195 | uint8_t* buff = (uint8_t*)av_malloc(bytes_num); 196 | av_image_fill_arrays((unsigned char **)(AVFrame *)pYUVFrame->data, pYUVFrame->linesize, buff, AV_PIX_FMT_YUV420P, outputWidth, outputHeight, 1); 197 | pYUVFrame->width = outputWidth; 198 | pYUVFrame->height = outputHeight; 199 | pYUVFrame->format = AV_PIX_FMT_YUV420P; 200 | 201 | return self; 202 | 203 | initError: 204 | [self release]; 205 | return nil; 206 | } 207 | 208 | 209 | -(void)setupScaler { 210 | 211 | // Release old RGB frame and scaler 212 | av_free(pRGBFrame); 213 | sws_freeContext(pImgConvertCtx); 214 | 215 | // Allocate RGB frame 216 | pRGBFrame = av_frame_alloc(); 217 | av_frame_unref(pRGBFrame); 218 | 219 | int bytes_num = av_image_get_buffer_size(AV_PIX_FMT_RGB24, pYUVFrame->width, pYUVFrame->height, 1); 220 | uint8_t* buff = (uint8_t*)av_malloc(bytes_num); 221 | av_image_fill_arrays((unsigned char **)(AVFrame *)pRGBFrame->data, pRGBFrame->linesize, buff, AV_PIX_FMT_RGB24, pYUVFrame->width, pYUVFrame->height, 1); 222 | pRGBFrame->width = outputWidth; 223 | pRGBFrame->height = outputHeight; 224 | pRGBFrame->format = AV_PIX_FMT_RGB24; 225 | 226 | // Setup scaler 227 | static int sws_flags = SWS_FAST_BILINEAR; 228 | pImgConvertCtx = sws_getContext(pCodecCtx->width, 229 | pCodecCtx->height, 230 | pCodecCtx->pix_fmt, 231 | outputWidth, 232 | outputHeight, 233 | AV_PIX_FMT_RGB24, 234 | sws_flags, NULL, NULL, NULL); 235 | 236 | } 237 | 238 | -(void)seekTime:(double)seconds { 239 | AVRational timeBase = pFormatCtx->streams[videoStream]->time_base; 240 | int64_t targetFrame = (int64_t)((double)timeBase.den / timeBase.num * seconds); 241 | avformat_seek_file(pFormatCtx, videoStream, targetFrame, targetFrame, targetFrame, AVSEEK_FLAG_FRAME); 242 | avcodec_flush_buffers(pCodecCtx); 243 | } 244 | 245 | -(void)dealloc { 246 | 247 | [aPlayer Stop:TRUE]; 248 | 249 | // Free scaler 250 | sws_freeContext(pImgConvertCtx); 251 | 252 | // Free RGB frame 253 | av_free(pRGBFrame); 254 | 255 | // Free the packet that was allocated by av_read_frame 256 | av_packet_unref(&packet); 257 | 258 | // Free the YUV frame 259 | av_free(pYUVFrame); 260 | 261 | // Close the codec 262 | if (pCodecCtx) avcodec_close(pCodecCtx); 263 | 264 | // Close the video file 265 | if (pFormatCtx) avformat_close_input(&pFormatCtx); 266 | 267 | [super dealloc]; 268 | } 269 | 270 | -(void)StopRecording:(NSTimer *)timer { 271 | veVideoRecordState = eH264RecClose; 272 | NSLog(@"eH264RecClose"); 273 | [timer invalidate]; 274 | } 275 | 276 | -(BOOL)stepFrame { 277 | int frameFinished=0; 278 | static bool bFirstIFrame=false; 279 | static int64_t vPTS=0, vDTS=0, vAudioPTS=0, vAudioDTS=0; 280 | 281 | while(!frameFinished && av_read_frame(pFormatCtx, &packet)>=0) { 282 | // Is this a packet from the video stream? 283 | int vRet = 0; 284 | if(packet.stream_index==videoStream) { 285 | 286 | 287 | // Initialize a new format context for writing file 288 | if(veVideoRecordState!=eH264RecIdle) 289 | { 290 | switch(veVideoRecordState) 291 | { 292 | case eH264RecInit: 293 | { 294 | if ( !pFormatCtx_Record ) 295 | { 296 | int bFlag = 0; 297 | //NSString *videoPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.mp4"]; 298 | NSString *videoPath = @"/Users/liaokuohsun/iFrameTest.mp4"; 299 | 300 | const char *file = [videoPath UTF8String]; 301 | //pFormatCtx_Record = avformat_alloc_context(); 302 | avformat_alloc_output_context2(&pFormatCtx_Record, NULL, NULL, file); 303 | bFlag = h264_file_create(file, pFormatCtx_Record, pCodecCtx, pAudioCodecCtx,/*fps*/0.0, packet.data, packet.size ); 304 | 305 | if(bFlag==true) 306 | { 307 | veVideoRecordState = eH264RecActive; 308 | fprintf(stderr, "h264_file_create success\n"); 309 | } 310 | else 311 | { 312 | veVideoRecordState = eH264RecIdle; 313 | fprintf(stderr, "h264_file_create error\n"); 314 | } 315 | } 316 | } 317 | //break; 318 | 319 | case eH264RecActive: 320 | { 321 | if((bFirstIFrame==false) &&(packet.flags&AV_PKT_FLAG_KEY)==AV_PKT_FLAG_KEY) 322 | { 323 | bFirstIFrame=true; 324 | vPTS = packet.pts ; 325 | vDTS = packet.dts ; 326 | #if 0 327 | NSRunLoop *pRunLoop = [NSRunLoop currentRunLoop]; 328 | [pRunLoop addTimer:RecordingTimer forMode:NSDefaultRunLoopMode]; 329 | #else 330 | [NSTimer scheduledTimerWithTimeInterval:5.0//2.0 331 | target:self 332 | selector:@selector(StopRecording:) 333 | userInfo:nil 334 | repeats:NO]; 335 | #endif 336 | } 337 | 338 | // Record audio when 1st i-Frame is obtained 339 | if(bFirstIFrame==true) 340 | { 341 | if ( pFormatCtx_Record ) 342 | { 343 | #if PTS_DTS_IS_CORRECT==1 344 | packet.pts = packet.pts - vPTS; 345 | packet.dts = packet.dts - vDTS; 346 | 347 | #endif 348 | // h264_file_write_frame2( pFormatCtx_Record, packet.stream_index, &packet); 349 | h264_file_write_frame( pFormatCtx_Record, packet.stream_index, packet.data, packet.size, packet.dts, packet.pts); 350 | 351 | } 352 | else 353 | { 354 | NSLog(@"pFormatCtx_Record no exist"); 355 | } 356 | } 357 | } 358 | break; 359 | 360 | case eH264RecClose: 361 | { 362 | bFirstIFrame = false; 363 | veVideoRecordState = eH264RecIdle; 364 | 365 | if ( pFormatCtx_Record ) 366 | { 367 | h264_file_close(pFormatCtx_Record); 368 | #if 0 369 | // 20130607 Test, TODO: remove me 370 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) 371 | { 372 | ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init]; 373 | NSString *filePathString = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.mp4"]; 374 | NSURL *filePathURL = [NSURL fileURLWithPath:filePathString isDirectory:NO]; 375 | if(1)// ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:filePathURL]) 376 | { 377 | [library writeVideoAtPathToSavedPhotosAlbum:filePathURL completionBlock:^(NSURL *assetURL, NSError *error){ 378 | if (error) { 379 | // TODO: error handling 380 | NSLog(@"writeVideoAtPathToSavedPhotosAlbum error"); 381 | } else { 382 | // TODO: success handling 383 | NSLog(@"writeVideoAtPathToSavedPhotosAlbum success"); 384 | } 385 | }]; 386 | } 387 | [library release]; 388 | }); 389 | #endif 390 | vPTS = 0; 391 | vDTS = 0; 392 | vAudioPTS = 0; 393 | vAudioDTS = 0; 394 | pFormatCtx_Record = NULL; 395 | NSLog(@"h264_file_close() is finished"); 396 | } 397 | else 398 | { 399 | NSLog(@"fc no exist"); 400 | } 401 | } 402 | break; 403 | 404 | default: 405 | if ( pFormatCtx_Record ) 406 | { 407 | h264_file_close(pFormatCtx_Record); 408 | pFormatCtx_Record = NULL; 409 | } 410 | NSLog(@"[ERROR] unexpected veVideoRecordState!!"); 411 | veVideoRecordState = eH264RecIdle; 412 | break; 413 | } 414 | } 415 | 416 | // Decode video frame 417 | avcodec_send_packet(pCodecCtx, &packet); 418 | do { 419 | vRet = avcodec_receive_frame(pCodecCtx, pYUVFrame); 420 | } while(vRet==EAGAIN); 421 | 422 | if(vRet==0) frameFinished=1; 423 | else frameFinished=0; 424 | 425 | } 426 | else if(packet.stream_index==audioStream) 427 | { 428 | static int vPktCount=0; 429 | BOOL bIsAACADTS = FALSE; 430 | 431 | if(aPlayer.vAACType == eAAC_UNDEFINED) 432 | { 433 | tAACADTSHeaderInfo vxAACADTSHeaderInfo = {0}; 434 | bIsAACADTS = [AudioUtilities parseAACADTSHeader:(uint8_t *)packet.data ToHeader:&vxAACADTSHeaderInfo]; 435 | } 436 | 437 | @synchronized(aPlayer) 438 | { 439 | if(aPlayer==nil) 440 | { 441 | aPlayer = [[AudioPlayer alloc]initAudio:nil withCodecCtx:(AVCodecContext *) pAudioCodecCtx]; 442 | NSLog(@"aPlayer initAudio"); 443 | 444 | if(bIsAACADTS) 445 | { 446 | aPlayer.vAACType = eAAC_ADTS; 447 | NSLog(@"is ADTS AAC"); 448 | } 449 | } 450 | else 451 | { 452 | if(vPktCount<5) // The voice is listened once image is rendered 453 | { 454 | vPktCount++; 455 | } 456 | else 457 | { 458 | if([aPlayer getStatus]!=eAudioRunning) 459 | { 460 | NSLog(@"aPlayer start play"); 461 | [aPlayer Play]; 462 | } 463 | } 464 | } 465 | }; 466 | 467 | @synchronized(aPlayer) 468 | { 469 | int ret = 0; 470 | 471 | // AVPacket vxPacket = {0}; 472 | // uint8_t *pTmp = (uint8_t *) malloc(frameDataLength); 473 | // memcpy(pTmp, frameData, frameDataLength); 474 | // vxPacket.data = (uint8_t *)pTmp; 475 | // vxPacket.size = frameDataLength; 476 | // ret = [aPlayer putAVPacket:&vxPacket]; 477 | 478 | ret = [aPlayer putAVPacket:&packet]; 479 | if(ret <= 0) 480 | NSLog(@"Put Audio Packet Error!!"); 481 | 482 | } 483 | 484 | if(bFirstIFrame==true) 485 | { 486 | switch(veVideoRecordState) 487 | { 488 | case eH264RecActive: 489 | { 490 | if ( pFormatCtx_Record ) 491 | { 492 | h264_file_write_audio_frame(pFormatCtx_Record, pAudioCodecCtx, packet.stream_index, packet.data, packet.size, packet.dts, packet.pts); 493 | 494 | } 495 | else 496 | { 497 | NSLog(@"pFormatCtx_Record no exist"); 498 | } 499 | } 500 | } 501 | } 502 | } 503 | else 504 | { 505 | //fprintf(stderr, "packet len=%d, Byte=%02X%02X%02X%02X%02X\n",\ 506 | packet.size, packet.data[0],packet.data[1],packet.data[2],packet.data[3], packet.data[4]); 507 | } 508 | } 509 | return frameFinished!=0; 510 | } 511 | 512 | -(void)convertFrameToRGB { 513 | sws_scale (pImgConvertCtx, (const uint8_t **)pYUVFrame->data, pYUVFrame->linesize, 514 | 0, pCodecCtx->height, 515 | pRGBFrame->data, pRGBFrame->linesize); 516 | } 517 | 518 | -(UIImage *)imageFromAVFrame:(AVFrame *)frame width:(int)width height:(int)height { 519 | CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; 520 | CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, frame->data[0], frame->linesize[0]*height,kCFAllocatorNull); 521 | CGDataProviderRef provider = CGDataProviderCreateWithCFData(data); 522 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 523 | CGImageRef cgImage = CGImageCreate(width, 524 | height, 525 | 8, 526 | 24, 527 | frame->linesize[0], 528 | colorSpace, 529 | bitmapInfo, 530 | provider, 531 | NULL, 532 | NO, 533 | kCGRenderingIntentDefault); 534 | CGColorSpaceRelease(colorSpace); 535 | UIImage *image = [UIImage imageWithCGImage:cgImage]; 536 | CGImageRelease(cgImage); 537 | CGDataProviderRelease(provider); 538 | CFRelease(data); 539 | 540 | return image; 541 | } 542 | 543 | -(void)savePPMPicture:(AVFrame *)frame width:(int)width height:(int)height index:(int)iFrame { 544 | FILE *pFile; 545 | NSString *fileName; 546 | int y; 547 | 548 | fileName = [Utilities documentsPath:[NSString stringWithFormat:@"image%04d.ppm",iFrame]]; 549 | // Open file 550 | NSLog(@"write image file: %@",fileName); 551 | pFile=fopen([fileName cStringUsingEncoding:NSASCIIStringEncoding], "wb"); 552 | if(pFile==NULL) 553 | return; 554 | 555 | // Write header 556 | fprintf(pFile, "P6\n%d %d\n255\n", width, height); 557 | 558 | // Write pixel data 559 | for(y=0; ydata[0]+y*frame->linesize[0], 1, width*3, pFile); 561 | 562 | // Close file 563 | fclose(pFile); 564 | } 565 | 566 | @end 567 | -------------------------------------------------------------------------------- /Classes/iFrameExtractorViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // iFrameExtractorViewController.h 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 2016/11/24. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @class VideoFrameExtractor; 12 | 13 | #define RECORDING_AT_RTSP_START 0 14 | //#define RECORDING_AT_RTSP_START 1 15 | #define RECPRDING_SECONDS 5 16 | 17 | @interface iFrameExtractorViewController : UIViewController { 18 | //VideoFrameExtractor *video; 19 | float lastFrameTime; 20 | } 21 | @property (nonatomic, retain) IBOutlet UIImageView *imageView; 22 | @property (nonatomic, retain) IBOutlet UILabel *label; 23 | @property (nonatomic, retain) IBOutlet UIButton *playButton; 24 | @property (nonatomic, retain) VideoFrameExtractor *video; 25 | @property (retain, nonatomic) IBOutlet UIButton *RecordButton; 26 | @property (retain, nonatomic) IBOutlet UIButton *SnapShotButton; 27 | @property (retain, nonatomic) IBOutlet UILabel *RecordProgressLevel; 28 | @property (nonatomic) int vRecordSeconds; 29 | 30 | 31 | -(IBAction)playButtonAction:(id)sender; 32 | - (IBAction)SnapShotButtonAction:(id)sender; 33 | - (IBAction)RecordButtionAction:(id)sender; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/iFrameExtractorViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // iFrameExtractorViewController.m 3 | // iFrameExtractor 4 | // 5 | // Created by Liao KuoHsun on 2016/11/24. 6 | // 7 | // 8 | 9 | #import "iFrameExtractorViewController.h" 10 | 11 | #import "VideoFrameExtractor.h" 12 | #import "Utilities.h" 13 | #include "H264_Save.h" 14 | 15 | @interface iFrameExtractorViewController () 16 | 17 | @end 18 | 19 | @implementation iFrameExtractorViewController 20 | @synthesize imageView, label, playButton, video, RecordProgressLevel, vRecordSeconds; 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view. 25 | 26 | // Test URL 27 | // rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov 28 | // http://210.65.250.18:8080/cam000b67014ff5001/20131023/090000.mp4 29 | 30 | // Test File 31 | // 7h800-2.mp4 32 | // h265_ex3.mp4 33 | 34 | 35 | NSLog(@"Try Connect: %f",video.duration); 36 | //video = [[VideoFrameExtractor alloc] initWithVideo:[Utilities bundlePath:@"7h800-2.mp4"]]; 37 | video = [[VideoFrameExtractor alloc] initWithVideo:[Utilities bundlePath:@"h265_ex3.mp4"]]; 38 | //video = [[VideoFrameExtractor alloc] initWithVideo:@"rtsp://192.168.11.2:8554/h265ESVideoTest"]; 39 | //video = [[VideoFrameExtractor alloc] initWithVideo:@"rtsp://172.19.19.146/stream1"]; 40 | 41 | // set output image size 42 | video.outputWidth = 1280-120; // reserver 120 pixel for control button 43 | video.outputHeight = 720; 44 | 45 | // print some info about the video 46 | NSLog(@"video duration: %f",video.duration); 47 | NSLog(@"video size: %d x %d", video.sourceWidth, video.sourceHeight); 48 | 49 | // set the initial value to progress level 50 | [RecordProgressLevel setHidden:YES]; 51 | 52 | // If video images are landscape, so rotate image view 90 degrees 53 | //[imageView setTransform:CGAffineTransformMakeRotation(M_PI/2)]; 54 | 55 | } 56 | 57 | - (void)didReceiveMemoryWarning { 58 | [super didReceiveMemoryWarning]; 59 | // Dispose of any resources that can be recreated. 60 | } 61 | 62 | 63 | #if RECORDING_AT_RTSP_START==1 64 | -(void)StopRecording:(NSTimer *)timer { 65 | video.veVideoRecordState = eH264RecClose; 66 | NSLog(@"eH264RecClose"); 67 | [timer invalidate]; 68 | } 69 | #endif 70 | 71 | -(IBAction)playButtonAction:(id)sender { 72 | [playButton setEnabled:NO]; 73 | lastFrameTime = -1; 74 | 75 | // seek to 0.0 seconds 76 | [video seekTime:0.0]; 77 | 78 | 79 | #if RECORDING_AT_RTSP_START==1 80 | video.veVideoRecordState = eH264RecInit; 81 | [NSTimer scheduledTimerWithTimeInterval:10.0 82 | target:self 83 | selector:@selector(StopRecording:) 84 | userInfo:nil 85 | repeats:NO]; 86 | #endif 87 | 88 | [NSTimer scheduledTimerWithTimeInterval:1.0/30 89 | target:self 90 | selector:@selector(displayNextFrame:) 91 | userInfo:nil 92 | repeats:YES]; 93 | } 94 | 95 | 96 | - (IBAction)SnapShotButtonAction:(id)sender { 97 | video.bSnapShot = YES; 98 | } 99 | 100 | 101 | #define LERP(A,B,C) ((A)*(1.0-C)+(B)*C) 102 | 103 | -(void)displayNextFrame:(NSTimer *)timer { 104 | NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate]; 105 | if (![video stepFrame]) { 106 | [timer invalidate]; 107 | [playButton setEnabled:YES]; 108 | return; 109 | } 110 | imageView.image = video.currentImage; 111 | float frameTime = 1.0/([NSDate timeIntervalSinceReferenceDate]-startTime); 112 | if (lastFrameTime<0) { 113 | lastFrameTime = frameTime; 114 | } else { 115 | lastFrameTime = LERP(frameTime, lastFrameTime, 0.8); 116 | } 117 | [label setText:[NSString stringWithFormat:@"%.0f",lastFrameTime]]; 118 | } 119 | 120 | 121 | #pragma mark - ffmpeg usage 122 | -(void)UpdateProgressLevel:(NSTimer *)timer { 123 | NSLog(@"RecordProgress:%d", vRecordSeconds); 124 | 125 | if(vRecordSeconds==0) 126 | { 127 | video.veVideoRecordState = eH264RecClose; 128 | [RecordProgressLevel setHidden:YES]; 129 | [timer invalidate]; 130 | } 131 | else 132 | { 133 | vRecordSeconds--; 134 | } 135 | NSString *vpTmp = [NSString stringWithFormat:@"Recording 00:%02d", vRecordSeconds]; 136 | [RecordProgressLevel setText:vpTmp]; 137 | 138 | } 139 | 140 | - (IBAction)RecordButtionAction:(id)sender { 141 | video.veVideoRecordState = eH264RecInit; 142 | 143 | // Update the recording progress 144 | vRecordSeconds = RECPRDING_SECONDS; 145 | NSString *vpTmp = [NSString stringWithFormat:@"Recording 00:%02d", vRecordSeconds]; 146 | [RecordProgressLevel setText:vpTmp]; 147 | 148 | [RecordProgressLevel setHidden:NO]; 149 | 150 | [NSTimer scheduledTimerWithTimeInterval:1.0 151 | target:self 152 | selector:@selector(UpdateProgressLevel:) 153 | userInfo:nil 154 | repeats:YES]; 155 | } 156 | 157 | - (void)dealloc { 158 | [super dealloc]; 159 | } 160 | @end 161 | -------------------------------------------------------------------------------- /Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alb423/iFrameExtractor/c64609dd34c2064e8e2680c1f2441aeed628c500/Default-568h@2x.png -------------------------------------------------------------------------------- /Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alb423/iFrameExtractor/c64609dd34c2064e8e2680c1f2441aeed628c500/Default.png -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | **original copyright** 2 | >This project extracts frames from video recorded by iPhone 3Gs 3 | using the LGPL FFmpeg libraries. 4 | 5 | >This software is licensed under the GNU-LGPL version 2.1 or later. 6 | 7 | >Copyright 2010 Lajos Kamocsay 8 | 9 | >lajos at codza dot com 10 | 11 | ## Introduction ## 12 | 13 | This project is forked from . 14 | I update the code for the latest ffmpeg and iOS version. The source code is tested on `Mac OS 10.7.4(Lion)` for `ffmpeg 0.11.1` and `iOS 5.1` with `Xcode 4.3.2`. 15 | 16 | ## Build steps ## 17 | 18 | - Download the code using 19 | 20 | `git clone git://github.com/PinkyJie/iFrameExtractor.git` 21 | 22 | - Download the latest ffmpeg (0.11.1 tested) using 23 | 24 | `git clone git://source.ffmpeg.org/ffmpeg.git` 25 | 26 | - Put the ffmpeg source code into the folder `ffmpeg` 27 | 28 | - Copy the perl script `gas-preprocessor.pl` into `/usr/local/bin` folder 29 | 30 | - Change directory to your `ffmpeg` folder, select your target platform and follow the scripts below 31 | 32 | ### Platforms ### 33 | 34 | - `armv7` (for iPhone 3GS and devices after 3GS) 35 | 36 | ##### configure ##### 37 | 38 | >./configure \ 39 | 40 | >--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ 41 | 42 | >--as='/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ 43 | 44 | >--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk \ 45 | 46 | >--target-os=darwin \ 47 | 48 | >--arch=arm \ 49 | 50 | >--cpu=cortex-a8 \ 51 | 52 | >--extra-cflags='-arch armv7' \ 53 | 54 | >--extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk' \ 55 | 56 | >--prefix=compiled/armv7 \ 57 | 58 | >--enable-cross-compile \ 59 | 60 | >--enable-nonfree \ 61 | 62 | >--enable-gpl \ 63 | 64 | >--disable-armv5te \ 65 | 66 | >--disable-swscale-alpha \ 67 | 68 | >--disable-doc \ 69 | 70 | >--disable-ffmpeg \ 71 | 72 | >--disable-ffplay \ 73 | 74 | >--disable-ffprobe \ 75 | 76 | >--disable-ffserver \ 77 | 78 | >--disable-asm \ 79 | 80 | >--disable-debug 81 | 82 | ##### make ##### 83 | 84 | >make clean 85 | 86 | >make && make install 87 | 88 | - `armv6` (for devices before 3GS) 89 | 90 | ##### configure ##### 91 | 92 | >./configure \ 93 | 94 | >--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ 95 | 96 | >--as='/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ 97 | 98 | >--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk \ 99 | 100 | >--target-os=darwin \ 101 | 102 | >--arch=arm \ 103 | 104 | >--cpu=arm1176jzf-s \ 105 | 106 | >--extra-cflags='-arch armv6' \ 107 | 108 | >--extra-ldflags='-arch armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk' \ 109 | 110 | >--prefix=compiled/armv6 \ 111 | 112 | >--enable-cross-compile \ 113 | 114 | >--enable-nonfree \ 115 | 116 | >--enable-gpl \ 117 | 118 | >--disable-armv5te \ 119 | 120 | >--disable-swscale-alpha \ 121 | 122 | >--disable-doc \ 123 | 124 | >--disable-ffmpeg \ 125 | 126 | >--disable-ffplay \ 127 | 128 | >--disable-ffprobe \ 129 | 130 | >--disable-ffserver \ 131 | 132 | >--disable-asm \ 133 | 134 | >--disable-debug 135 | 136 | ##### make ##### 137 | 138 | >make clean 139 | 140 | >make && make install 141 | 142 | - `i386` (for simulator) 143 | 144 | ##### configure ##### 145 | 146 | >./configure \ 147 | 148 | >--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \ 149 | 150 | >--as='/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc' \ 151 | 152 | >--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk \ 153 | 154 | >--target-os=darwin \ 155 | 156 | >--arch=i386 \ 157 | 158 | >--cpu=i386 \ 159 | 160 | >--extra-cflags='-arch i386' \ 161 | 162 | >--extra-ldflags='-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk' \ 163 | 164 | >--prefix=compiled/i386 \ 165 | 166 | >--enable-cross-compile \ 167 | 168 | >--enable-nonfree \ 169 | 170 | >--enable-gpl \ 171 | 172 | >--disable-armv5te \ 173 | 174 | >--disable-swscale-alpha \ 175 | 176 | >--disable-doc \ 177 | 178 | >--disable-ffmpeg \ 179 | 180 | >--disable-ffplay \ 181 | 182 | >--disable-ffprobe \ 183 | 184 | >--disable-ffserver \ 185 | 186 | >--disable-asm \ 187 | 188 | >--disable-debug 189 | 190 | ##### make ##### 191 | 192 | >make clean 193 | 194 | >make && make install 195 | 196 | - `universal` (using one *.a files for all platforms) 197 | 198 | >mkdir -p ./compiled/fat/lib 199 | 200 | >lipo -output ./compiled/fat/lib/libavcodec.a -create \ 201 | 202 | >-arch armv6 ./compiled/armv6/lib/libavcodec.a \ 203 | 204 | >-arch armv7 ./compiled/armv7/lib/libavcodec.a \ 205 | 206 | >-arch i386 ./compiled/i386/lib/libavcodec.a 207 | 208 | 209 | >lipo -output ./compiled/fat/lib/libavdevice.a -create \ 210 | 211 | >-arch armv6 ./compiled/armv6/lib/libavdevice.a \ 212 | 213 | >-arch armv7 ./compiled/armv7/lib/libavdevice.a \ 214 | 215 | >-arch i386 ./compiled/i386/lib/libavdevice.a 216 | 217 | >lipo -output ./compiled/fat/lib/libavformat.a -create \ 218 | 219 | >-arch armv6 ./compiled/armv6/lib/libavformat.a \ 220 | 221 | >-arch armv7 ./compiled/armv7/lib/libavformat.a \ 222 | 223 | >-arch i386 ./compiled/i386/lib/libavformat.a 224 | 225 | 226 | >lipo -output ./compiled/fat/lib/libavutil.a -create \ 227 | 228 | >-arch armv6 ./compiled/armv6/lib/libavutil.a \ 229 | 230 | >-arch armv7 ./compiled/armv7/lib/libavutil.a \ 231 | 232 | >-arch i386 ./compiled/i386/lib/libavutil.a 233 | 234 | 235 | >lipo -output ./compiled/fat/lib/libswresample.a -create \ 236 | 237 | >-arch armv6 ./compiled/armv6/lib/libswresample.a \ 238 | 239 | >-arch armv7 ./compiled/armv7/lib/libswresample.a \ 240 | 241 | >-arch i386 ./compiled/i386/lib/libswresample.a 242 | 243 | 244 | >lipo -output ./compiled/fat/lib/libpostproc.a -create \ 245 | 246 | >-arch armv6 ./compiled/armv6/lib/libpostproc.a \ 247 | 248 | >-arch armv7 ./compiled/armv7/lib/libpostproc.a \ 249 | 250 | >-arch i386 ./compiled/i386/lib/libpostproc.a 251 | 252 | 253 | >lipo -output ./compiled/fat/lib/libswscale.a -create \ 254 | 255 | >-arch armv6 ./compiled/armv6/lib/libswscale.a \ 256 | 257 | >-arch armv7 ./compiled/armv7/lib/libswscale.a \ 258 | 259 | >-arch i386 ./compiled/i386/lib/libswscale.a 260 | 261 | 262 | >lipo -output ./compiled/fat/lib/libavfilter.a -create \ 263 | 264 | >-arch armv6 ./compiled/armv6/lib/libavfilter.a \ 265 | 266 | >-arch armv7 ./compiled/armv7/lib/libavfilter.a \ 267 | 268 | >-arch i386 ./compiled/i386/lib/libavfilter.a 269 | 270 | #### The complied static libraries (*.a) lie in the`ffmpeg/compiled` folder. #### -------------------------------------------------------------------------------- /Storyboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 36 | 44 | 51 | 59 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /gas-preprocessor.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # by David Conrad 3 | # This code is licensed under GPLv2 or later; go to gnu.org to read it 4 | # (not that it much matters for an asm preprocessor) 5 | # usage: set your assembler to be something like "perl gas-preprocessor.pl gcc" 6 | use strict; 7 | 8 | # Apple's gas is ancient and doesn't support modern preprocessing features like 9 | # .rept and has ugly macro syntax, among other things. Thus, this script 10 | # implements the subset of the gas preprocessor used by x264 and ffmpeg 11 | # that isn't supported by Apple's gas. 12 | 13 | # FIXME: doesn't work if the path has spaces, but oh well... 14 | my $gcc_cmd = join(' ', @ARGV); 15 | my $preprocess_c_cmd; 16 | 17 | if ($gcc_cmd =~ /\S+\.c/) { 18 | # C file (inline asm?) - compile 19 | $preprocess_c_cmd = "$gcc_cmd -S"; 20 | $gcc_cmd =~ s/\S+\.c/-x assembler -/g; 21 | } elsif ($gcc_cmd =~ /\S+\.S/) { 22 | # asm file, just do C preprocessor 23 | $preprocess_c_cmd = "$gcc_cmd -E"; 24 | $gcc_cmd =~ s/\S+\.S/-x assembler -/g; 25 | } else { 26 | die "Unrecognized input filetype"; 27 | } 28 | 29 | $preprocess_c_cmd =~ s/\S+\.o/-/g; 30 | 31 | open(ASMFILE, "-|", $preprocess_c_cmd) || die "Error running preprocessor"; 32 | 33 | my $current_macro = ''; 34 | my %macro_lines; 35 | my %macro_args; 36 | my %macro_args_default; 37 | 38 | my @pass1_lines; 39 | 40 | # pass 1: parse .macro 41 | # note that the handling of arguments is probably overly permissive vs. gas 42 | # but it should be the same for valid cases 43 | while () { 44 | # comment out unsupported directives 45 | s/\.type/@.type/x; 46 | s/\.func/@.func/x; 47 | s/\.endfunc/@.endfunc/x; 48 | s/\.ltorg/@.ltorg/x; 49 | s/\.size/@.size/x; 50 | s/\.fpu/@.fpu/x; 51 | 52 | # the syntax for these is a little different 53 | s/\.global/.globl/x; 54 | # also catch .section .rodata since the equivalent to .const_data is .section __DATA,__const 55 | s/(.*)\.rodata/.const_data/x; 56 | s/\.int/.long/x; 57 | s/\.float/.single/x; 58 | 59 | # catch unknown section names that aren't mach-o style (with a comma) 60 | if (/.section ([^,]*)$/) { 61 | die ".section $1 unsupported; figure out the mach-o section name and add it"; 62 | } 63 | 64 | # macros creating macros is not handled (is that valid?) 65 | if (/\.macro\s+([\d\w\.]+)\s*(.*)/) { 66 | $current_macro = $1; 67 | 68 | # commas in the argument list are optional, so only use whitespace as the separator 69 | my $arglist = $2; 70 | $arglist =~ s/,/ /g; 71 | 72 | my @args = split(/\s+/, $arglist); 73 | foreach my $i (0 .. $#args) { 74 | my @argpair = split(/=/, $args[$i]); 75 | $macro_args{$current_macro}[$i] = $argpair[0]; 76 | $argpair[0] =~ s/:vararg$//; 77 | $macro_args_default{$current_macro}{$argpair[0]} = $argpair[1]; 78 | } 79 | # ensure %macro_lines has the macro name added as a key 80 | $macro_lines{$current_macro} = []; 81 | } elsif (/\.endm/) { 82 | if (!$current_macro) { 83 | die "ERROR: .endm without .macro"; 84 | } 85 | $current_macro = ''; 86 | } elsif ($current_macro) { 87 | push(@{$macro_lines{$current_macro}}, $_); 88 | } else { 89 | expand_macros($_); 90 | } 91 | } 92 | 93 | sub expand_macros { 94 | my $line = @_[0]; 95 | if ($line =~ /(\S+:|)\s*([\w\d\.]+)\s*(.*)/ && exists $macro_lines{$2}) { 96 | push(@pass1_lines, $1); 97 | my $macro = $2; 98 | 99 | # commas are optional here too, but are syntactically important because 100 | # parameters can be blank 101 | my @arglist = split(/,/, $3); 102 | my @args; 103 | foreach (@arglist) { 104 | my @whitespace_split = split(/\s+/, $_); 105 | if (!@whitespace_split) { 106 | push(@args, ''); 107 | } else { 108 | foreach (@whitespace_split) { 109 | if (length($_)) { 110 | push(@args, $_); 111 | } 112 | } 113 | } 114 | } 115 | 116 | my %replacements; 117 | if ($macro_args_default{$macro}){ 118 | %replacements = %{$macro_args_default{$macro}}; 119 | } 120 | 121 | # construct hashtable of text to replace 122 | foreach my $i (0 .. $#args) { 123 | my $argname = $macro_args{$macro}[$i]; 124 | 125 | if ($args[$i] =~ m/=/) { 126 | # arg=val references the argument name 127 | # XXX: I'm not sure what the expected behaviour if a lot of 128 | # these are mixed with unnamed args 129 | my @named_arg = split(/=/, $args[$i]); 130 | $replacements{$named_arg[0]} = $named_arg[1]; 131 | } elsif ($i > $#{$macro_args{$macro}}) { 132 | # more args given than the macro has named args 133 | # XXX: is vararg allowed on arguments before the last? 134 | $argname = $macro_args{$macro}[-1]; 135 | if ($argname =~ s/:vararg$//) { 136 | $replacements{$argname} .= ", $args[$i]"; 137 | } else { 138 | die "Too many arguments to macro $macro"; 139 | } 140 | } else { 141 | $argname =~ s/:vararg$//; 142 | $replacements{$argname} = $args[$i]; 143 | } 144 | } 145 | 146 | # apply replacements as regex 147 | foreach (@{$macro_lines{$macro}}) { 148 | my $macro_line = $_; 149 | # do replacements by longest first, this avoids wrong replacement 150 | # when argument names are subsets of each other 151 | foreach (reverse sort {length $a <=> length $b} keys %replacements) { 152 | $macro_line =~ s/\\$_/$replacements{$_}/g; 153 | } 154 | $macro_line =~ s/\\\(\)//g; # remove \() 155 | expand_macros($macro_line); 156 | } 157 | } else { 158 | push(@pass1_lines, $line); 159 | } 160 | } 161 | 162 | close(ASMFILE) or exit 1; 163 | open(ASMFILE, "|-", $gcc_cmd) or die "Error running assembler"; 164 | 165 | my @sections; 166 | my $num_repts; 167 | my $rept_lines; 168 | 169 | my %literal_labels; # for ldr , = 170 | my $literal_num = 0; 171 | 172 | # pass 2: parse .rept and .if variants 173 | # NOTE: since we don't implement a proper parser, using .rept with a 174 | # variable assigned from .set is not supported 175 | foreach my $line (@pass1_lines) { 176 | # textual comparison .if 177 | # this assumes nothing else on the same line 178 | if ($line =~ /\.ifnb\s+(.*)/) { 179 | if ($1) { 180 | $line = ".if 1\n"; 181 | } else { 182 | $line = ".if 0\n"; 183 | } 184 | } elsif ($line =~ /\.ifb\s+(.*)/) { 185 | if ($1) { 186 | $line = ".if 0\n"; 187 | } else { 188 | $line = ".if 1\n"; 189 | } 190 | } elsif ($line =~ /\.ifc\s+(.*)\s*,\s*(.*)/) { 191 | if ($1 eq $2) { 192 | $line = ".if 1\n"; 193 | } else { 194 | $line = ".if 0\n"; 195 | } 196 | } 197 | 198 | # handle .previous (only with regard to .section not .subsection) 199 | if ($line =~ /\.(section|text|const_data)/) { 200 | push(@sections, $line); 201 | } elsif ($line =~ /\.previous/) { 202 | if (!$sections[-2]) { 203 | die ".previous without a previous section"; 204 | } 205 | $line = $sections[-2]; 206 | push(@sections, $line); 207 | } 208 | 209 | # handle ldr , = 210 | if ($line =~ /(.*)\s*ldr([\w\s\d]+)\s*,\s*=(.*)/) { 211 | my $label = $literal_labels{$3}; 212 | if (!$label) { 213 | $label = ".Literal_$literal_num"; 214 | $literal_num++; 215 | $literal_labels{$3} = $label; 216 | } 217 | $line = "$1 ldr$2, $label\n"; 218 | } elsif ($line =~ /\.ltorg/) { 219 | foreach my $literal (keys %literal_labels) { 220 | $line .= "$literal_labels{$literal}:\n .word $literal\n"; 221 | } 222 | %literal_labels = (); 223 | } 224 | 225 | # @l -> lo16() @ha -> ha16() 226 | $line =~ s/,\s+([^,]+)\@l(\s)/, lo16($1)$2/g; 227 | $line =~ s/,\s+([^,]+)\@ha(\s)/, ha16($1)$2/g; 228 | 229 | if ($line =~ /\.rept\s+(.*)/) { 230 | $num_repts = $1; 231 | $rept_lines = "\n"; 232 | 233 | # handle the possibility of repeating another directive on the same line 234 | # .endr on the same line is not valid, I don't know if a non-directive is 235 | if ($num_repts =~ s/(\.\w+.*)//) { 236 | $rept_lines .= "$1\n"; 237 | } 238 | $num_repts = eval($num_repts); 239 | } elsif ($line =~ /\.endr/) { 240 | for (1 .. $num_repts) { 241 | print ASMFILE $rept_lines; 242 | } 243 | $rept_lines = ''; 244 | } elsif ($rept_lines) { 245 | $rept_lines .= $line; 246 | } else { 247 | print ASMFILE $line; 248 | } 249 | } 250 | 251 | print ASMFILE ".text\n"; 252 | foreach my $literal (keys %literal_labels) { 253 | print ASMFILE "$literal_labels{$literal}:\n .word $literal\n"; 254 | } 255 | 256 | close(ASMFILE) or exit 1; 257 | -------------------------------------------------------------------------------- /h265_ex3.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alb423/iFrameExtractor/c64609dd34c2064e8e2680c1f2441aeed628c500/h265_ex3.mp4 -------------------------------------------------------------------------------- /iFrameExtractor-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleVersion 22 | 1.0 23 | LSRequiresIPhoneOS 24 | 25 | NSPhotoLibraryUsageDescription 26 | Save SnapShot Image 27 | UIMainStoryboardFile 28 | Storyboard 29 | UIRequiresFullScreen 30 | 31 | UIStatusBarHidden 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationLandscapeLeft 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /iFrameExtractor.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0918E6D110F839FC00300130 /* sophie.mov in Resources */ = {isa = PBXBuildFile; fileRef = 0918E6D010F839FC00300130 /* sophie.mov */; }; 11 | 0921E14110FADAFB004EAA40 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 0921E14010FADAFB004EAA40 /* Utilities.m */; }; 12 | 0921E14610FADB97004EAA40 /* VideoFrameExtractor.m in Sources */ = {isa = PBXBuildFile; fileRef = 0921E14510FADB97004EAA40 /* VideoFrameExtractor.m */; }; 13 | 09A69722110EC23900FE1DA8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 14 | 09F1D692110ED3AA00F50511 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 09F1D691110ED3AA00F50511 /* Default.png */; }; 15 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 16 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 17 | 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; 18 | 9A06E9231DE5E36700607CE9 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A06E9221DE5E36700607CE9 /* CoreVideo.framework */; }; 19 | 9A0B57391DE6F23B0069FE9A /* h265_ex3.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 9A0B57381DE6F23B0069FE9A /* h265_ex3.mp4 */; }; 20 | 9A0C258D1DE2ECCE00887B2A /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C258C1DE2ECCE00887B2A /* libz.tbd */; }; 21 | 9A0C25931DE2ED8800887B2A /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A0C25921DE2ED8800887B2A /* VideoToolbox.framework */; }; 22 | 9A1387681DE5E7A9007C5F0B /* libavcodec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A1387611DE5E7A9007C5F0B /* libavcodec.a */; }; 23 | 9A1387691DE5E7A9007C5F0B /* libavdevice.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A1387621DE5E7A9007C5F0B /* libavdevice.a */; }; 24 | 9A13876A1DE5E7A9007C5F0B /* libavfilter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A1387631DE5E7A9007C5F0B /* libavfilter.a */; }; 25 | 9A13876B1DE5E7A9007C5F0B /* libavformat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A1387641DE5E7A9007C5F0B /* libavformat.a */; }; 26 | 9A13876C1DE5E7A9007C5F0B /* libavutil.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A1387651DE5E7A9007C5F0B /* libavutil.a */; }; 27 | 9A13876D1DE5E7A9007C5F0B /* libswresample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A1387661DE5E7A9007C5F0B /* libswresample.a */; }; 28 | 9A13876E1DE5E7A9007C5F0B /* libswscale.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A1387671DE5E7A9007C5F0B /* libswscale.a */; }; 29 | 9A13877B1DE5ED57007C5F0B /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A06E9241DE5E36E00607CE9 /* CoreMedia.framework */; }; 30 | 9A1387861DE5FB76007C5F0B /* libiconv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A13877D1DE5EDD9007C5F0B /* libiconv.tbd */; }; 31 | 9A170D5C181657A000AB5B82 /* AudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A170D56181657A000AB5B82 /* AudioPlayer.m */; }; 32 | 9A170D5D181657A000AB5B82 /* AudioUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A170D58181657A000AB5B82 /* AudioUtilities.m */; }; 33 | 9A170D5E181657A000AB5B82 /* AudioPacketQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A170D5A181657A000AB5B82 /* AudioPacketQueue.m */; }; 34 | 9A170D601816581700AB5B82 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A170D5F1816581700AB5B82 /* AudioToolbox.framework */; }; 35 | 9A170D621816582E00AB5B82 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A170D611816582E00AB5B82 /* AVFoundation.framework */; }; 36 | 9A4B20E31E083D8400010C1B /* 7h800-2.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 9A4B20E21E083D8400010C1B /* 7h800-2.mp4 */; }; 37 | 9A95E74F174F5AA6008EB183 /* H264_Save.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A95E74E174F5AA6008EB183 /* H264_Save.m */; }; 38 | 9AA118961DE2EF3F00401F21 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AA118951DE2EF3F00401F21 /* libbz2.tbd */; }; 39 | 9AD2375B1DE6B74A00ACA7DD /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9AD2375A1DE6B74A00ACA7DD /* Storyboard.storyboard */; }; 40 | 9AD237611DE6BD8800ACA7DD /* iFrameExtractorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AD237601DE6BD8800ACA7DD /* iFrameExtractorViewController.m */; }; 41 | 9AD237641DE6C37100ACA7DD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AD237631DE6C37100ACA7DD /* AppDelegate.m */; }; 42 | 9AD2376A1DE6E8EA00ACA7DD /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ADF204B1761BCFD0018ACF3 /* AssetsLibrary.framework */; }; 43 | 9ADF204A1761B6180018ACF3 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9ADF20491761B6180018ACF3 /* Default-568h@2x.png */; }; 44 | /* End PBXBuildFile section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | 0918E6D010F839FC00300130 /* sophie.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = sophie.mov; sourceTree = ""; }; 48 | 0921E13F10FADAFB004EAA40 /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = ""; }; 49 | 0921E14010FADAFB004EAA40 /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utilities.m; sourceTree = ""; }; 50 | 0921E14410FADB97004EAA40 /* VideoFrameExtractor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoFrameExtractor.h; sourceTree = ""; }; 51 | 0921E14510FADB97004EAA40 /* VideoFrameExtractor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoFrameExtractor.m; sourceTree = ""; }; 52 | 09F1D691110ED3AA00F50511 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 53 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 54 | 1D6058910D05DD3D006BFB54 /* iFrameExtractor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iFrameExtractor.app; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 56 | 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 57 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 58 | 32CA4F630368D1EE00C91783 /* iFrameExtractor_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iFrameExtractor_Prefix.pch; sourceTree = ""; }; 59 | 8D1107310486CEB800E47090 /* iFrameExtractor-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "iFrameExtractor-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 60 | 9A06E9221DE5E36700607CE9 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; 61 | 9A06E9241DE5E36E00607CE9 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; 62 | 9A0B57381DE6F23B0069FE9A /* h265_ex3.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = h265_ex3.mp4; sourceTree = ""; }; 63 | 9A0C258C1DE2ECCE00887B2A /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 64 | 9A0C25921DE2ED8800887B2A /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; }; 65 | 9A13875F1DE5E71A007C5F0B /* libiconv.2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.2.tbd; path = usr/lib/libiconv.2.tbd; sourceTree = SDKROOT; }; 66 | 9A1387611DE5E7A9007C5F0B /* libavcodec.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavcodec.a; path = ../thin/armv7/lib/libavcodec.a; sourceTree = ""; }; 67 | 9A1387621DE5E7A9007C5F0B /* libavdevice.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavdevice.a; path = ../thin/armv7/lib/libavdevice.a; sourceTree = ""; }; 68 | 9A1387631DE5E7A9007C5F0B /* libavfilter.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavfilter.a; path = ../thin/armv7/lib/libavfilter.a; sourceTree = ""; }; 69 | 9A1387641DE5E7A9007C5F0B /* libavformat.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavformat.a; path = ../thin/armv7/lib/libavformat.a; sourceTree = ""; }; 70 | 9A1387651DE5E7A9007C5F0B /* libavutil.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavutil.a; path = ../thin/armv7/lib/libavutil.a; sourceTree = ""; }; 71 | 9A1387661DE5E7A9007C5F0B /* libswresample.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswresample.a; path = ../thin/armv7/lib/libswresample.a; sourceTree = ""; }; 72 | 9A1387671DE5E7A9007C5F0B /* libswscale.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswscale.a; path = ../thin/armv7/lib/libswscale.a; sourceTree = ""; }; 73 | 9A13877D1DE5EDD9007C5F0B /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; }; 74 | 9A170D56181657A000AB5B82 /* AudioPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioPlayer.m; sourceTree = ""; }; 75 | 9A170D57181657A000AB5B82 /* AudioPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioPlayer.h; sourceTree = ""; }; 76 | 9A170D58181657A000AB5B82 /* AudioUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioUtilities.m; sourceTree = ""; }; 77 | 9A170D59181657A000AB5B82 /* AudioUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioUtilities.h; sourceTree = ""; }; 78 | 9A170D5A181657A000AB5B82 /* AudioPacketQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioPacketQueue.m; sourceTree = ""; }; 79 | 9A170D5B181657A000AB5B82 /* AudioPacketQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioPacketQueue.h; sourceTree = ""; }; 80 | 9A170D5F1816581700AB5B82 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 81 | 9A170D611816582E00AB5B82 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 82 | 9A4B20E21E083D8400010C1B /* 7h800-2.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "7h800-2.mp4"; sourceTree = ""; }; 83 | 9A95E74E174F5AA6008EB183 /* H264_Save.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = H264_Save.m; sourceTree = ""; }; 84 | 9A95E750174F5AC0008EB183 /* H264_Save.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = H264_Save.h; sourceTree = ""; }; 85 | 9AA118951DE2EF3F00401F21 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; }; 86 | 9AD2375A1DE6B74A00ACA7DD /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = ""; }; 87 | 9AD2375F1DE6BD8800ACA7DD /* iFrameExtractorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iFrameExtractorViewController.h; sourceTree = ""; }; 88 | 9AD237601DE6BD8800ACA7DD /* iFrameExtractorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iFrameExtractorViewController.m; sourceTree = ""; }; 89 | 9AD237621DE6C37100ACA7DD /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 90 | 9AD237631DE6C37100ACA7DD /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 91 | 9ADF20491761B6180018ACF3 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 92 | 9ADF204B1761BCFD0018ACF3 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; 93 | /* End PBXFileReference section */ 94 | 95 | /* Begin PBXFrameworksBuildPhase section */ 96 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 97 | isa = PBXFrameworksBuildPhase; 98 | buildActionMask = 2147483647; 99 | files = ( 100 | 9AD2376A1DE6E8EA00ACA7DD /* AssetsLibrary.framework in Frameworks */, 101 | 9A170D621816582E00AB5B82 /* AVFoundation.framework in Frameworks */, 102 | 9A170D601816581700AB5B82 /* AudioToolbox.framework in Frameworks */, 103 | 9A13877B1DE5ED57007C5F0B /* CoreMedia.framework in Frameworks */, 104 | 9A06E9231DE5E36700607CE9 /* CoreVideo.framework in Frameworks */, 105 | 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */, 106 | 09A69722110EC23900FE1DA8 /* Foundation.framework in Frameworks */, 107 | 9A0C25931DE2ED8800887B2A /* VideoToolbox.framework in Frameworks */, 108 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 109 | 9A1387861DE5FB76007C5F0B /* libiconv.tbd in Frameworks */, 110 | 9AA118961DE2EF3F00401F21 /* libbz2.tbd in Frameworks */, 111 | 9A0C258D1DE2ECCE00887B2A /* libz.tbd in Frameworks */, 112 | 9A1387681DE5E7A9007C5F0B /* libavcodec.a in Frameworks */, 113 | 9A1387691DE5E7A9007C5F0B /* libavdevice.a in Frameworks */, 114 | 9A13876A1DE5E7A9007C5F0B /* libavfilter.a in Frameworks */, 115 | 9A13876B1DE5E7A9007C5F0B /* libavformat.a in Frameworks */, 116 | 9A13876C1DE5E7A9007C5F0B /* libavutil.a in Frameworks */, 117 | 9A13876D1DE5E7A9007C5F0B /* libswresample.a in Frameworks */, 118 | 9A13876E1DE5E7A9007C5F0B /* libswscale.a in Frameworks */, 119 | ); 120 | runOnlyForDeploymentPostprocessing = 0; 121 | }; 122 | /* End PBXFrameworksBuildPhase section */ 123 | 124 | /* Begin PBXGroup section */ 125 | 080E96DDFE201D6D7F000001 /* Classes */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 9A170D551816578F00AB5B82 /* AudioPlayer */, 129 | 0921E13F10FADAFB004EAA40 /* Utilities.h */, 130 | 0921E14010FADAFB004EAA40 /* Utilities.m */, 131 | 0921E14410FADB97004EAA40 /* VideoFrameExtractor.h */, 132 | 0921E14510FADB97004EAA40 /* VideoFrameExtractor.m */, 133 | 9A95E74E174F5AA6008EB183 /* H264_Save.m */, 134 | 9A95E750174F5AC0008EB183 /* H264_Save.h */, 135 | 9AD2375F1DE6BD8800ACA7DD /* iFrameExtractorViewController.h */, 136 | 9AD237601DE6BD8800ACA7DD /* iFrameExtractorViewController.m */, 137 | 9AD237621DE6C37100ACA7DD /* AppDelegate.h */, 138 | 9AD237631DE6C37100ACA7DD /* AppDelegate.m */, 139 | ); 140 | path = Classes; 141 | sourceTree = ""; 142 | }; 143 | 0918E6C310F839A300300130 /* ffmpeg */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | ); 147 | path = ffmpeg; 148 | sourceTree = ""; 149 | }; 150 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 1D6058910D05DD3D006BFB54 /* iFrameExtractor.app */, 154 | ); 155 | name = Products; 156 | sourceTree = ""; 157 | }; 158 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 9ADF20491761B6180018ACF3 /* Default-568h@2x.png */, 162 | 0918E6C310F839A300300130 /* ffmpeg */, 163 | 080E96DDFE201D6D7F000001 /* Classes */, 164 | 29B97315FDCFA39411CA2CEA /* Other Sources */, 165 | 29B97317FDCFA39411CA2CEA /* Resources */, 166 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 167 | 19C28FACFE9D520D11CA2CBB /* Products */, 168 | ); 169 | name = CustomTemplate; 170 | sourceTree = ""; 171 | }; 172 | 29B97315FDCFA39411CA2CEA /* Other Sources */ = { 173 | isa = PBXGroup; 174 | children = ( 175 | 32CA4F630368D1EE00C91783 /* iFrameExtractor_Prefix.pch */, 176 | 29B97316FDCFA39411CA2CEA /* main.m */, 177 | ); 178 | name = "Other Sources"; 179 | sourceTree = ""; 180 | }; 181 | 29B97317FDCFA39411CA2CEA /* Resources */ = { 182 | isa = PBXGroup; 183 | children = ( 184 | 9A4B20E21E083D8400010C1B /* 7h800-2.mp4 */, 185 | 9A0B57381DE6F23B0069FE9A /* h265_ex3.mp4 */, 186 | 09F1D691110ED3AA00F50511 /* Default.png */, 187 | 0918E6D010F839FC00300130 /* sophie.mov */, 188 | 8D1107310486CEB800E47090 /* iFrameExtractor-Info.plist */, 189 | 9AD2375A1DE6B74A00ACA7DD /* Storyboard.storyboard */, 190 | ); 191 | name = Resources; 192 | sourceTree = ""; 193 | }; 194 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 195 | isa = PBXGroup; 196 | children = ( 197 | 9A13877D1DE5EDD9007C5F0B /* libiconv.tbd */, 198 | 9A1387611DE5E7A9007C5F0B /* libavcodec.a */, 199 | 9A1387621DE5E7A9007C5F0B /* libavdevice.a */, 200 | 9A1387631DE5E7A9007C5F0B /* libavfilter.a */, 201 | 9A1387641DE5E7A9007C5F0B /* libavformat.a */, 202 | 9A1387651DE5E7A9007C5F0B /* libavutil.a */, 203 | 9A1387661DE5E7A9007C5F0B /* libswresample.a */, 204 | 9A1387671DE5E7A9007C5F0B /* libswscale.a */, 205 | 9A13875F1DE5E71A007C5F0B /* libiconv.2.tbd */, 206 | 9A06E9241DE5E36E00607CE9 /* CoreMedia.framework */, 207 | 9A06E9221DE5E36700607CE9 /* CoreVideo.framework */, 208 | 9AA118951DE2EF3F00401F21 /* libbz2.tbd */, 209 | 9A0C25921DE2ED8800887B2A /* VideoToolbox.framework */, 210 | 9A0C258C1DE2ECCE00887B2A /* libz.tbd */, 211 | 9A170D611816582E00AB5B82 /* AVFoundation.framework */, 212 | 9A170D5F1816581700AB5B82 /* AudioToolbox.framework */, 213 | 9ADF204B1761BCFD0018ACF3 /* AssetsLibrary.framework */, 214 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 215 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 216 | 288765FC0DF74451002DB57D /* CoreGraphics.framework */, 217 | ); 218 | name = Frameworks; 219 | sourceTree = ""; 220 | }; 221 | 9A170D551816578F00AB5B82 /* AudioPlayer */ = { 222 | isa = PBXGroup; 223 | children = ( 224 | 9A170D56181657A000AB5B82 /* AudioPlayer.m */, 225 | 9A170D57181657A000AB5B82 /* AudioPlayer.h */, 226 | 9A170D58181657A000AB5B82 /* AudioUtilities.m */, 227 | 9A170D59181657A000AB5B82 /* AudioUtilities.h */, 228 | 9A170D5A181657A000AB5B82 /* AudioPacketQueue.m */, 229 | 9A170D5B181657A000AB5B82 /* AudioPacketQueue.h */, 230 | ); 231 | name = AudioPlayer; 232 | sourceTree = ""; 233 | }; 234 | /* End PBXGroup section */ 235 | 236 | /* Begin PBXNativeTarget section */ 237 | 1D6058900D05DD3D006BFB54 /* iFrameExtractor */ = { 238 | isa = PBXNativeTarget; 239 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "iFrameExtractor" */; 240 | buildPhases = ( 241 | 1D60588D0D05DD3D006BFB54 /* Resources */, 242 | 1D60588E0D05DD3D006BFB54 /* Sources */, 243 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 244 | ); 245 | buildRules = ( 246 | ); 247 | dependencies = ( 248 | ); 249 | name = iFrameExtractor; 250 | productName = frameExtractor; 251 | productReference = 1D6058910D05DD3D006BFB54 /* iFrameExtractor.app */; 252 | productType = "com.apple.product-type.application"; 253 | }; 254 | /* End PBXNativeTarget section */ 255 | 256 | /* Begin PBXProject section */ 257 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 258 | isa = PBXProject; 259 | attributes = { 260 | LastUpgradeCheck = 0810; 261 | TargetAttributes = { 262 | 1D6058900D05DD3D006BFB54 = { 263 | DevelopmentTeam = 7GD32M775H; 264 | }; 265 | }; 266 | }; 267 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "iFrameExtractor" */; 268 | compatibilityVersion = "Xcode 3.2"; 269 | developmentRegion = English; 270 | hasScannedForEncodings = 1; 271 | knownRegions = ( 272 | en, 273 | ); 274 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 275 | projectDirPath = ""; 276 | projectRoot = ""; 277 | targets = ( 278 | 1D6058900D05DD3D006BFB54 /* iFrameExtractor */, 279 | ); 280 | }; 281 | /* End PBXProject section */ 282 | 283 | /* Begin PBXResourcesBuildPhase section */ 284 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 285 | isa = PBXResourcesBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | 0918E6D110F839FC00300130 /* sophie.mov in Resources */, 289 | 09F1D692110ED3AA00F50511 /* Default.png in Resources */, 290 | 9ADF204A1761B6180018ACF3 /* Default-568h@2x.png in Resources */, 291 | 9AD2375B1DE6B74A00ACA7DD /* Storyboard.storyboard in Resources */, 292 | 9A4B20E31E083D8400010C1B /* 7h800-2.mp4 in Resources */, 293 | 9A0B57391DE6F23B0069FE9A /* h265_ex3.mp4 in Resources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | /* End PBXResourcesBuildPhase section */ 298 | 299 | /* Begin PBXSourcesBuildPhase section */ 300 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 301 | isa = PBXSourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 305 | 9A170D5C181657A000AB5B82 /* AudioPlayer.m in Sources */, 306 | 9AD237611DE6BD8800ACA7DD /* iFrameExtractorViewController.m in Sources */, 307 | 9AD237641DE6C37100ACA7DD /* AppDelegate.m in Sources */, 308 | 0921E14110FADAFB004EAA40 /* Utilities.m in Sources */, 309 | 9A170D5E181657A000AB5B82 /* AudioPacketQueue.m in Sources */, 310 | 0921E14610FADB97004EAA40 /* VideoFrameExtractor.m in Sources */, 311 | 9A170D5D181657A000AB5B82 /* AudioUtilities.m in Sources */, 312 | 9A95E74F174F5AA6008EB183 /* H264_Save.m in Sources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | /* End PBXSourcesBuildPhase section */ 317 | 318 | /* Begin XCBuildConfiguration section */ 319 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CODE_SIGN_IDENTITY = "iPhone Developer: kuohsun liao (6B99YHMHBR)"; 324 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: kuohsun liao (6B99YHMHBR)"; 325 | COPY_PHASE_STRIP = NO; 326 | GCC_DYNAMIC_NO_PIC = NO; 327 | GCC_OPTIMIZATION_LEVEL = 0; 328 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 329 | GCC_PREFIX_HEADER = iFrameExtractor_Prefix.pch; 330 | HEADER_SEARCH_PATHS = /Users/liaokuohsun/Work/thin/x86_64/include; 331 | "HEADER_SEARCH_PATHS[sdk=iphoneos*]" = /Users/liaokuohsun/Work/thin/arm64/include; 332 | INFOPLIST_FILE = "iFrameExtractor-Info.plist"; 333 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 334 | LIBRARY_SEARCH_PATHS = ""; 335 | "LIBRARY_SEARCH_PATHS[sdk=iphoneos*]" = /Users/liaokuohsun/Work/thin/arm64/lib; 336 | "LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*]" = ( 337 | "$(inherited)", 338 | /Users/liaokuohsun/Work/thin/x86_64/lib, 339 | ); 340 | PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.${PRODUCT_NAME:rfc1034identifier}"; 341 | PRODUCT_NAME = iFrameExtractor; 342 | SDKROOT = iphoneos; 343 | TARGETED_DEVICE_FAMILY = 1; 344 | VALID_ARCHS = "arm64 armv7 armv7s x86_64"; 345 | }; 346 | name = Debug; 347 | }; 348 | 1D6058950D05DD3E006BFB54 /* Release */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CODE_SIGN_IDENTITY = "iPhone Developer: kuohsun liao (6B99YHMHBR)"; 353 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 354 | COPY_PHASE_STRIP = YES; 355 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 356 | GCC_PREFIX_HEADER = iFrameExtractor_Prefix.pch; 357 | HEADER_SEARCH_PATHS = /Users/liaokuohsun/Work/thin/arm64/include; 358 | INFOPLIST_FILE = "iFrameExtractor-Info.plist"; 359 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 360 | LIBRARY_SEARCH_PATHS = ""; 361 | PRODUCT_BUNDLE_IDENTIFIER = "com.yourcompany.${PRODUCT_NAME:rfc1034identifier}"; 362 | PRODUCT_NAME = iFrameExtractor; 363 | SDKROOT = iphoneos; 364 | TARGETED_DEVICE_FAMILY = 1; 365 | VALID_ARCHS = "arm64 armv7 armv7s x86_64"; 366 | }; 367 | name = Release; 368 | }; 369 | C01FCF4F08A954540054247B /* Debug */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | CLANG_WARN_BOOL_CONVERSION = YES; 373 | CLANG_WARN_CONSTANT_CONVERSION = YES; 374 | CLANG_WARN_EMPTY_BODY = YES; 375 | CLANG_WARN_ENUM_CONVERSION = YES; 376 | CLANG_WARN_INFINITE_RECURSION = YES; 377 | CLANG_WARN_INT_CONVERSION = YES; 378 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 379 | CLANG_WARN_UNREACHABLE_CODE = YES; 380 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 381 | CODE_SIGN_IDENTITY = "iPhone Developer: kuohsun liao (6B99YHMHBR)"; 382 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: kuohsun liao (6B99YHMHBR)"; 383 | DEVELOPMENT_TEAM = 7GD32M775H; 384 | "DEVELOPMENT_TEAM[sdk=*]" = 7GD32M775H; 385 | ENABLE_STRICT_OBJC_MSGSEND = YES; 386 | ENABLE_TESTABILITY = YES; 387 | GCC_C_LANGUAGE_STANDARD = c99; 388 | GCC_NO_COMMON_BLOCKS = YES; 389 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 390 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 391 | GCC_WARN_UNDECLARED_SELECTOR = YES; 392 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 393 | GCC_WARN_UNUSED_FUNCTION = YES; 394 | GCC_WARN_UNUSED_VARIABLE = YES; 395 | HEADER_SEARCH_PATHS = /Users/liaokuohsun/Work/thin/x86_64/include; 396 | "HEADER_SEARCH_PATHS[sdk=iphoneos*]" = /Users/liaokuohsun/Work/thin/arm64/include; 397 | "HEADER_SEARCH_PATHS[sdk=iphonesimulator*]" = /Users/liaokuohsun/Work/thin/x86_64/include; 398 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 399 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 400 | "LIBRARY_SEARCH_PATHS[sdk=iphoneos*]" = /Users/liaokuohsun/Work/thin/arm64/lib; 401 | "LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*]" = ( 402 | "$(inherited)", 403 | /Users/liaokuohsun/Work/thin/x86_64/lib, 404 | ); 405 | ONLY_ACTIVE_ARCH = YES; 406 | "PROVISIONING_PROFILE[sdk=*]" = ""; 407 | PROVISIONING_PROFILE_SPECIFIER = iOS_Wildcard_App_ID; 408 | "PROVISIONING_PROFILE_SPECIFIER[sdk=*]" = iOS_Wildcard_App_ID; 409 | SDKROOT = iphoneos; 410 | }; 411 | name = Debug; 412 | }; 413 | C01FCF5008A954540054247B /* Release */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | CLANG_WARN_BOOL_CONVERSION = YES; 417 | CLANG_WARN_CONSTANT_CONVERSION = YES; 418 | CLANG_WARN_EMPTY_BODY = YES; 419 | CLANG_WARN_ENUM_CONVERSION = YES; 420 | CLANG_WARN_INFINITE_RECURSION = YES; 421 | CLANG_WARN_INT_CONVERSION = YES; 422 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 423 | CLANG_WARN_UNREACHABLE_CODE = YES; 424 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 425 | CODE_SIGN_IDENTITY = "iPhone Developer: kuohsun liao (6B99YHMHBR)"; 426 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: kuohsun liao (6B99YHMHBR)"; 427 | DEVELOPMENT_TEAM = 7GD32M775H; 428 | ENABLE_STRICT_OBJC_MSGSEND = YES; 429 | GCC_C_LANGUAGE_STANDARD = c99; 430 | GCC_NO_COMMON_BLOCKS = YES; 431 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 432 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 433 | GCC_WARN_UNDECLARED_SELECTOR = YES; 434 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 435 | GCC_WARN_UNUSED_FUNCTION = YES; 436 | GCC_WARN_UNUSED_VARIABLE = YES; 437 | HEADER_SEARCH_PATHS = /Users/liaokuohsun/Work/thin/arm64/include; 438 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 439 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 440 | PROVISIONING_PROFILE_SPECIFIER = iOS_Wildcard_App_ID; 441 | SDKROOT = iphoneos; 442 | }; 443 | name = Release; 444 | }; 445 | /* End XCBuildConfiguration section */ 446 | 447 | /* Begin XCConfigurationList section */ 448 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "iFrameExtractor" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | 1D6058940D05DD3E006BFB54 /* Debug */, 452 | 1D6058950D05DD3E006BFB54 /* Release */, 453 | ); 454 | defaultConfigurationIsVisible = 0; 455 | defaultConfigurationName = Debug; 456 | }; 457 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "iFrameExtractor" */ = { 458 | isa = XCConfigurationList; 459 | buildConfigurations = ( 460 | C01FCF4F08A954540054247B /* Debug */, 461 | C01FCF5008A954540054247B /* Release */, 462 | ); 463 | defaultConfigurationIsVisible = 0; 464 | defaultConfigurationName = Debug; 465 | }; 466 | /* End XCConfigurationList section */ 467 | }; 468 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 469 | } 470 | -------------------------------------------------------------------------------- /iFrameExtractor.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /iFrameExtractor.xcodeproj/project.xcworkspace/xcshareddata/iFrameExtractor.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 6675E069-0712-4C47-A0A7-974DF42949A1 9 | IDESourceControlProjectName 10 | iFrameExtractor 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | A0115F42-17FC-4A85-B57E-08272724EE43 14 | https://github.com/alb423/iFrameExtractor.git 15 | 16 | IDESourceControlProjectPath 17 | iFrameExtractor.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | A0115F42-17FC-4A85-B57E-08272724EE43 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/alb423/iFrameExtractor.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | A0115F42-17FC-4A85-B57E-08272724EE43 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | A0115F42-17FC-4A85-B57E-08272724EE43 36 | IDESourceControlWCCName 37 | iFrameExtractor 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /iFrameExtractor.xcodeproj/project.xcworkspace/xcuserdata/wjie.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alb423/iFrameExtractor/c64609dd34c2064e8e2680c1f2441aeed628c500/iFrameExtractor.xcodeproj/project.xcworkspace/xcuserdata/wjie.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /iFrameExtractor.xcodeproj/xcuserdata/liaokuohsun.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /iFrameExtractor.xcodeproj/xcuserdata/wjie.xcuserdatad/xcschemes/iFrameExtractor.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /iFrameExtractor.xcodeproj/xcuserdata/wjie.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | iFrameExtractor.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1D6058900D05DD3D006BFB54 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /iFrameExtractor_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'frameExtractor' target in the 'frameExtractor' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // iFrameExtractor 4 | // 5 | // Created by lajos on 1/8/10. 6 | // 7 | // Copyright 2010 Lajos Kamocsay 8 | // 9 | // lajos at codza dot com 10 | // 11 | // iFrameExtractor is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU Lesser General Public 13 | // License as published by the Free Software Foundation; either 14 | // version 2.1 of the License, or (at your option) any later version. 15 | // 16 | // iFrameExtractor is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Lesser General Public License for more details. 20 | // 21 | 22 | #import 23 | 24 | int main(int argc, char *argv[]) { 25 | 26 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 27 | //int retVal = UIApplicationMain(argc, argv, nil, nil); 28 | int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); 29 | 30 | [pool release]; 31 | return retVal; 32 | } 33 | -------------------------------------------------------------------------------- /sophie.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alb423/iFrameExtractor/c64609dd34c2064e8e2680c1f2441aeed628c500/sophie.mov --------------------------------------------------------------------------------